Hello
I can't seem to find an answer for this, but I hope there is a solution.
I keep reading that running actions is expensive, but I need a lot of moveTo actions.
I have, lets say, 5 different objects you can toss up the screen. Each one of them is different, but created from the same object class. Within those objects I have an action that handles the moveTo for each of these when it has been thrown. Basically I take the difference of the locations between ccTouchesBegan and ccTouchesEnded and I multiply them by 50 (10 being the minimum difference for the x value - thus causing it to go off the screen).
Anyway, once they have reached a given point (x = 480) or they have interacted with another object, I do stuff. Either remove it, change it, or whatever I am doing.
I have gone through all of my code and I have optimized everything I can think of, and when I have a bunch of sprites on the screen at once, everything is fine, fps is 60 and not budging, up until I have thrown a lot of these sprites. So, when a lot of moveTo's have happened, it seems to slow down to about 40fps - sometimes down to 30.
My question is, is there a way to empty the actions when no actions are happening? The only cocosNode actions are the 'throwing' actions I was talking about. I handle all other actions manually. So, if none of those are being thrown, can I release anything being held in action?
From what I understand, everything it set to be removed in [actionsToRemove, right?
Can I just call stopAllActions? It looks like this may not remove them all?.. does it?
The last line of the following in the stopAllActions class confuses me:
-(void) stopAllActions
{
[actionsToAdd removeAllObjects];
[actionsToRemove removeAllObjects];
[actionsToRemove addObjectsFromArray:actions];
}
Anyway, on a side note. Does anyone else have a better way to move something the way I am trying to? Basically I need something like this.
I need to make something move as if it has been thrown up the screen (right now, the further you swipe your finger, the faster the object goes - thus giving the illusion that it's being thrown harder). I need it to bounce off the side walls, but continue up. Right now it slows down after each bounce, which is fine, cause I change the direction of the action when it hits a wall, and I keep the duration the same, but it doesn't need to slow down.
Sorry about the long post. I tried to make it as short as I could. I'm bad with writing a lot.
Thanks for your help!