mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed flip for RubeDoll
This commit is contained in:
parent
0b8d885d48
commit
f35b9f5ba9
5 changed files with 33 additions and 27 deletions
|
|
@ -197,9 +197,6 @@ function (Parent, Layer, Settings, Nc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
RubeDoll.prototype.flip = function(direction) {
|
RubeDoll.prototype.flip = function(direction) {
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Parent.prototype.flip.call(this, direction);
|
Parent.prototype.flip.call(this, direction);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -417,7 +417,7 @@ function () {
|
||||||
"image": "banana.gif",
|
"image": "banana.gif",
|
||||||
|
|
||||||
"weight": "3",
|
"weight": "3",
|
||||||
"width": "5",
|
"width": "15",
|
||||||
"height": "9",
|
"height": "9",
|
||||||
|
|
||||||
"type": "rubedoll",
|
"type": "rubedoll",
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,8 @@ function (Parent, Box2D, Options, Settings, Exception, Nc, Assert) {
|
||||||
handPosition.y
|
handPosition.y
|
||||||
);
|
);
|
||||||
this.body.SetPosition(position);
|
this.body.SetPosition(position);
|
||||||
this.flip(direction);
|
|
||||||
this.body.SetAngle((this.options.grabAngle || 0.0) * direction);
|
this.body.SetAngle((this.options.grabAngle || 0.0) * direction);
|
||||||
|
this.flip(direction);
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.prototype.getGrabPoint = function() {
|
Item.prototype.getGrabPoint = function() {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, Matrix, RubeDollJson)
|
||||||
lower: this.joints[i].GetLowerLimit(),
|
lower: this.joints[i].GetLowerLimit(),
|
||||||
upper: this.joints[i].GetUpperLimit(),
|
upper: this.joints[i].GetUpperLimit(),
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
this.joints[i].EnableLimit(false);
|
this.joints[i].EnableLimit(false);
|
||||||
|
|
||||||
if(count < 4 && this.joints[i] instanceof Box2D.Dynamics.Joints.b2RevoluteJoint) {
|
if(count < 4 && this.joints[i] instanceof Box2D.Dynamics.Joints.b2RevoluteJoint) {
|
||||||
|
|
@ -82,6 +82,7 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, Matrix, RubeDollJson)
|
||||||
body.GetWorld().DestroyJoint(this.joints[i]);
|
body.GetWorld().DestroyJoint(this.joints[i]);
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -92,39 +93,46 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, Matrix, RubeDollJson)
|
||||||
};
|
};
|
||||||
|
|
||||||
RubeDoll.prototype.flip = function(direction) {
|
RubeDoll.prototype.flip = function(direction) {
|
||||||
|
var oldFlipDirection = this.flipDirection;
|
||||||
|
|
||||||
//Parent.prototype.flip.call(this, direction);
|
Parent.prototype.flip.call(this, direction);
|
||||||
/*
|
|
||||||
|
|
||||||
for (var i in this.joints) {
|
if(oldFlipDirection != direction) {
|
||||||
var joint = this.joints[i];
|
|
||||||
var limits = this.limits[i];
|
|
||||||
|
|
||||||
if (joint instanceof Box2D.Dynamics.Joints.b2RevoluteJoint) {
|
for (var i in this.joints) {
|
||||||
|
var joint = this.joints[i];
|
||||||
|
var limits = this.limits[i];
|
||||||
|
|
||||||
if (direction > 0) {
|
if (joint instanceof Box2D.Dynamics.Joints.b2RevoluteJoint) {
|
||||||
joint.SetLimits(limits.lower, limits.upper);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var a1 = limits.lower * -1;
|
if (direction > 0) {
|
||||||
var a2 = limits.upper * -1;
|
joint.SetLimits(limits.lower, limits.upper);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (a2 > a1) {
|
var a1 = limits.lower * -1;
|
||||||
joint.SetLimits(a1, a2);
|
var a2 = limits.upper * -1;
|
||||||
} else {
|
|
||||||
joint.SetLimits(a2, a1);
|
if (a2 > a1) {
|
||||||
|
joint.SetLimits(a1, a2);
|
||||||
|
} else {
|
||||||
|
joint.SetLimits(a2, a1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// joint.SetAngle(joint.GetAngle() * -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RubeDoll.prototype.reposition = function(handPosition, direction) {
|
RubeDoll.prototype.reposition = function(handPosition, direction) {
|
||||||
console.log('repo');
|
|
||||||
|
|
||||||
var oldPosition = this.getPosition();
|
var oldPosition = this.getPosition();
|
||||||
var oldAngle = this.body.GetAngle();
|
var oldAngle = this.body.GetAngle();
|
||||||
|
var oldDirection = this.flipDirection;
|
||||||
|
|
||||||
|
// calls flip() at the end of Parent reposition()
|
||||||
Parent.prototype.reposition.call(this, handPosition, direction);
|
Parent.prototype.reposition.call(this, handPosition, direction);
|
||||||
|
|
||||||
var differenceAngle = oldAngle - this.body.GetAngle();
|
var differenceAngle = oldAngle - this.body.GetAngle();
|
||||||
|
|
||||||
//this.body.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
//this.body.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
||||||
|
|
@ -154,7 +162,8 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, Matrix, RubeDollJson)
|
||||||
limb.SetPosition(globalPoint);
|
limb.SetPosition(globalPoint);
|
||||||
|
|
||||||
// relative limb rotating by chest rotation difference
|
// relative limb rotating by chest rotation difference
|
||||||
limb.SetAngle(limb.GetAngle() - differenceAngle);
|
var d = (oldDirection == direction) ? -1 : 1;
|
||||||
|
limb.SetAngle((limb.GetAngle() - differenceAngle) * d);
|
||||||
|
|
||||||
//limb.SetType(Box2D.Dynamics.b2Body.b2_staticBody);
|
//limb.SetType(Box2D.Dynamics.b2Body.b2_staticBody);
|
||||||
//limb.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
//limb.SetLinearVelocity(new Box2D.Common.Math.b2Vec2(0, 0));
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@
|
||||||
{
|
{
|
||||||
"height":0,
|
"height":0,
|
||||||
"id":10,
|
"id":10,
|
||||||
"name":"Small Cleaver",
|
"name":"RubeDoll",
|
||||||
"properties":
|
"properties":
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue