mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
first step of rotating limbs in RubeDoll
This commit is contained in:
parent
7cd4cc702b
commit
2e01a093fc
5 changed files with 24 additions and 12 deletions
|
|
@ -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]) {
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ function () {
|
|||
"height": "9",
|
||||
|
||||
"type": "rubedoll",
|
||||
"grabAngle": "0",
|
||||
"grabAngle": "0.1",
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@
|
|||
"visible":true,
|
||||
"width":0,
|
||||
"x":504.607333333333,
|
||||
"y":111.255333333333
|
||||
"y":433.26
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue