mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed remote joint
This commit is contained in:
parent
0665348ae2
commit
b159bbb1cc
12 changed files with 143 additions and 29 deletions
|
|
@ -12,6 +12,7 @@ function (Parent, Box2D, Settings) {
|
|||
this.createFixture();
|
||||
this.body.ResetMassData();
|
||||
this.flipDirection = 1;
|
||||
this.heldByPlayers = [];
|
||||
}
|
||||
|
||||
Item.prototype = Object.create(Parent.prototype);
|
||||
|
|
@ -67,6 +68,31 @@ function (Parent, Box2D, Settings) {
|
|||
|
||||
// FIXME: implement body flip if necessary
|
||||
};
|
||||
|
||||
Item.prototype.isGrabbingAllowed = function(player) {
|
||||
return this.heldByPlayers.length == 0;
|
||||
};
|
||||
|
||||
Item.prototype.beingGrabbed = function(player) {
|
||||
if(this.isGrabbingAllowed(player)) {
|
||||
this.heldByPlayers.push(player);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Item.prototype.isReleasingAllowed = function(player) {
|
||||
return true;
|
||||
};
|
||||
|
||||
Item.prototype.beingReleased = function(player) {
|
||||
if(this.isReleasingAllowed(player)) {
|
||||
var pos = this.heldByPlayers.indexOf(player);
|
||||
if(pos >= 0) {
|
||||
this.heldByPlayers.splice(pos, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return Item;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue