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

9 years ago by haiguyzcaniplay

Hey guys, I am having trouble detecting when an entity collides with a wall. Normally, I would use handlemovement trace but that does not work in Box2d. Any tips?

9 years ago by Joncom

In Box2D, all physical things are made up of "bodies".

Walls. Entities. Everything.

for (var edge = this.body.m_contactList;
        edge; edge = edge.next) {
    if (!edge.contact.IsTouching()) {
        continue;
    }
    console.log("Just collided with something!");
}

You might consider a body a "wall" if the body is of static type (never moves).

Here's a good Box2D reference:
http://www.box2dflash.org/docs/2.1a/reference/
Page 1 of 1
« first « previous next › last »