mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
added Constants module. fixes #4
This commit is contained in:
parent
f3e186afb1
commit
3c1e7008e5
4 changed files with 29 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
|||
define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
||||
define(["Vendor/Box2D", "Chuck/Constants", "Chuck/Settings"], function(Box2D, Constants, Settings){
|
||||
|
||||
function Doll (physicsEngine, id){
|
||||
this.id = id;
|
||||
|
|
@ -18,7 +18,7 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
bodyDef.fixedRotation = true;
|
||||
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||
bodyDef.userData = 'player-' + this.id;
|
||||
bodyDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER + '-' + this.id;
|
||||
|
||||
this.body = world.CreateBody(bodyDef);
|
||||
|
||||
|
|
@ -32,14 +32,14 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -37 / Settings.RATIO));
|
||||
fixtureDef.shape = headShape;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = 'myHead-' + this.id;
|
||||
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_HEAD;
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
|
||||
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));
|
||||
fixtureDef.shape = bodyShape;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = 'myBody-' + this.id;
|
||||
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_CHEST;
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
|
||||
var legsShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
|
|
@ -48,7 +48,8 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
fixtureDef.shape = legsShape;
|
||||
fixtureDef.friction = Settings.PLAYER_FRICTION;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = 'myLegs-' + this.id;
|
||||
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_PLAYER_LEGS;
|
||||
|
||||
this.legs = this.body.CreateFixture(fixtureDef);
|
||||
|
||||
var feetShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
|
|
@ -56,7 +57,7 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
feetShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, 0 / Settings.RATIO));
|
||||
fixtureDef.shape = feetShape;
|
||||
fixtureDef.isSensor = true;
|
||||
fixtureDef.userData = 'myFeet-' + this.id;
|
||||
fixtureDef.userData = Constants.COLLISION_IDENTIFIER_FOOTSENSOR;
|
||||
this.body.CreateFixture(fixtureDef);
|
||||
|
||||
this.body.SetActive(false);
|
||||
|
|
@ -74,8 +75,7 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
Doll.prototype.setFriction = function (friction) {
|
||||
if(!friction) friction = -1;
|
||||
|
||||
if (this.legs.GetFriction() != friction)
|
||||
{
|
||||
if (this.legs.GetFriction() != friction) {
|
||||
this.legs.SetFriction(friction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue