Thursday, February 5, 2009

Gaining some FPS in your game


So, you want to gain some FPS in your game.
Here is the checklist:
  • Optimize Chipmunk. Follow Skorche's (the author of Chipmunk) tips
  • Compile your code with Thumb support disabled
  • And from cocos2d v0.7 onwards you can use the Fast Director
To enable the Fast Director you need to call:

[Director useFastDirector];

before calling any other Director's method.

Fast Director pros/cons:
  • Calls mainLoop as fast as it can
  • But no faster than 60 FPS (iPhone limitation)
  • Doesn't support IntervalAnimation yet, so you can't force it to, let's say 30 FPS.
For example, the ChipmunkDemo example is running 10 FPS faster using the Fast Director.


In conclusion:
  • If don't need a lot of speed, and you are OK with 30 FPS, then use the old Director since it supports the setIntervalAnimation method.
  • But if you want all the possible FPS then use the Fast Director
Remember: The more FPS, the more battery is consumed.

For more information regarding the FastDirector and how it was implemented see issue #145

[Edit]: Fixed grammar errors, added 'in conclusion'

No comments: