fixed item throw interface of ragdoll fixes #93

This commit is contained in:
logsol 2015-02-07 14:30:55 +01:00
parent 15e4b2825f
commit 5caa21f453
5 changed files with 19 additions and 24 deletions

View file

@ -334,21 +334,13 @@ function (Parent, Box2D, Settings, Nc) {
this.limbs.head.SetAngle((this.options.grabAngle || 0) * direction);
};
RagDoll.prototype.throw = function(x, y) {
Parent.prototype.throw.call(this, x, y);
var limbDampingFactor = 1;
RagDoll.prototype.throw = function(options, carrierVelocity) {
Parent.prototype.throw.call(this, options, carrierVelocity);
for(var name in this.limbs) {
var body = this.limbs[name];
body.SetAwake(true);
var vector = new Box2D.Common.Math.b2Vec2(
x * Settings.MAX_THROW_FORCE * limbDampingFactor / this.options.weight,
-y * Settings.MAX_THROW_FORCE * limbDampingFactor / this.options.weight
);
body.SetLinearVelocity(vector);
// body.SetAngularVelocity(Settings.MAX_THROW_ANGULAR_VELOCITY * x);
this.accelerateBody(body, options, carrierVelocity);
}
};

View file

@ -87,18 +87,13 @@ function (Parent, Box2D, Settings) {
// FIXME: implement body flip if necessary
};
Skateboard.prototype.throw = function(x, y) {
Parent.prototype.throw.call(this, x, y);
Skateboard.prototype.throw = function(options, carrierVelocity) {
Parent.prototype.throw.call(this, options, carrierVelocity);
for (var i = 0; i < this.wheels.length; i++) {
var body = this.wheels[i];
body.SetAwake(true);
var vector = new Box2D.Common.Math.b2Vec2(
x * Settings.MAX_THROW_FORCE / this.options.weight,
-y * Settings.MAX_THROW_FORCE / this.options.weight
);
body.SetLinearVelocity(vector);
this.accelerateBody(body, options, carrierVelocity);
}
};