mirror of
https://github.com/wassname/phaser-plugin-isometric.git
synced 2026-09-09 11:28:50 +08:00
Fixed issue with grunt concat
This commit is contained in:
Vendored
+158
-157
@@ -1,4 +1,152 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
|
||||
* Copyright (c) 2014 Lewis Lane
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Lewis Lane <lew@rotates.org>
|
||||
* @copyright 2014 Lewis Lane (Rotates.org)
|
||||
* @license {@link http://opensource.org/licenses/MIT|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Isometric is a comprehensive axonometric plugin for Phaser which provides an API for handling axonometric projection of assets in 3D space to the screen.
|
||||
* The goal has been to mimic as closely as possible the existing APIs provided by Phaser for standard orthogonal 2D projection, but add a third dimension.
|
||||
* Also included is an Arcade-based 3D AABB physics engine, which again is closely equivalent in functionality and its API.
|
||||
*
|
||||
* @class Phaser.Plugin.Isometric
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Game} game The current game instance.
|
||||
*/
|
||||
Phaser.Plugin.Isometric = function (game, parent) {
|
||||
|
||||
Phaser.Plugin.call(this, game, parent);
|
||||
|
||||
// Add an instance of Isometric.Projector to game.iso if it doesn't exist already
|
||||
this.game.iso = this.game.iso || new Phaser.Plugin.Isometric.Projector(this.game, Phaser.Plugin.Isometric.CLASSIC);
|
||||
};
|
||||
|
||||
Phaser.Plugin.Isometric.prototype = Object.create(Phaser.Plugin.prototype);
|
||||
Phaser.Plugin.Isometric.prototype.constructor = Phaser.Plugin.Isometric;
|
||||
|
||||
Phaser.Plugin.Isometric.VERSION = '0.7.1';
|
||||
|
||||
// Directional consts
|
||||
Phaser.Plugin.Isometric.UP = 0;
|
||||
Phaser.Plugin.Isometric.DOWN = 1;
|
||||
Phaser.Plugin.Isometric.FORWARDX = 2;
|
||||
Phaser.Plugin.Isometric.FORWARDY = 3;
|
||||
Phaser.Plugin.Isometric.BACKWARDX = 4;
|
||||
Phaser.Plugin.Isometric.BACKWARDY = 5;
|
||||
|
||||
// Type consts
|
||||
Phaser.Plugin.Isometric.ISOSPRITE = 'isosprite';
|
||||
Phaser.Plugin.Isometric.ISOARCADE = 'isoarcade';
|
||||
|
||||
// Projection angles
|
||||
Phaser.Plugin.Isometric.CLASSIC = 0.5;
|
||||
Phaser.Plugin.Isometric.TRUE = 0.6154797093263624;
|
||||
|
||||
/**
|
||||
* Creates a new Isometric Projector object, which has helpers for projecting x, y and z coordinates into axonometric x and y equivalents.
|
||||
*
|
||||
* @class Phaser.Plugin.Isometric.Projector
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - The current game object.
|
||||
* @param {number} projectionRatio - The ratio of the axonometric projection.
|
||||
* @return {Phaser.Plugin.Isometric.Cube} This Cube object.
|
||||
*/
|
||||
Phaser.Plugin.Isometric.Projector = function (game, projectionRatio) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - The current game object.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {number} projectionRatio - The ratio of the axonometric projection.
|
||||
* @default
|
||||
*/
|
||||
this.projectionRatio = projectionRatio || Phaser.Plugin.Isometric.CLASSIC;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} anchor - The x and y offset multipliers as a ratio of the game world size.
|
||||
* @default
|
||||
*/
|
||||
this.anchor = new Phaser.Point(0.5, 0);
|
||||
};
|
||||
|
||||
Phaser.Plugin.Isometric.Projector.prototype = {
|
||||
|
||||
/**
|
||||
* Use axonometric projection to transform a 3D Point3 coordinate to a 2D Point coordinate. If given the coordinates will be set into the object, otherwise a brand new Point object will be created and returned.
|
||||
* @method Phaser.Plugin.Isometric.Projector#project
|
||||
* @param {Phaser.Plugin.Isometric.Point3} point3 - The Point3 to project from.
|
||||
* @param {Phaser.Point} out - The Point to project to.
|
||||
* @return {Phaser.Point} The transformed Point.
|
||||
*/
|
||||
project: function (point3, out) {
|
||||
if (typeof out === "undefined") {
|
||||
out = new Phaser.Point();
|
||||
}
|
||||
|
||||
out.x = point3.x - point3.y;
|
||||
out.y = ((point3.x + point3.y) * this.projectionRatio) - point3.z;
|
||||
|
||||
|
||||
out.x += this.game.world.width * this.anchor.x;
|
||||
out.y += this.game.world.height * this.anchor.y;
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Use axonometric projection to transform a 3D Point3 coordinate to a 2D Point coordinate, ignoring the z-axis. If given the coordinates will be set into the object, otherwise a brand new Point object will be created and returned.
|
||||
* @method Phaser.Plugin.Isometric.Projector#projectXY
|
||||
* @param {Phaser.Plugin.Isometric.Point3} point3 - The Point3 to project from.
|
||||
* @param {Phaser.Point} out - The Point to project to.
|
||||
* @return {Phaser.Point} The transformed Point.
|
||||
*/
|
||||
projectXY: function (point3, out) {
|
||||
if (typeof out === "undefined") {
|
||||
out = new Phaser.Point();
|
||||
}
|
||||
|
||||
out.x = point3.x - point3.y;
|
||||
out.y = ((point3.x + point3.y) * this.projectionRatio);
|
||||
|
||||
|
||||
out.x += this.game.world.width * this.anchor.x;
|
||||
out.y += this.game.world.height * this.anchor.y;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
};
|
||||
;
|
||||
/**
|
||||
* @class Phaser.Plugin.Isometric.Point3
|
||||
* @classdesc
|
||||
@@ -1086,154 +1234,6 @@ Phaser.GameObjectFactory.prototype.isoSprite = function (x, y, z, key, frame, gr
|
||||
|
||||
return group.add(new Phaser.Plugin.Isometric.IsoSprite(this.game, x, y, z, key, frame));
|
||||
|
||||
};
|
||||
;/**
|
||||
* The MIT License (MIT)
|
||||
|
||||
* Copyright (c) 2014 Lewis Lane
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Lewis Lane <lew@rotates.org>
|
||||
* @copyright 2014 Lewis Lane (Rotates.org)
|
||||
* @license {@link http://opensource.org/licenses/MIT|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Isometric is a comprehensive axonometric plugin for Phaser which provides an API for handling axonometric projection of assets in 3D space to the screen.
|
||||
* The goal has been to mimic as closely as possible the existing APIs provided by Phaser for standard orthogonal 2D projection, but add a third dimension.
|
||||
* Also included is an Arcade-based 3D AABB physics engine, which again is closely equivalent in functionality and its API.
|
||||
*
|
||||
* @class Phaser.Plugin.Isometric
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Game} game The current game instance.
|
||||
*/
|
||||
Phaser.Plugin.Isometric = function (game, parent) {
|
||||
|
||||
Phaser.Plugin.call(this, game, parent);
|
||||
|
||||
// Add an instance of Isometric.Projector to game.iso if it doesn't exist already
|
||||
this.game.iso = this.game.iso || new Phaser.Plugin.Isometric.Projector(this.game, Phaser.Plugin.Isometric.CLASSIC);
|
||||
};
|
||||
|
||||
Phaser.Plugin.Isometric.prototype = Object.create(Phaser.Plugin.prototype);
|
||||
Phaser.Plugin.Isometric.prototype.constructor = Phaser.Plugin.Isometric;
|
||||
|
||||
Phaser.Plugin.Isometric.VERSION = '0.7';
|
||||
|
||||
// Directional consts
|
||||
Phaser.Plugin.Isometric.UP = 0;
|
||||
Phaser.Plugin.Isometric.DOWN = 1;
|
||||
Phaser.Plugin.Isometric.FORWARDX = 2;
|
||||
Phaser.Plugin.Isometric.FORWARDY = 3;
|
||||
Phaser.Plugin.Isometric.BACKWARDX = 4;
|
||||
Phaser.Plugin.Isometric.BACKWARDY = 5;
|
||||
|
||||
// Type consts
|
||||
Phaser.Plugin.Isometric.ISOSPRITE = 'isosprite';
|
||||
Phaser.Plugin.Isometric.ISOARCADE = 'isoarcade';
|
||||
|
||||
// Projection angles
|
||||
Phaser.Plugin.Isometric.CLASSIC = 0.5;
|
||||
Phaser.Plugin.Isometric.TRUE = 0.6154797093263624;
|
||||
|
||||
/**
|
||||
* Creates a new Isometric Projector object, which has helpers for projecting x, y and z coordinates into axonometric x and y equivalents.
|
||||
*
|
||||
* @class Phaser.Plugin.Isometric.Projector
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - The current game object.
|
||||
* @param {number} projectionRatio - The ratio of the axonometric projection.
|
||||
* @return {Phaser.Plugin.Isometric.Cube} This Cube object.
|
||||
*/
|
||||
Phaser.Plugin.Isometric.Projector = function (game, projectionRatio) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - The current game object.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {number} projectionRatio - The ratio of the axonometric projection.
|
||||
* @default
|
||||
*/
|
||||
this.projectionRatio = projectionRatio || Phaser.Plugin.Isometric.CLASSIC;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} anchor - The x and y offset multipliers as a ratio of the game world size.
|
||||
* @default
|
||||
*/
|
||||
this.anchor = new Phaser.Point(0.5, 0);
|
||||
};
|
||||
|
||||
Phaser.Plugin.Isometric.Projector.prototype = {
|
||||
|
||||
/**
|
||||
* Use axonometric projection to transform a 3D Point3 coordinate to a 2D Point coordinate. If given the coordinates will be set into the object, otherwise a brand new Point object will be created and returned.
|
||||
* @method Phaser.Plugin.Isometric.Projector#project
|
||||
* @param {Phaser.Plugin.Isometric.Point3} point3 - The Point3 to project from.
|
||||
* @param {Phaser.Point} out - The Point to project to.
|
||||
* @return {Phaser.Point} The transformed Point.
|
||||
*/
|
||||
project: function (point3, out) {
|
||||
if (typeof out === "undefined") {
|
||||
out = new Phaser.Point();
|
||||
}
|
||||
|
||||
out.x = point3.x - point3.y;
|
||||
out.y = ((point3.x + point3.y) * this.projectionRatio) - point3.z;
|
||||
|
||||
|
||||
out.x += this.game.world.width * this.anchor.x;
|
||||
out.y += this.game.world.height * this.anchor.y;
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Use axonometric projection to transform a 3D Point3 coordinate to a 2D Point coordinate, ignoring the z-axis. If given the coordinates will be set into the object, otherwise a brand new Point object will be created and returned.
|
||||
* @method Phaser.Plugin.Isometric.Projector#projectXY
|
||||
* @param {Phaser.Plugin.Isometric.Point3} point3 - The Point3 to project from.
|
||||
* @param {Phaser.Point} out - The Point to project to.
|
||||
* @return {Phaser.Point} The transformed Point.
|
||||
*/
|
||||
projectXY: function (point3, out) {
|
||||
if (typeof out === "undefined") {
|
||||
out = new Phaser.Point();
|
||||
}
|
||||
|
||||
out.x = point3.x - point3.y;
|
||||
out.y = ((point3.x + point3.y) * this.projectionRatio);
|
||||
|
||||
|
||||
out.x += this.game.world.width * this.anchor.x;
|
||||
out.y += this.game.world.height * this.anchor.y;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
};
|
||||
;/**
|
||||
* IsoArcade Physics constructor.
|
||||
@@ -1715,13 +1715,14 @@ Phaser.Plugin.Isometric.Arcade.prototype = {
|
||||
* @param {boolean} overlapOnly - Just run an overlap or a full collision.
|
||||
*/
|
||||
collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) {
|
||||
var i, len;
|
||||
|
||||
if (group.length === 0 || !sprite.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sprite.body.skipTree || this.skipTree) {
|
||||
for (var i = 0, len = group.children.length; i < len; i++) {
|
||||
for (i = 0, len = group.children.length; i < len; i++) {
|
||||
if (group.children[i] && group.children[i].exists) {
|
||||
this.collideSpriteVsSprite(sprite, group.children[i], collideCallback, processCallback, callbackContext, overlapOnly);
|
||||
}
|
||||
@@ -1747,7 +1748,7 @@ Phaser.Plugin.Isometric.Arcade.prototype = {
|
||||
this._potentials = this.octree.retrieve(sprite);
|
||||
}
|
||||
|
||||
for (var i = 0, len = this._potentials.length; i < len; i++) {
|
||||
for (i = 0, len = this._potentials.length; i < len; i++) {
|
||||
// We have our potential suspects, are they in this group?
|
||||
if (this.separate(sprite.body, this._potentials[i], processCallback, callbackContext, overlapOnly)) {
|
||||
if (collideCallback) {
|
||||
@@ -2265,7 +2266,7 @@ Phaser.Physics.prototype.parseConfig = (function (_super) {
|
||||
this.isoArcade = new Phaser.Plugin.Isometric(this.game, this.config);
|
||||
}
|
||||
return _super.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
})(Phaser.Physics.prototype.parseConfig);
|
||||
|
||||
@@ -2277,7 +2278,7 @@ Phaser.Physics.prototype.startSystem = (function (_super) {
|
||||
this.setBoundsToWorld();
|
||||
}
|
||||
return _super.call(this, system);
|
||||
}
|
||||
};
|
||||
|
||||
})(Phaser.Physics.prototype.startSystem);
|
||||
|
||||
@@ -2288,7 +2289,7 @@ Phaser.Physics.prototype.enable = (function (_super) {
|
||||
this.isoArcade.enable(sprite);
|
||||
}
|
||||
return _super.call(this, sprite, system);
|
||||
}
|
||||
};
|
||||
|
||||
})(Phaser.Physics.prototype.enable);
|
||||
|
||||
@@ -2299,7 +2300,7 @@ Phaser.Physics.prototype.setBoundsToWorld = (function (_super) {
|
||||
this.isoArcade.setBoundsToWorld();
|
||||
}
|
||||
return _super.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
})(Phaser.Physics.prototype.setBoundsToWorld);
|
||||
|
||||
@@ -2309,7 +2310,7 @@ Phaser.Physics.prototype.destroy = (function (_super) {
|
||||
this.isoArcade = null;
|
||||
|
||||
return _super.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
})(Phaser.Physics.prototype.destroy);
|
||||
|
||||
@@ -3804,7 +3805,7 @@ Phaser.Utils.Debug.prototype.body = (function (_super) {
|
||||
}
|
||||
|
||||
return _super.call(this, sprite, color, filled);
|
||||
}
|
||||
};
|
||||
|
||||
})(Phaser.Utils.Debug.prototype.body);
|
||||
|
||||
@@ -3818,6 +3819,6 @@ Phaser.Utils.Debug.prototype.bodyInfo = (function (_super) {
|
||||
}
|
||||
|
||||
return _super.call(this, sprite, x, y, color);
|
||||
}
|
||||
};
|
||||
|
||||
})(Phaser.Utils.Debug.prototype.bodyInfo);
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
@@ -52,7 +52,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.7';
|
||||
Phaser.Plugin.Isometric.VERSION = '0.7.1';
|
||||
|
||||
// Directional consts
|
||||
Phaser.Plugin.Isometric.UP = 0;
|
||||
|
||||
Reference in New Issue
Block a user