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;
|
||||
});
|
||||
|
|
@ -1,6 +1,16 @@
|
|||
define(function() {
|
||||
define([
|
||||
"Lib/Vendor/Box2D",
|
||||
"Game/Core/Collision/Detector"
|
||||
],
|
||||
|
||||
function(Box2D, Parent) {
|
||||
|
||||
function Detector() {
|
||||
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.IDENTIFIER = {
|
||||
|
|
@ -12,6 +22,27 @@ define(function() {
|
|||
PLAYER_FOOT_SENSOR: 'footsensor'
|
||||
}
|
||||
|
||||
return Detector;
|
||||
Detector.prototype.getListener = function() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
Detector.prototype.handleStand = function(point, isColliding) {
|
||||
throw "Overwrite this function";
|
||||
}
|
||||
|
||||
/** 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;
|
||||
});
|
||||
|
|
@ -1,4 +1,9 @@
|
|||
define(["Chuck/Physics/Doll", "Chuck/Settings"], function(Doll, Settings){
|
||||
define([
|
||||
"Game/Core/Physics/Doll",
|
||||
"Game/Config/Settings"
|
||||
],
|
||||
|
||||
function(Doll, Settings) {
|
||||
|
||||
function Player (physicsEngine, id, repository) {
|
||||
this.physicsEngine = physicsEngine;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
define([
|
||||
"Lib/Vendor/Box2D",
|
||||
"Game/Core/Collision/Detector"
|
||||
],
|
||||
|
||||
function(Box2D, Parent) {
|
||||
|
||||
function Detector() {
|
||||
Parent.call(this);
|
||||
}
|
||||
|
||||
Detector.prototype = Object.create(Parent);
|
||||
|
||||
Detector.prototype.handleStand = function(point, isColliding) {
|
||||
throw "Implement this function";
|
||||
}
|
||||
|
||||
return Detector;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue