Open fdev31 opened 6 years ago
@kripken I'm running into the same issue as @fdev31 Any hints on how to resolve this ?
@orgicus Sorry, I don't have much time for this project anymore, and I don't remember enough about how stuff like the callbacks work, to be honest.
There are 2 js version box2d : https://github.com/flyover/box2d.js https://github.com/flyover/box2d.ts
they are active, I think you could try them.
It would be great though if someone did have the time to be a maintainer of this project, as it compiles to asm.js/wasm which is great for speed.
I added prefix "Box2D." to both JSContactListener and b2Contact, which results Box2D.JSContactListener and Box2D.b2Contact, and then it works.
@ShoutTree do you mind posting a short snippet ? I've tried something super basic like:
var cl = new Box2D.b2ContactListener()
cl.BeginContact = function(e){
console.log(e);
}
cl.EndContact = function(e){
console.log(e);
}
world.SetContactListener(cl);
but I got no console message. I might missing a trick here.
Can you please elaborate on your approach that worked ?
Thank you, George
@ShoutTree do you mind posting a short snippet ? I've tried something super basic like:
var cl = new Box2D.b2ContactListener() cl.BeginContact = function(e){ console.log(e); } cl.EndContact = function(e){ console.log(e); } world.SetContactListener(cl);
but I got no console message. I might missing a trick here.
Can you please elaborate on your approach that worked ?
Thank you, George
var world = new Box2D.b2World(new Box2D.b2Vec2(0.0, -9.8));
var listener = new Box2D.JSContactListener();
listener.EndContact = function(contactPtr) {
var contact = Box2D.wrapPointer( contactPtr, Box2D.b2Contact );
var fixtureA = contact.GetFixtureA();
....
}
listener.BeginContact = function(contactPtr){}
listener.PreSolve = function(contactPtr){}
listener.PostSolve = function(contactPtr){}
world.SetContactListener( listener );
Taking a working scene and adding the README code to it (while renaming JSContactListener to b2ContaxtListener):
The console never prints anything...