Question

I have a CCSpriteBatchNode containing 30 sprites. I'd like to move all of the sprites some deltaX. How can I do this?

Here's what I've tried so far:

for (CCSprite *sprite in myBatchNode.children) 
    sprite.position = ccpAdd(sprite.Position, ccp(deltaX, 0.0));

While this works I'm wondering if there's a more efficient way that perhaps doesn't involve explicitly visiting each node in the batch node. Note that I don't want to move the batch node itself.

Was it helpful?

Solution

would not

myBatchNode.position.x += deltaX;

do the same for you ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top