mirror of
https://github.com/wassname/phaser-plugin-isometric.git
synced 2026-09-09 11:28:50 +08:00
Stops sprites flying off if isoPosition is changed during update
This commit is contained in:
+6
-6
@@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user