Stops sprites flying off if isoPosition is changed during update

This commit is contained in:
2015-11-28 14:48:11 +08:00
parent 09a213c493
commit 4cc748b339
2 changed files with 15 additions and 6 deletions
+6 -6
View File
@@ -141,8 +141,8 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", {
set: function (value) {
this._isoPosition.x = value;
this._depthChanged = this._isoPositionChanged = this._isoBoundsChanged = true;
if (this.body && this.body.phase===1){
this.body.preUpdate();
if (this.body){
this.body._reset = true;
}
}
});
@@ -160,8 +160,8 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", {
set: function (value) {
this._isoPosition.y = value;
this._depthChanged = this._isoPositionChanged = this._isoBoundsChanged = true;
if (this.body.phase===1){
this.body.preUpdate();
if (this.body){
this.body._reset = true;
}
}
});
@@ -179,8 +179,8 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", {
set: function (value) {
this._isoPosition.z = value;
this._depthChanged = this._isoPositionChanged = this._isoBoundsChanged = true;
if (this.body.phase===1){
this.body.preUpdate();
if (this.body){
this.body._reset = true;
}
}
});
+9
View File
@@ -544,6 +544,13 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.phase = 2;
// stops sprites flying off if isoPosition is changed during update
if (this._reset) {
this.prev.x = this.position.x;
this.prev.y = this.position.y;
this.prev.z = this.position.z;
}
if (this.deltaAbsX() >= this.deltaAbsY() && this.deltaAbsX() >= this.deltaAbsZ()){
if (this.deltaX() < 0) {
this.facing = Phaser.Plugin.Isometric.BACKWARDX;
@@ -608,6 +615,8 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.prev.y = this.position.y;
this.prev.z = this.position.z;
this._reset = false;
},
/**