update of client data by server

This commit is contained in:
Jeena Paradies 2012-07-13 22:49:15 +02:00
parent 2cb401bbd3
commit c8d0a48489
11 changed files with 239 additions and 120 deletions

View file

@ -18,6 +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;
this._body = world.CreateBody(bodyDef);
@ -31,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 = 'myHead-' + this.id;
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 = 'myBody-' + this.id;
this._body.CreateFixture(fixtureDef);
var legsShape = new Box2D.Collision.Shapes.b2CircleShape();
@ -47,7 +48,7 @@ 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 = 'myLegs-' + this.id;
this._legs = this._body.CreateFixture(fixtureDef);
var feetShape = new Box2D.Collision.Shapes.b2CircleShape();
@ -55,7 +56,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 = 'myFeet-' + this.id;
this._body.CreateFixture(fixtureDef);
this._body.SetActive(false);