I currently use Actions for lots of movements, mostly MoveTo's. However, I use Chipmunk for collision detection and for bullets. One issue that most likely slows my game down is the number of actions currently in use. The number of sprites with actions increases every level. I'm wondering if changing from MoveTo's to applying forces via Chipmunk will be more efficient. Can somebody shed some light on the topic? I'd rather not overhaul my code if it's not going to be more efficient.
Which is better? MoveTo or Chipmunk apply force?
(6 posts) (3 voices)-
Posted 2 years ago #
-
what cocos2d version are you using ?
How many actions are you running ?
Are you sure that the thing that is slowing down your game are the actions ?cocos2d v0.8 has faster (much faster) actions.
Posted 2 years ago # -
I have 0.8 beta. I have unlimited levels with each level adding more actions. But during the level, I release the actions when necessary. My game is slow because I didn't use atlasspites yet, but I assume tons of actions will hurt performance as well.
I was wondering if applying forces to chipmunk bodies was more efficient memory wise than moveTo's so I can update my code now. What I noticed in limited testing was it seemed slightly faster using chipmunk.
If you feel 0.8 is that much faster, I can give it a shot.
Posted 2 years ago # -
v0.8-beta is MUCH faster than v0.7.3, and v0.8-rc2 is just a little bit faster than v0.8-beta.
But, I suggest looking at the performance test chart:
http://www.cocos2d-iphone.org/wiki/doku.php/perf_test:0_8#sprite_testsSpecially take a look at rows F and G (sprites + actions).
As you can see
AtlasSpriteis MUCH MUCH faster than simplerSpriteobjects.Compare 450 running sprites + actions:
F(9)=20 FPS (uses sprites of 32x32 pixels)
F(10)=60 FPS (uses atlas sprites of 32x32 pixels)Posted 2 years ago # -
How are you using Cocos actions to modify the locations of chipmunk bodies? Did you modify/extend Cocos to do this? Unless you did, your question doesn't really make much sense to me.
Actions affect CocosNodes, where as applying forces to Chipmunk objects affects Chipmunk Bodies.
However, I also found that many actions taking place at the same time or over and over again (specifically fade-in, fade-out, and delays) affected my performance quite a bit. This was especially the case if I didn't re-use the actions. I ended up allocating all my actions that I would use when the game initialized, then just reused them.
-Sunsu
Posted 2 years ago # -
Riq - I'm using AtlasSprites, but I'm not pulling in a sprite sheet and grabbing sections to create my images. I'm just creating my AtlasSprites from individual PNGs for now. I'm doing this because I'm waiting for updated graphics.
Sunsu - I'm using chipmunk for collisions only. If I use actions, they are applied to the Sprites and don't use body. If I use chipmunk, I just apply a velocity to the chipmunk body instead of actions. The actions are easier for me to use at this point.
I can initiate all the moveTo's ahead of time, but I need to add a different delay to the action each time. I was adding delay on the fly to my actions. I was considering queueing up my actions and using the timer to handle the delay for me. Then I'm reusing the actions straight up.
The issue I have is, I have 6 actions that never change except for the delay. But those 6 actions can be used by multiple Sprites at the same time. Right now I use [action copy] so when I release the action, I don't clobber that same action used by another sprite. Does that make sense?
Posted 2 years ago #
Reply
You must log in to post.