Jump to content

Box2D Painfully Slow Movement


eddieone
 Share

Recommended Posts

On certain computers, ones that wouldn't seem like they should lag, movement in my game is slow. When using `game.time.desiredFps = 30;` it also happens. My question is, how can I drop frames instead of making players swim through mud? Instead of looking ugly, it becomes unplayable. I tested this for p2, it also happens with that physics engine.

Link to comment
Share on other sites

I had a similar situation a few weeks back where a game was running really slow on some older iPads and low spec devices. I also first assumed it was the physics, but when I profiled with chrome found it was rendering graphics API shapes that was killing the processor. When I removed the Graphics display objects the game ran perfectly on those problem devices. Solution was to detect non-retina iPads and disable the graphics API features for those platforms.

Isolating stuff like you mentioned is definitely the way to go in your case.

Link to comment
Share on other sites

Thanks for the tips. I haven't experienced the lag myself, I can only simulate it. Though, we have one machine with 6 core i7 and GTX 960, it's getting lag. I'm still collecting data, I'm hoping to pinpoint why some are getting 30-40 FPS on decent machines and others get solid 60 FPS. I read some where non bitmap text could cause slow downs, that that is my first choice for isolating the problem. We have a decent amount of text.

Link to comment
Share on other sites

We had 2 people report 30 FPS. After removing most text, they reported 55-60. Could be less tabs open or something.

Still text or not, there is a massive flaw with Phaser having physics tied to frame rates. It will cut off a huge chuck of the possible audience.

There is an old issue on github that explains it very well. https://github.com/photonstorm/phaser/issues/798

Link to comment
Share on other sites

  • 4 weeks later...

I had to buy a netbook to figure it out but I found a way to get what I wanted. The following code will drop physics frames if you will and allow a player on a slow machine to almost move as fast as someone with 60 FPS. So instead of being ugly and slow, it's mostly just ugly now. I mean visually browsers will try to compensate by lowering quality.

 

// Put this in create or somewhere
game.time.advancedTiming = true;
game.physics.box2d.useElapsedTime = true;

// Put this in render
game.time.physicsElapsed = 1 / game.time.fps;

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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