Have b2DebugDraw and b2ContactListener been replaced in liquidfun.js?

I am trying to replace my current Box2D library (box2dweb.js) with the Google LiquidFun library .

The main difference seems to be that they put all b2 # ClassName # classes in the global scope, rather than keeping them modular (in a namespace Box2D.*

like box2dweb).

BUT also it seems that they missed a few b2 # ClassName # , two of which I used from the Box2dWeb.js version:

  • b2DebugDraw and
  • b2ContactListener

Are these deprecated / not fully implemented / forgotten?

+3


source to share


1 answer


Just define the listener as a function object, for example:

var listener =  {
    BeginContactBody: function(contact) {
      console.log(contact.GetFixtureA());
    },
    EndContactBody: function(contact) {
        console.log(contact.GetFixtureA());
    },
    PostSolve: function(contact, impulse) {

    },
    PreSolve: function(contact, oldManifold) {

    }
}
world.SetContactListener(listener);

      



looking at https://github.com/google/liquidfun/blob/master/liquidfun/Box2D/lfjs/jsBindings/Dynamics/b2World.js helped me solve this problem, so if you run into other C ++ translation issues -> javascript is a good starting point.

+1


source







All Articles