sprite.body.facing snaps to fastest movement direction

This commit is contained in:
2015-11-28 13:03:41 +08:00
parent e9c72140dc
commit d3d00c1624
+18 -16
View File
@@ -540,22 +540,24 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.phase = 2;
if (this.deltaX() < 0) {
this.facing = Phaser.Plugin.Isometric.BACKWARDX;
} else if (this.deltaX() > 0) {
this.facing = Phaser.Plugin.Isometric.FORWARDX;
}
if (this.deltaY() < 0) {
this.facing = Phaser.Plugin.Isometric.BACKWARDY;
} else if (this.deltaY() > 0) {
this.facing = Phaser.Plugin.Isometric.FORWARDY;
}
if (this.deltaZ() < 0) {
this.facing = Phaser.Plugin.Isometric.DOWN;
} else if (this.deltaZ() > 0) {
this.facing = Phaser.Plugin.Isometric.UP;
if (this.deltaAbsX() >= this.deltaAbsY() && this.deltaAbsX() >= this.deltaAbsZ()){
if (this.deltaX() < 0) {
this.facing = Phaser.Plugin.Isometric.BACKWARDX;
} else if (this.deltaX() > 0) {
this.facing = Phaser.Plugin.Isometric.FORWARDX;
}
} else if (this.deltaAbsY() >= this.deltaAbsX() && this.deltaAbsY() >= this.deltaAbsZ()){
if (this.deltaY() < 0) {
this.facing = Phaser.Plugin.Isometric.BACKWARDY;
} else if (this.deltaY() > 0) {
this.facing = Phaser.Plugin.Isometric.FORWARDY;
}
} else {
if (this.deltaZ() < 0) {
this.facing = Phaser.Plugin.Isometric.DOWN;
} else if (this.deltaZ() > 0) {
this.facing = Phaser.Plugin.Isometric.UP;
}
}
if (this.moves) {