SFML community forums
Help => Graphics => Topic started by: DunklesTier on March 08, 2012, 05:28:35 am
-
Is there any way of forcing a Sprite to be drawn to the screen in a different level than RenderWindow.Draw(Sprite) is called?
Ex. Sprite 1 and Sprite 2 have the same position. Is there a way to tell the RenderWindow to draw Sprite1 on top of Sprite2 even if I call my RenderWindow's Draw function to draw Sprite1 first?
-
Is there any way of forcing a Sprite to be drawn to the screen in a different level than RenderWindow.Draw(Sprite) is called?
No. The only way would be to call your own Draw, which put the sprite in a sorted queue and then flushing it at the end, calling SFML's Draw.
-
I did this by adding a variable called 'Priority' to the game object code. Its range was only 0-4 but provided the key which Laurent spoke of.
At render time, the sprites were drawn according to priority level, 0 being furthest away (first to be drawn), and 4 being the closest (last to be drawn).
-
For this problem, you need use layer
A class is present in wiki :wink:
-
Thanks a lot everyone, I'm going to use the priority system implementation suggested. And Laurent, great engine, by the way.