fixed define paths, exchanged Constants with Detector stuff

This commit is contained in:
Jeena Paradies 2012-07-21 22:03:11 +02:00
parent f3f9138ddc
commit 7a355e8b9a
2 changed files with 13 additions and 10 deletions

View file

@ -3,10 +3,13 @@ define(function() {
function Detector() { function Detector() {
} }
Detecotr.COLLISION_IDENTIFIER_TILE = "tile"; Detector.IDENTIFIER = {
TILE: "tile",
Detector.prototype.name = function(arguments){ PLAYER: "player",
return null; PLAYER_HEAD: 'head',
PLAYER_CHEST: 'chest',
PLAYER_LEGS: 'legs',
PLAYER_FOOT_SENSOR: 'footsensor'
} }
return Detector; return Detector;

View file

@ -1,4 +1,4 @@
define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Constants, Settings){ define(["Lib/Vendor/Box2D", "Game/Config/Settings", "Game/Core/Collision/Detector"], function(Box2D, Settings, Detector) {
function Doll (physicsEngine, id){ function Doll (physicsEngine, id){
this.id = id; this.id = id;
@ -18,7 +18,7 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
bodyDef.fixedRotation = true; bodyDef.fixedRotation = true;
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING; bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody; bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
bodyDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER + '-' + this.id; bodyDef.userData = Detector.IDENTIFIER.PLAYER + '-' + this.id;
this.body = world.CreateBody(bodyDef); this.body = world.CreateBody(bodyDef);
@ -32,14 +32,14 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -37 / Settings.RATIO)); headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -37 / Settings.RATIO));
fixtureDef.shape = headShape; fixtureDef.shape = headShape;
fixtureDef.isSensor = false; fixtureDef.isSensor = false;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_HEAD; fixtureDef.userData = Detector.IDENTIFIER.PLAYER_HEAD;
this.body.CreateFixture(fixtureDef); this.body.CreateFixture(fixtureDef);
var bodyShape = new Box2D.Collision.Shapes.b2PolygonShape(); var bodyShape = new Box2D.Collision.Shapes.b2PolygonShape();
bodyShape.SetAsOrientedBox(5 / Settings.RATIO, 16 / Settings.RATIO, new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -21 / Settings.RATIO)); bodyShape.SetAsOrientedBox(5 / Settings.RATIO, 16 / Settings.RATIO, new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -21 / Settings.RATIO));
fixtureDef.shape = bodyShape; fixtureDef.shape = bodyShape;
fixtureDef.isSensor = false; fixtureDef.isSensor = false;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_CHEST; fixtureDef.userData = Detector.IDENTIFIER.PLAYER_CHEST;
this.body.CreateFixture(fixtureDef); this.body.CreateFixture(fixtureDef);
var legsShape = new Box2D.Collision.Shapes.b2CircleShape(); var legsShape = new Box2D.Collision.Shapes.b2CircleShape();
@ -48,7 +48,7 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
fixtureDef.shape = legsShape; fixtureDef.shape = legsShape;
fixtureDef.friction = Settings.PLAYER_FRICTION; fixtureDef.friction = Settings.PLAYER_FRICTION;
fixtureDef.isSensor = false; fixtureDef.isSensor = false;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_LEGS; fixtureDef.userData = Detector.IDENTIFIER.PLAYER_LEGS;
this.legs = this.body.CreateFixture(fixtureDef); this.legs = this.body.CreateFixture(fixtureDef);
@ -57,7 +57,7 @@ define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Co
feetShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, 0 / Settings.RATIO)); feetShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, 0 / Settings.RATIO));
fixtureDef.shape = feetShape; fixtureDef.shape = feetShape;
fixtureDef.isSensor = true; fixtureDef.isSensor = true;
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_FOOTSENSOR; fixtureDef.userData = Detector.IDENTIFIER.FOOTSENSOR;
this.body.CreateFixture(fixtureDef); this.body.CreateFixture(fixtureDef);
this.body.SetActive(false); this.body.SetActive(false);