Closed inkeliz closed 4 years ago
It does this because it has to set rs.sortingNeeded so that the system can sort the textures properly. If it's public and you set it yourself, it may not actually do anything, since the textures still draw in the same order every pass.
I do see what you mean, though. I think maybe there can be another public variable, such as StartZIndex
, that sets the starting Z-Index. Then near the top of the render system's Add function, you just call SetZIndex(render.StartZIndex)
. Would that solve your problem?
Yes, I don't thought that someone will set something.ZIndex = 3
after already use the render.Add(...)
. 😅
The StartZIndex
is better.
EDIT: But, I'm not sure if I understand it. Because the sorting
also uses the .Position.Y
and .Position.X
, which might change without triggers the rs.sortingNeeded
, far I'm aware of.
I think it's fine now, the rendering is working as expected. I didn't test on GopherJS. I'm going to sleep now. 😅
Looks good, thank you for your contribution!
I'm not sure why, but the current version of Engo has a
zIndex
as private value.The only way to set ZIndex is by using
SetZIndex
, at the current version. That makes it impossible to set the value in advanced (at the&RenderComponent{}
). In my case doesn't make any sense to set the ZIndex using theSetZIndex
, since some elements have always the same ZIndex (like: background is 0 and player is 1).I'm not aware of any issue of that change, but I don't know what wasn't public before.