mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
moved detector to core
This commit is contained in:
parent
b4c59ae7c6
commit
22ae392ace
4 changed files with 58 additions and 27 deletions
|
|
@ -8,20 +8,10 @@ function(Box2D, Parent) {
|
|||
function Detector(me) {
|
||||
Parent.call(this);
|
||||
this.me = me;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Detector.prototype = Object.create(Parent);
|
||||
|
||||
Detector.prototype.getListener = function() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
Detector.prototype.handleStand = function(point, isColliding) {
|
||||
if (point.GetFixtureA().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR
|
||||
|| point.GetFixtureB().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR) {
|
||||
|
|
@ -30,19 +20,5 @@ function(Box2D, Parent) {
|
|||
}
|
||||
}
|
||||
|
||||
/** Extension **/
|
||||
|
||||
Detector.prototype.BeginContact = function(point) {
|
||||
this.chuckDetector.handleStand(point, true);
|
||||
}
|
||||
|
||||
Detector.prototype.PostSolve = function(point, impulse) {
|
||||
this.chuckDetector.handleStand(point, true);
|
||||
}
|
||||
|
||||
Detector.prototype.EndContact = function(point) {
|
||||
this.chuckDetector.handleStand(point, false);
|
||||
}
|
||||
|
||||
return Detector;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue