Hello everybody!
I have a small problem with advanced (I think) positioning.
I added image what shows what I mean (because one image is more than thousand words ;)) as asset to this post.
So, what I have:
I have background-parent layer that has two sprites: box A and box B. Box A has sprite called “item”. Box B ha sprite called “front wall of Box B”. Front wall of Box B has the highest Z value (is on the front of everything what is in box B).
What I want to have:
I want to move with animation sprite “item” from box A to box B so that “front wall of Box B” will cover “item”.
What I think can help:
- RemoveChild “item” from “box A”.
- AddChild “item” to “background” and set position on the same that “item” had in “box A” (so visually nothing will change, but under the hood “item” will have new parent).
- Move “item” from previous position to desired position in “box B”.
- RemoveChild “item” from “background”.
- AddChild “item” to “box B” with Z order lower than “front wall of box B” (after changing parent, position of “item” will change).
- Set position of “item” to proper position inside “box B”.
But I have problem with changing position after change parent. You know, this things with convertToNodeSpace, convertToWorldSpace, etc.
This seems would help but little bit complicated. What do you thing about it?
I would like to mention that “item” at start has to be in “box A”.
trouble.png (45.6 KB)