I have an 8 by 8 matrix of sprites that I need to be able to rotate all of them 90 degrees at once. The way I've done it is using nested for loops, and a 2 dimensional array of sprite pointers.
for(row = 0;row<9;row++){
for(column = 0;column<8;column++){
[trolls[row][column] runAction:[RotateBy actionWithDuration:0.01 angle:90]];
}
}
Is there a more efficient way of doing this? There seems to be a lag before they all rotate.
EDIT: here's is more of my code to respond to the alchemist:
@interface GameLayer : CCLayer {
CCSprite *monsters[8][8];
//other code ...
}
@property @property (nonatomic,retain) *monsters
//other code ...
@end
@implementation
@synthesize monsters
-(void)init {
NSString *filename;
int row,column,randnum;
for(row = 0;row<9;row++){
for(column = 0;column<8;column++){
randnNum =(int)Rand(8);
filename =stringWithFormat:@"%d.png",randnNum];
monsters[row][column] = [[[CCSprite alloc] initWithImage:(CGImageRef)filename key:filename] autorelease];
}
}
//other code ...
}