getNextSibling() strange returns.
-
hi there,
i have a while loop where i iterate a list of sprites.
i assume getNextSibling returns the next object in the order of the objects Priority.however for some reason getNextSibling returns the objects 1,3,5. leaving out 2 and 4. and i cant understand why.
this is an example of my loop
while(a->getNextSibling())
{
a->setPosition(a->getNextSibling()->getPosition());
a = safeSpCast<Sprite>(d->getNextSibling());
}
#returns siblings 1,3,5. should return 1,2,3,4,5...any ideas?
-
you pasted really strange code, i dont understand it:)
try this
spActor child = actor->getFirstChild();while(child)
{
logs::messageln(child->getName().c_str());
child = child->getNextSibling();
}
-
Hi @Oxygine.
I'm a bit of a novice .
Basically i'm trying to swap the positions and priorities of a array of sprites, the problem is when i swap one sprite it puts two sprites on the same priority. That gives me the issue i'm having with GetNextSibling().because there are two sprites on the same priority getnextsibling() returns the sibling with the priority recently changed.
do you have any ideas of a better way to do this?
-
store your Actors list in additional std::vector
-
Thanks @ oxygine