mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed #53
This commit is contained in:
parent
695008afd8
commit
aa4535cb0c
10 changed files with 73 additions and 32 deletions
|
|
@ -345,8 +345,8 @@ function (Parent, Box2D, Settings, NotificationCenter) {
|
|||
body.SetAwake(true);
|
||||
|
||||
var vector = new Box2D.Common.Math.b2Vec2(
|
||||
x * Settings.MAX_THROW_FORCE * limbDampingFactor,
|
||||
-y * Settings.MAX_THROW_FORCE * 1.5 *limbDampingFactor // 1.5 is to throw higher then far
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -85,6 +85,21 @@ function (Parent, Box2D, Settings) {
|
|||
// FIXME: implement body flip if necessary
|
||||
};
|
||||
|
||||
Skateboard.prototype.throw = function(x, y) {
|
||||
Parent.prototype.throw.call(this, x, y);
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
Skateboard.prototype.destroy = function() {
|
||||
for (var i = 0; i < this.wheels.length; i++) {
|
||||
this.body.GetWorld().DestroyBody(this.wheels[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue