Proper way to set the z-index of any sprite we add later in the game

edited September 2012 in Development
After the game starts, I have added a sprite to a pre-existing group. But I need this sprite to be before other sprites of this group. What is the proper (less messy) way to layer a sprites that we add later into a pre-existing group?

For example, on keypress, I have added a sprite, but now need it to be first in the group.

thanks!

Comments

  • Accepted Answer
    You can use the .z() function to set the z-index.
  • Im trying to set a sprite from a different group to be on front of the first group (visible) whitout drop it out the group, but cant make it work.

    i changed the z-index and tried with the z() function and nothing.
  • If a group A has a smaller z-index than a group B, every elements of A will be "behind" each elements of B. You will have to change the group of an element of A to make it in front of an element of B.
Sign In or Register to comment.