i developed a game using cocos2D javascript that works fine on web browsers but when i run it on mobile ( iPhone 4s , android nexus) the FPS was dropped to 20 - 22 on iPhone (max) how to optimize it to increase the FPS to 30 on mobile .

  • 1
    \$\begingroup\$ If you post some code that is performing badly, we can try to help you optimize it. As your question stands now, there is not much help we can offer you. \$\endgroup\$ – Nate Jul 30 '12 at 15:10
  • \$\begingroup\$ @NateBross when i run the game on a web browser on my PC it gives 60 FPS .. \$\endgroup\$ – Nammari Jul 30 '12 at 16:17
  • 1
    \$\begingroup\$ @Nammari Restating information you've already told us is not too helpful. You need to use a profiler to find the parts of your game that are not performing well. Once you know which parts are not working well, and you've tried and were unsuccessful with optimizing them, come back here and show us the code and tell us what you tried already. \$\endgroup\$ – MichaelHouse Jul 30 '12 at 16:28
  • \$\begingroup\$ I don't think we're there yet with browser mobile games being fast enough. \$\endgroup\$ – Joey Green Aug 1 '12 at 0:13

Generally slow downs are an inevitable part of using a mobile browser. There just isn't as much grunt on a phone, and mobile browsers are not yet as natively accelerated as their desktop counterparts. This is changing though (iOS 6 for example has made great leaps).

For now though, generally you need to profile and optimize your code. Try to use some isolated testing to understand what's causing the lag. Some general tips:

  1. Drawing is slow. Try to draw less things.
  2. Consider preredering complex graphics.
  3. Don't create objects. I recommend using gamecore.js object pooling.
  4. Test your effects and sprite rendering: generally rotation, alpha and scaling are going to slow you down a lot.
  5. Buffer input events and only handle them once per cycle.
  6. Buffer audio objects.
  7. Slow down your physics cycling (if you're running a simulation)
  8. Consider using a game engine like playcraft.
  9. Look at using appMobi or Ludei for native acceleration wrapping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.