I wanna to zoom a group of about 10 sprites at the same time. The sprites are different sprite layers with transparent background.
I'm trying to preattach all the sprite at first to the layer and store the reference in an array. After that as I click the button I do this: Sorry this is Javascript but in Objective-C it's almost the same.
attr.zoomAllVisibleSprites = function() {
for (var i = 0; i < this.SpriteArray.length; i++) {
if (this.SpriteArray[i].isVisible()) {
this.SpriteArray[i].setAnchorPoint(cc.PointMake(0.5,0.5));
this.SpriteArray[i].setScale(2, 2);
}
}
}
The execution of this little snippet requires on my Android phone about 2-3 seconds which is too much for my game. Is there a way to do it faster, optimize this code. Maybe group in a different way the sprites could help ?
You could replace your array of sprites by using a
for
-loop for all CCSprites, like this:Might not help alot, but you can atleast ditch the array ;D