mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
added inheritance to last moved Item
This commit is contained in:
parent
38b5023410
commit
2a4327c5cf
2 changed files with 33 additions and 5 deletions
|
|
@ -54,6 +54,34 @@ function (Parent) {
|
|||
}
|
||||
};
|
||||
|
||||
Item.prototype.onCollisionChange = function(isColliding, fixture) {
|
||||
|
||||
if(isColliding) {
|
||||
var otherBody = fixture.GetBody();
|
||||
if(otherBody) {
|
||||
var otherItem = otherBody.GetUserData();
|
||||
if(otherItem instanceof Item) {
|
||||
if(!this.lastMoved && !otherItem.lastMoved) return;
|
||||
|
||||
if(this.lastMoved && otherItem.lastMoved) {
|
||||
if(this.lastMoved.timestamp > otherItem.lastMoved.timestamp) {
|
||||
this.setLastMovedBy(otherItem.lastMoved.player);
|
||||
} else {
|
||||
otherItem.setLastMovedBy(this.lastMoved.player);
|
||||
}
|
||||
} else {
|
||||
if(!this.lastMoved) {
|
||||
this.setLastMovedBy(otherItem.lastMoved.player);
|
||||
} else {
|
||||
otherItem.setLastMovedBy(this.lastMoved.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Item;
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue