I'm trying to rotate numerous sprites (about 48 different ones) around an arbitrary point (using this article: http://indiedevstories.com/2012/08/14/custom-cocos2d-action-rotating-sprite-around-arbitrary-point/ ) and I managed to create the custom category for it, but it only works on a single sprite. I've looked around on the site and tried to use runAction:[action copy] but it makes the copies rotating points crazy numbers for some reason. Then I tried to create a method for the actions and just call the method, but I keep getting errors for that as well. I've tried so many different solutions but no luck. So my question is, is there a way I can create another class that holds all of my sprites, and then run a single method to run an action on all of the sprites of the class?
Asked
Active
Viewed 64 times
0
-
The linked code does not implement NSCopying, therefore copy doesn't work. You can still just create a new action for every sprite, same thing. – CodeSmile Jun 06 '13 at 09:43
-
Code will be easier to understand. can you post the relevant pieces ? – giorashc Jun 06 '13 at 10:37
1 Answers
0
Assuming you have an array called spriteArray
containing all sprites you wish to rotate, it's as simple as:
for(CCSprite *sprite in spriteArray)
{
CCRotateAroundBy *rotateAround = [CCRotateAroundBy actionWithDuration:1.0 angle:90 rotationPoint:screenCenter];
[sprite runAction:rotateAround];
}

Lorenzo Linarducci
- 541
- 1
- 4
- 8
-
Does it matter if it's a CCArray, or a NSArray? I have a CCArray called row4 and I initialized it with: `[CCArray arrayWithCapacity:12]`. Then as I added the sprite's file's I used `[row4 addObject:Row4Tile12]`. – evanlws Jun 06 '13 at 21:45
-