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

1 decade ago by yikidu

I am trying to destroy a box2d body on collision and it's not working. I am able to detect the collision and destroy the impact entity by passing it's name in the userData of the body, but the box2d entity is still there invisibly. Here is the code.

init: function () {
            this.score = 0;
            var myListener = new b2.ContactListener();
            myListener.BeginContact = function (contact) {
                var body1 = contact.GetFixtureA().GetBody();
                var body2 = contact.GetFixtureB().GetBody();
                var player =[0];
                if (body2.userData != 'cactus' && body2.userData != 'player' && body1.userData == 'player') {
                    var other =;
                else if (body2.userData == 'cactus') {
                var playerSpeed = parseInt(player.body.GetLinearVelocity().y) + 20 + parseInt(;
       = playerSpeed.toFixed(0);

1 decade ago by yikidu

If anyone has been able to kill both an impact entity and it's box2d body I'd really love to know how you did it. Any help at all would be appreciated.

1 decade ago by alexandre

ig.Box2DEntity takes care of that for you. It injects a call to this.body ) before invoking this.parent.

1 decade ago by unstoppableCarl

I am also having this problem

1 decade ago by mimik

One of the problems that can accure is that the the kill function dosen't get called in the same tick. so the animation is killed but not the box2d body.

To work around this you can in your update function make an boleean calling this.kill.

// kill the player

this.gotkilled = true;




Page 1 of 1
« first « previous next › last »