fixed flip for RubeDoll

This commit is contained in:
Jeena 2015-08-02 17:22:41 +02:00
parent 0b8d885d48
commit f35b9f5ba9
5 changed files with 33 additions and 27 deletions

View file

@ -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);

View file

@ -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",

View file

@ -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() {

View file

@ -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,9 +93,11 @@ 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);
/*
if(oldFlipDirection != direction) {
for (var i in this.joints) { for (var i in this.joints) {
var joint = this.joints[i]; var joint = this.joints[i];
@ -115,16 +118,21 @@ function (Parent, RubeLoader, Box2D, Settings, Assert, Nc, Matrix, RubeDollJson)
} else { } else {
joint.SetLimits(a2, a1); 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));

View file

@ -215,7 +215,7 @@
{ {
"height":0, "height":0,
"id":10, "id":10,
"name":"Small Cleaver", "name":"RubeDoll",
"properties": "properties":
{ {