added inheritance to last moved Item

This commit is contained in:
Jeena 2014-01-20 18:44:58 +01:00
parent 38b5023410
commit 2a4327c5cf
2 changed files with 33 additions and 5 deletions

View file

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