When I messed with addChild and addChildAt methods, I discovered that I couldn't pass an index that was beyond the number of already added child.
For example, if I added 2 images using addChild method, I couldn't then add a new sprite with addChildAt method and passing 4 as an index.
So my guess is if I want to use the addChildMethod, I can add a new sprite at the end of some kind of list of sprites using a number_of_childs + 1 index value. And if I want to replace a child at a specific index with a new one, I just have to pass the index of the original sprite.
In that case, does all the sprites with index superior or equal to that value are displaced with their index incremented by 1?
Comments
ps.\\ to work with layers
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Sprite:addChild(child)
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
stage:addChildAt(child1, 3)
--stage{child2,child3,child1}
stage:addChild(child4)
--stage{child2,child3,child1,child4}
stage:removeChildAt(2)
--stage{child2,child1,child4}
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
"In that case, does all the sprites with index superior or equal to that value are displaced with their index incremented by 1?"
- yes
"using a number_of_childs + 1 index value."
- yes, use Sprite:getNumChildren()
Fragmenter - animated loop machine and IKONOMIKON - the memory game