mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Repaired Collision detecteion by adding one detector for each user - fixes #15
This commit is contained in:
parent
a1e94e1ed0
commit
f07505bc20
9 changed files with 31 additions and 29 deletions
|
|
@ -5,12 +5,14 @@ define([
|
|||
|
||||
function (Box2D, Parent) {
|
||||
|
||||
function Detector () {
|
||||
function Detector (player) { // FIXME evtl.bind(this) ?
|
||||
this.listener = new Box2D.Dynamics.b2ContactListener();
|
||||
this.listener.chuckDetector = this;
|
||||
this.listener.BeginContact = this.BeginContact;
|
||||
this.listener.PostSolve = this.PostSolve;
|
||||
this.listener.EndContact = this.EndContact;
|
||||
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
Detector.IDENTIFIER = {
|
||||
|
|
@ -27,7 +29,12 @@ function (Box2D, Parent) {
|
|||
}
|
||||
|
||||
Detector.prototype.handleStand = function (point, isColliding) {
|
||||
throw "Overwrite this function";
|
||||
|
||||
if (point.GetFixtureA().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR + '-' + this.player.id
|
||||
|| point.GetFixtureB().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR + '-' + this.player.id) {
|
||||
|
||||
this.player.onFootSensorDetection(isColliding);
|
||||
}
|
||||
}
|
||||
|
||||
/** Extension **/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue