Ninjadoodle Posted June 23, 2018 Share Posted June 23, 2018 Hi @enpu I could swear that there was a depth swapping example floating around for Panda 2, but I can't find it. Is there something like this hiding somewhere, or am I just being blind? Thank you! Quote Link to comment Share on other sites More sharing options...
enpu Posted June 23, 2018 Share Posted June 23, 2018 Just added this: https://www.panda2.io/examples#container-swap Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 23, 2018 Author Share Posted June 23, 2018 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? Quote Link to comment Share on other sites More sharing options...
enpu Posted June 23, 2018 Share Posted June 23, 2018 Swap the sprite you want to be in top with the sprite that is in top (which is first children of the container). sprite.swap(container.children[0]); Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 23, 2018 Author Share Posted June 23, 2018 @enpu 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) *** Quote Link to comment Share on other sites More sharing options...
enpu Posted June 23, 2018 Share Posted June 23, 2018 @Ninjadoodle 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 Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 23, 2018 Author Share Posted June 23, 2018 @enpu You're a legend! Thanks heaps for adding these so quick - these will be extremely useful for any 'point and click' style games Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.