Jump to content

Attach sprite behind sprite?


Recommended Posts



so I'm working on a game and I'm wondering if there's an easy way to code the following. I have an animal sprite, with body, collision, gravity, animations etc all implemented and working like I want. But now I want to add a tail sprite to the animal.


animal.addChild(tail) works like I want only it puts the tail in front and I can't seem to change that. So I'm wondering if there's a simple way like to do the same thing only put it behind the first sprite.


I know you can do stuff with groups, maybe I have to here, but then I have to change how everything interacts with the animal don't I? P.S. it's a cat. :)



Link to comment
Share on other sites

Found this same problem some time before. Tried manually sorting the children array myself, but it seems that the parent ObjectContainer (Sprite in this case) will always be behind.

One simple solution that worked for me was to add the sprite I wanted to be on the back to a Group being under the rest of the objects, and update its position to match the parent on every update call.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...