I already implemented all the objects, their velocity, etc. but the Box2D functions are within a Cocos2D inherit function. I can't find a way to create a listener class within this. Does anyone have any idea on how to do this? I can't seem to find the solution in Google. Thanks!
问问题
346 次
1 回答
0
Found it. I can just create a listener inside the function and override its own functions/attributes.
var listener = new b2ContactListener
listener.BeginContact = function (contact) {
//console.log(contact.GetFixtureA().GetBody().monster);
}
listener.EndContact = function (contact) {
//console.log(contact.GetFixtureA().GetBody().GetUserData());
}
listener.PostSolve = function (contact, impulse) {
}
listener.PreSolve = function (contact, oldManifold) {
}
Source: http://blog.sethladd.com/2011/09/box2d-collision-damage-for-javascript.html
于 2013-04-17T03:34:03.273 回答