first step of rotating limbs in RubeDoll

This commit is contained in:
Jeena 2015-06-28 16:26:52 -07:00
parent 7cd4cc702b
commit 2e01a093fc
5 changed files with 24 additions and 12 deletions

View file

@ -95,8 +95,6 @@ function (Parent, Layer, Settings, Nc) {
this.characterName = "Chuck";
this.lastFlipDirection = -options.direction || 1;
console.log(this.lastFlipDirection);
Parent.call(this, physicsEngine, uid, options);
}
@ -169,6 +167,8 @@ function (Parent, Layer, Settings, Nc) {
};
RubeDoll.prototype.render = function() {
Parent.prototype.render.call(this);
if(this.limbs) {
for(var name in this.limbMeshes) {
if(this.limbs[name]) {

View file

@ -421,7 +421,7 @@ function () {
"height": "9",
"type": "rubedoll",
"grabAngle": "0",
"grabAngle": "0.1",
}
};

View file

@ -16,8 +16,8 @@ function () {
BOX2D_WORLD_AABB_SIZE: 3000,
BOX2D_ALLOW_SLEEP: true,
BOX2D_GRAVITY: 26,
BOX2D_VELOCITY_ITERATIONS: 10,
BOX2D_POSITION_ITERATIONS: 6,
BOX2D_VELOCITY_ITERATIONS: 200,
BOX2D_POSITION_ITERATIONS: 100,
BOX2D_TIME_STEP: 1 / 60,
// PATHS

View file

@ -30,6 +30,7 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, RubeDollJson) {
Parent.call(this, physicsEngine, uid, options);
world.DestroyBody(this.body);
this.body = this.limbs.chest;
delete this.limbs.chest;
this.body.SetUserData(this);
@ -80,7 +81,9 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, RubeDollJson) {
};
RubeDoll.prototype.flip = function(direction) {
Parent.prototype.flip.call(this, direction);
/*
for (var i in this.joints) {
var joint = this.joints[i];
@ -102,19 +105,28 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, RubeDollJson) {
joint.SetLimits(a2, a1);
}
}
}
}*/
};
RubeDoll.prototype.reposition = function(handPosition, direction) {
var oldPosition = this.getPosition();
Parent.prototype.reposition.call(this, handPosition, direction);
var position = new Box2D.Common.Math.b2Vec2(
handPosition.x + ((6 / Settings.RATIO) * direction),
handPosition.y
);
//this.body.SetType(Box2D.Dynamics.b2Body.b2_staticBody)
var newPosition = this.getPosition();
var b2Math = Box2D.Common.Math.b2Math;
var offset = b2Math.SubtractVV(newPosition, oldPosition);
for(var limb in this.limbs) {
var position = this.limbs[limb].GetPosition().Copy();
position.Add(offset);
this.limbs[limb].SetPosition(position);
//this.limbs[limb].SetType(Box2D.Dynamics.b2Body.b2_staticBody)
}
this.body.SetPosition(position);
};
RubeDoll.prototype.setVelocities = function(options) {