cocos2d-iphoneccspriteccspritebatchnode

How can I update the position of all sprites in a CCSpriteBatchNode?


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.


Solution

  • would not

    myBatchNode.position.x += deltaX;
    

    do the same for you ?