Jump to content

Depth Swapping / Bring to top?


Recommended Posts

Hi @enpu

This is awesome, thank you very much!

I do have one case scenario that I'm not sure how to work around tho.

I have a bunch of sprites in a container (4 or 5). Any suggestion on what would be the best way to bring any particular sprite to the top of the container?

Link to comment
Share on other sites


Sorry, but what if I don't know what the top sprite is? Is there a quick way to find out?

In Construct 3, there are a couple of actions called - sendToTop and sendToBottom and they will send the sprite to the top/bottom of the current layer (in Panda's case 'container').

I think these would be really handy to have in Panda :)

Thanks heaps for the tips!

*** EDIT - I just realized that children[0] is the top sprite (feeling stupid tonight lol) ***

Link to comment
Share on other sites


Actually sorry, children[0] is the first children, which gets rendered first, so it is the bottom sprite.

I just added new index parameter to addTo function, which lets you specify the index where the child is added.

sprite.addTo(container, 0); // Add sprite to container as first child

Also adde toBottom and toTop methods to Container class.

sprite.toBottom(); // Move to first children, gets rendered first, so it's bottom
sprite.toTop(); // Move to last children, gets rendered last, so it's top


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...