mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
more fixes - not quite there yet
This commit is contained in:
parent
cca3a258ba
commit
a92afc1f4f
3 changed files with 40 additions and 11 deletions
|
|
@ -50,9 +50,7 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
|
||||||
}
|
}
|
||||||
|
|
||||||
GameController.prototype.onLevelLoaded = function() {
|
GameController.prototype.onLevelLoaded = function() {
|
||||||
console.log("onLevelLoaded updateWorld pre")
|
|
||||||
this.updateWorld();
|
this.updateWorld();
|
||||||
console.log("onLevelLoaded updateWorld post")
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameController.prototype.onUserJoined = function (user) {
|
GameController.prototype.onUserJoined = function (user) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
define([
|
define([
|
||||||
"Lib/Vendor/Box2D"
|
"Lib/Vendor/Box2D",
|
||||||
|
"Game/Config/Settings"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Box2D) {
|
function (Box2D, Settings) {
|
||||||
|
|
||||||
function Detector () {
|
function Detector () {
|
||||||
this.listener = new Box2D.Dynamics.b2ContactListener();
|
this.listener = new Box2D.Dynamics.b2ContactListener();
|
||||||
|
|
@ -12,20 +13,49 @@ function (Box2D) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Detector.prototype.getListener = function () {
|
Detector.prototype.getListener = function () {
|
||||||
return this.listener;
|
var self = this;
|
||||||
|
var listener = this.listener
|
||||||
|
|
||||||
|
if(Settings.USE_ASM) {
|
||||||
|
Box2D.customizeVTable(listener, [{
|
||||||
|
original: Box2D.b2ContactListener.prototype.BeginContact,
|
||||||
|
replacement: function(thisPtr, contactPtr) {
|
||||||
|
var contact = Box2D.wrapPointer(contactPtr, Box2D.Dynamics.Contacts.b2Contact);
|
||||||
|
self.beginContact(contact);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
original: Box2D.b2ContactListener.prototype.EndContact,
|
||||||
|
replacement: function(thisPtr, contactPtr) {
|
||||||
|
var contact = Box2D.wrapPointer(contactPtr, Box2D.Dynamics.Contacts.b2Contact);
|
||||||
|
self.endContact(contact);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
Detector.prototype.onCollisionChange = function (point, isColliding) {
|
Detector.prototype.onCollisionChange = function (point, isColliding) {
|
||||||
|
console.log(point.GetFixtureA().GetUserData().onCollisionChange)
|
||||||
var userDataA = point.GetFixtureA().GetUserData();
|
var userDataA = point.GetFixtureA().GetUserData();
|
||||||
var userDataB = point.GetFixtureB().GetUserData();
|
var userDataB = point.GetFixtureB().GetUserData();
|
||||||
|
|
||||||
if (userDataA && userDataA.onCollisionChange) {
|
//if (userDataA && userDataA.onCollisionChange) {
|
||||||
|
try {
|
||||||
userDataA.onCollisionChange(isColliding, point.GetFixtureB());
|
userDataA.onCollisionChange(isColliding, point.GetFixtureB());
|
||||||
}
|
} catch(e) {
|
||||||
|
|
||||||
if (userDataB && userDataB.onCollisionChange) {
|
|
||||||
userDataB.onCollisionChange(isColliding, point.GetFixtureA());
|
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (userDataB && userDataB.onCollisionChange) {
|
||||||
|
try{
|
||||||
|
userDataB.onCollisionChange(isColliding, point.GetFixtureA());
|
||||||
|
}catch(e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Extension **/
|
/** Extension **/
|
||||||
|
|
|
||||||
1
app/Lib/Vendor/Box2D.js
vendored
1
app/Lib/Vendor/Box2D.js
vendored
|
|
@ -14,6 +14,7 @@ function (Settings, /*Box2dWeb, */AsmBox2d) {
|
||||||
b2ControllerEdge: Module.b2ControllerEdge
|
b2ControllerEdge: Module.b2ControllerEdge
|
||||||
},
|
},
|
||||||
Contacts: {
|
Contacts: {
|
||||||
|
b2Contact: Module.b2Contact,
|
||||||
b2CircleContact: Module.b2CircleContact
|
b2CircleContact: Module.b2CircleContact
|
||||||
},
|
},
|
||||||
Joints: {
|
Joints: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue