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

@ -159,10 +159,6 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
this.setActionState("fall");
}
Doll.prototype.getPosition = function() {
return this.body.GetPosition().Copy();
};
Doll.prototype.getHeadPosition = function() {
var pos = this.body.GetPosition();
return {

View file

@ -28,6 +28,10 @@ function (Box2D, Exception) {
GameObject.prototype.getBody = function() {
return this.body;
};
GameObject.prototype.getPosition = function() {
return this.body.GetPosition().Copy();
};
return GameObject;

View file

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

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