Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by mimik

Hi
I have some box2d problem.
Sometimes i get the good old
"Uncaught TypeError: Cannot read property 'value' of undefined",

This usually happens when an box2d element get's outside of the box2d world.

The error refercse to
lib/plugins/box2d/lib.js (172)

but that's the lib file of box2d, using the box2d library that dominic made.

Have a hard time getting around this error it keeps coming up even when i have no entity outside of the box2d world.

I also notice that sometimes the kill function dosen't get called, or just to slowly.
I get the dead body hanging around on stage with the DebugDrawer.

Anyone have this problem?

Should i upgrade the version of box2d, might that help?

Tried getting around this by increasing my box2d world outside of stage.

1 decade ago by mimik

So i kinda helped myself, writing it here if someone stumble upon the same error.

So i had no idea what was going on, i expanded the minified box2d lib and found the problem.

this line 6702:
 g = new Array(this.m_bodyCount);

gets an error and then the whole thing waterfalls in to a horrible freeze.
So whats happening was that this.m_bodyCount got a negative value, and then the loops cant realy use the data to do anything.

And that can happen for example when
ig.world.DestroyBody( this.body );

get's called more then once on a entity.

I had earlier made a function to accommodate that sometimes the kill function isn't called correctly, ending up with "ghost" body's without sprites hanging around the world.

The problem was that this double call happen rarely, in my case 5-10 minutes in to the gameplay.

So i just made a count and incremented so if the destroy body actually happen then do nothing.
It can still get called 1-3 times because sometime the loop just skips the destruction part.
Page 1 of 1
« first « previous next › last »