This commit is contained in:
Jeena 2014-02-24 19:26:31 +01:00
parent 695008afd8
commit aa4535cb0c
10 changed files with 73 additions and 32 deletions

View file

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