mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
refactored grabbing
This commit is contained in:
parent
1c4336c7f7
commit
38b5023410
7 changed files with 124 additions and 62 deletions
|
|
@ -52,23 +52,16 @@ function (Doll, Settings) {
|
|||
if(this.doll) this.doll.lookAt(x, y);
|
||||
}
|
||||
|
||||
Player.prototype.handAction = function(x, y, isHolding, item) {
|
||||
|
||||
if (isHolding) {
|
||||
// throw
|
||||
if(item.isReleasingAllowed()) {
|
||||
item.beingReleased(this);
|
||||
this.doll.throw(item, x, y);
|
||||
this.holdingItem = null;
|
||||
}
|
||||
} else {
|
||||
// take
|
||||
if(item.isGrabbingAllowed()) {
|
||||
item.beingGrabbed(this);
|
||||
this.doll.grab(item);
|
||||
this.holdingItem = item;
|
||||
}
|
||||
}
|
||||
Player.prototype.grab = function(item) {
|
||||
item.beingGrabbed(this);
|
||||
this.doll.grab(item);
|
||||
this.holdingItem = item;
|
||||
};
|
||||
|
||||
Player.prototype.throw = function(x, y, item) {
|
||||
item.beingReleased(this);
|
||||
this.doll.throw(item, x, y);
|
||||
this.holdingItem = null;
|
||||
};
|
||||
|
||||
Player.prototype.update = function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue