Jump to content

Adjusting game speed for different devices using ARCADE Physics


kmp
 Share

Recommended Posts

I have a game where all the movement is run by ARCADE physics. When I run the game on my desktop it runs faster than it does on my Android phone and my Kindle Fire.

 

I would like the game to run at the same speed on all devices but, as movement is controlled by the physics engine, I cannot directly adjust sprite movement.

 

Does anyone have a good technique for this?

 

Ths only thing I can think of is to set an ideal rate (60 fps) - the speed on Firefox on my desktop - and change all the physics engine values in proportion to how the device matches this speed, like this:

 

this.game.physics.arcade.gravity.y = 200 * (idealfps / actualfps);

 

So on a desktop runing at 60fps the gravity setting would be 200 * (60/60) = 200.

 

On a slow dvice with only 30 fps then the gravity would be 200 * (60/30) = 400

 

So sprites woudl fall at the same rate as on the faster machine.

 

Is this the best way to go about it?

 

Thanks in advance

 

Ken

 

 

Link to comment
Share on other sites

Thanks to everyone for their replies. Looks like 2.2 will help with this issue. I'll look forward to it. As a matter of interest, my android phone (Nexus 4) was giving about the same frame rate as my desktop (60 fps) - only the Kindle Fire was appreciably slower (35 fps).

 

Ken

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...