mirror of
https://github.com/wassname/phaser-plugin-isometric.git
synced 2026-09-07 17:01:00 +08:00
Added Projector.unproject function to provide an equivalent 3D position from a provided 2D one. Fixed issue with body scale being incorrectly halved in dimensions.
This commit is contained in:
Vendored
+14
-3
@@ -1770,6 +1770,17 @@ Phaser.Plugin.Isometric.Projector.prototype = {
|
||||
return out;
|
||||
},
|
||||
|
||||
unproject: function (point, out, offsetY) {
|
||||
if (typeof out === "undefined") {
|
||||
out = new Phaser.Point3();
|
||||
}
|
||||
|
||||
out.y = ((2 * point.y - point.x) / 2) + (this.game.world.height * this.anchor.y) - offsetY;
|
||||
out.x = (point.x + out.y) - (this.game.world.width * this.anchor.x);
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Perform a simple depth sort on all IsoSprites in the passed group. This function is fast and will accurately sort items on a single z-plane, but breaks down when items are above/below one another in certain configurations.
|
||||
*
|
||||
@@ -2283,9 +2294,9 @@ Phaser.Plugin.Isometric.Body.prototype = {
|
||||
var asy = Math.abs(this.sprite.scale.y);
|
||||
|
||||
if (asx !== this._sx || asy !== this._sy) {
|
||||
this.widthX = (this.sprite.width * 0.5) * asx;
|
||||
this.widthY = (this.sprite.width * 0.5) * asx;
|
||||
this.height = (this.sprite.height - (this.sprite.width * 0.5)) * asy;
|
||||
this.widthX = (this.sprite.width * 0.5);
|
||||
this.widthY = (this.sprite.width * 0.5);
|
||||
this.height = (this.sprite.height - (this.sprite.width * 0.5));
|
||||
this.halfWidthX = Math.floor(this.widthX * 2);
|
||||
this.halfWidthY = Math.floor(this.widthY * 2);
|
||||
this.halfHeight = Math.floor(this.height * 2);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -53,7 +53,7 @@ Phaser.Plugin.Isometric = function (game, parent) {
|
||||
Phaser.Plugin.Isometric.prototype = Object.create(Phaser.Plugin.prototype);
|
||||
Phaser.Plugin.Isometric.prototype.constructor = Phaser.Plugin.Isometric;
|
||||
|
||||
Phaser.Plugin.Isometric.VERSION = '0.8.0';
|
||||
Phaser.Plugin.Isometric.VERSION = '0.8.1';
|
||||
|
||||
// Directional consts
|
||||
Phaser.Plugin.Isometric.UP = 0;
|
||||
|
||||
@@ -75,6 +75,25 @@ Phaser.Plugin.Isometric.Projector.prototype = {
|
||||
return out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Use reverse axonometric projection to transform a 2D Point coordinate to a 3D Point3 coordinate. If given the coordinates will be set into the object, otherwise a brand new Point3 object will be created and returned.
|
||||
* @method Phaser.Plugin.Isometric.Projector#unproject
|
||||
* @param {Phaser.Plugin.Isometric.Point} point - The Point to project from.
|
||||
* @param {Phaser.Point3} out - The Point3 to project to.
|
||||
* @param {number} offsetY - Offset of the Y axis in screen space, to account for differing z heights.
|
||||
* @return {Phaser.Point3} The transformed Point3.
|
||||
*/
|
||||
unproject: function (point, out, offsetY) {
|
||||
if (typeof out === "undefined") {
|
||||
out = new Phaser.Point3();
|
||||
}
|
||||
|
||||
out.y = ((2 * point.y - point.x) / 2) + (this.game.world.height * this.anchor.y) - offsetY;
|
||||
out.x = (point.x + out.y) - (this.game.world.width * this.anchor.x);
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Perform a simple depth sort on all IsoSprites in the passed group. This function is fast and will accurately sort items on a single z-plane, but breaks down when items are above/below one another in certain configurations.
|
||||
*
|
||||
|
||||
+3
-3
@@ -418,9 +418,9 @@ Phaser.Plugin.Isometric.Body.prototype = {
|
||||
var asy = Math.abs(this.sprite.scale.y);
|
||||
|
||||
if (asx !== this._sx || asy !== this._sy) {
|
||||
this.widthX = (this.sprite.width * 0.5) * asx;
|
||||
this.widthY = (this.sprite.width * 0.5) * asx;
|
||||
this.height = (this.sprite.height - (this.sprite.width * 0.5)) * asy;
|
||||
this.widthX = (this.sprite.width * 0.5);
|
||||
this.widthY = (this.sprite.width * 0.5);
|
||||
this.height = (this.sprite.height - (this.sprite.width * 0.5));
|
||||
this.halfWidthX = Math.floor(this.widthX * 2);
|
||||
this.halfWidthY = Math.floor(this.widthY * 2);
|
||||
this.halfHeight = Math.floor(this.height * 2);
|
||||
|
||||
Reference in New Issue
Block a user