Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Change drawable objects hierarchy ?  (Read 1837 times)

0 Members and 1 Guest are viewing this topic.

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Change drawable objects hierarchy ?
« on: October 06, 2022, 12:07:10 am »
So i wanna make a beat em up game, you see the player from the side but you can also walk up an down. So i need to fix following: When the player is on the y axis higher than another object, the player have to be behind it and when the player's y axis is lower than the object , he is in front of it. Exist there something like to change the drawable objects hierarchy while the game i running and compare the y- axis of the booth?

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Change drawable objects hierarchy ?
« Reply #1 on: October 06, 2022, 08:08:10 am »
For better understanding i post the following code, what i mean, i

if(playerPos.y > enemyPos.y){
                window.draw(player);
                window.draw(enemy);}
                else{
                        window.draw(enemy);
                        window.draw(player);
                }

 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Change drawable objects hierarchy ?
« Reply #2 on: October 06, 2022, 08:46:31 am »
No, SFML always uses the painter's algorithm meaning, whatever you draw first will be the thing in the back and what you draw afterwards, will be drawn over the previous thing.

So if you want to have a specific draw order, you'll have to implement that logic yourself.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything