Jump to content

Problems with arcade physics bodies not updating fast enough


Uhfgood
 Share

Recommended Posts

Okay so I rewrote some of my asteroid code for my game, and I can reproduce the problem I had before.  Basically I have some visibility code that sets a sprite's visible flag to false when off screen and true when back on the screen, only problem is somehow the physics bodies don't update that fast, and leaves them on the screen.

 

This was causing the player's ship to explode when you couldn't see the asteroid on the screen.  I'm not sure why it does this, but I found out by drawing out the bodies with the debug functions, and then logging collisions to the console, so you can collide with these physics bodies that remain on screen.

 

So then the question here is, how do I get it to remove the bodies (or update them to the correct position) immediately.  If I disable the physics body it stops updating and the asteroid will remain on screen.

 

In any case you can see this phenomenon here - https://dl.dropboxusercontent.com/u/32895233/sroids/index.html

 

this doesn't function as a game, but you can move around the screen.  Try not to get hit by the moving asteroids but try to touch the bodies that start accumulating on the outer edge of the screen.

 

Also you can find the source (easier in zip form) here - https://dl.dropboxusercontent.com/u/32895233/sroids.zip

 

Look at Asteroid.js (lines 179 - 185) and Game.js

 

Let me know what you think.

Link to comment
Share on other sites

Well...

Just launched it on my poor macbook pro snow leapoard with firefox... Got 2 fps, took around a minute to close the window... Glad I had not to kill the browser because I was downloading some stuff with it.

 

But I was one inch away from total freeze.

 

So yeah, debug mode probably slows things down... But to that point... Nah, something is utterly wrong, somewhere.

 

For instance I have a game with 24 bot soldiers firing at each others with machine guns on a giant tilemap, auto detecting their respective postions to know who's closer from who and when to fire or not... (which as you can imagine, takes a lot of rays and various conditions), and with debug mode activated, sure the game is slower, but not to that point.

 

Don't know exactly what is taking so much.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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