Fixed much of the documentation. Removed Z calculation from depth - I don't think it's needed, but we'll see! Tweaked Body.reset.

This commit is contained in:
lewster32
2014-08-07 18:24:50 +01:00
parent 6bc0073df7
commit d925dcfb72
30 changed files with 2358 additions and 4787 deletions
+1 -3
View File
@@ -36,6 +36,4 @@
ehthumbs.db
Thumbs.db
node_modules/
package.json
Gruntfile.js
node_modules/
+104
View File
@@ -0,0 +1,104 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ['doc'],
concat: {
options: {
separator: ';'
},
dist: {
src: ['src/Isometric.js', 'src/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
jshint: {
src: ['src/**/*.js'],
options: {
"globals" : { "Phaser": false, "PIXI": false, "p2": false },
// Ignore Environment Globals
"browser" : true, // Standard browser globals e.g. `window`, `document`.
// Development
"devel" : true, // Allow developments statements e.g. `console.log();`.
// ECMAScript Support
"es3" : true, // Support legacy browser and javascript environments.
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict": false, // Allow global "use strict" (also enables 'strict').
// Functionality
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : false, // Require triple equals i.e. `===`.
"eqnull" : true, // Tolerate use of `== null`.
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef" : true, // Prohibit variable use before definition.
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
"loopfunc" : true, // Allow functions to be defined within loops.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, // This option warns when you define and never use your variables.
// Styling
"indent" : 4, // Specify indentation spacing
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"plusplus" : false, // Prohibit use of `++` & `--`.
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"trailing" : true // Prohibit trailing whitespaces.
}
},
uglify: {
options: {
banner: '/* Phaser Isometric <%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> by Lewis Lane <lew@rotates.org>*/\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
watch: {
scripts: {
files: ['src/**/*.js'],
tasks: ['default']
}
},
jsdoc : {
docstrap : {
src: ['src/**/*.js'],
options: {
destination: 'doc',
template : "node_modules/ink-docstrap/template",
configure : "node_modules/ink-docstrap/template/jsdoc.conf.json",
private: false
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.registerTask('default', ['concat', 'jshint', 'uglify', 'jsdoc:docstrap']);
};
+438 -416
View File
@@ -32,13 +32,14 @@
*/
/**
* @class Phaser.Plugin.Isometric
*
* @classdesc
* 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) {
@@ -52,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.7.2';
Phaser.Plugin.Isometric.VERSION = '0.7.3';
// Directional consts
Phaser.Plugin.Isometric.UP = 0;
@@ -70,9 +71,11 @@ Phaser.Plugin.Isometric.ISOARCADE = 'isoarcade';
Phaser.Plugin.Isometric.CLASSIC = 0.5;
Phaser.Plugin.Isometric.TRUE = 0.6154797093263624;
;/**
* Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.
*
* @class Phaser.Plugin.Isometric.Cube
*
* @classdesc
* Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.
*
* @constructor
* @param {number} x - The x coordinate of the bottom-back corner of the Cube.
* @param {number} y - The y coordinate of the bottom-back corner of the Cube.
@@ -658,13 +661,26 @@ Phaser.Plugin.Isometric.Cube.intersects = function (a, b) {
return !(a.frontX < b.x || a.frontY < b.y || a.x > b.frontX || a.y > b.frontY || a.z > b.top || a.top < b.z);
};
;/**
* Phaser IsoSprite constructor
* @class Phaser.Plugin.Isometric.IsoSprite
* @constructor
* @class Phaser.Plugin.Isometric.IsoSprite
*
* @classdesc
* Create a new `IsoSprite` object. IsoSprites are extended versions of standard Sprites that are suitable for axonometric positioning.
*
* IsoSprites are simply Sprites that have three new position properties (isoX, isoY and isoZ) and ask the instance of Phaser.Plugin.Isometric.Projector what their position should be in a 2D scene whenever these properties are changed.
* The IsoSprites retain their 2D position property to prevent any problems and allow you to interact with them as you would a normal Sprite. The upside of this simplicity is that things should behave predictably for those already used to Phaser.
*
* @constructor
* @extends Phaser.Sprite
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {number} x - The x coordinate (in 3D space) to position the IsoSprite at.
* @param {number} y - The y coordinate (in 3D space) to position the IsoSprite at.
* @param {number} z - The z coordinate (in 3D space) to position the IsoSprite at.
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the IsoSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
* @param {string|number} frame - If this IsoSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
*/
Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent) {
Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame) {
Phaser.Sprite.call(this, game, x, y, key, frame, parent);
Phaser.Sprite.call(this, game, x, y, key, frame);
/**
* @property {number} type - The const type of this object.
@@ -679,7 +695,7 @@ Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent)
this._isoPosition = new Phaser.Plugin.Isometric.Point3(x, y, z);
/**
* @property {number} snap - Snap this IsoSprite's position to this value; handy for keeping pixel art snapped to whole pixels.
* @property {number} snap - Snap this IsoSprite's position to the specified value; handy for keeping pixel art snapped to whole pixels.
* @default
*/
this.snap = 0;
@@ -687,18 +703,21 @@ Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent)
/**
* @property {number} _depth - Internal cached depth value.
* @readonly
* @private
*/
this._depth = 0;
/**
* @property {boolean} _depthChanged - Internal invalidation control for depth management.
* @readonly
* @private
*/
this._depthChanged = true;
/**
* @property {boolean} _isoPositionChanged - Internal invalidation control for positioning.
* @readonly
* @private
*/
this._isoPositionChanged = true;
@@ -742,7 +761,7 @@ Phaser.Plugin.Isometric.IsoSprite.prototype._project = function () {
/**
* The axonometric position of the IsoSprite on the x axis. Increasing the x coordinate will move the object down and to the right on the screen.
*
* @name Phaser.Sprite#isoX
* @name Phaser.Plugin.Isometric.IsoSprite#isoX
* @property {number} isoX - The axonometric position of the IsoSprite on the x axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", {
@@ -758,7 +777,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", {
/**
* The axonometric position of the IsoSprite on the y axis. Increasing the y coordinate will move the object down and to the left on the screen.
*
* @name Phaser.Sprite#isoY
* @name Phaser.Plugin.Isometric.IsoSprite#isoY
* @property {number} isoY - The axonometric position of the IsoSprite on the y axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", {
@@ -774,7 +793,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", {
/**
* The axonometric position of the IsoSprite on the z axis. Increasing the z coordinate will move the object directly upwards on the screen.
*
* @name Phaser.Sprite#isoZ
* @name Phaser.Plugin.Isometric.IsoSprite#isoZ
* @property {number} isoZ - The axonometric position of the IsoSprite on the z axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", {
@@ -790,7 +809,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", {
/**
* A Point3 object representing the axonometric position of the IsoSprite.
*
* @name Phaser.Sprite#isoPosition
* @name Phaser.Plugin.Isometric.IsoSprite#isoPosition
* @property {Point3} isoPosition - The axonometric position of the IsoSprite on the z axis.
* @readonly
*/
@@ -803,14 +822,14 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoPosition"
/**
* The non-unit distance of the IsoSprite from the 'front' of the scene. Used to correctly depth sort a group of IsoSprites.
*
* @name Phaser.Sprite#depth
* @name Phaser.Plugin.Isometric.IsoSprite#depth
* @property {number} depth - A calculated value used for depth sorting.
* @readonly
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "depth", {
get: function () {
if (this._depthChanged === true) {
this._depth = (this._isoPosition.x + this._isoPosition.y) + (this._isoPosition.z * 0.95);
this._depth = (this._isoPosition.x + this._isoPosition.y);
this._depthChanged = false;
}
return this._depth;
@@ -856,17 +875,404 @@ 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));
};
;/**
* Octree Constructor
*
* @class Phaser.Plugin.Isometric.Octree
* @classdesc A Octree implementation based on Phaser.QuadTree.
* Original version at https://github.com/timohausmann/quadtree-js/
*
* @constructor
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
Phaser.Plugin.Isometric.Octree = function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
/**
* @property {number} maxObjects - The maximum number of objects per node.
* @default
*/
this.maxObjects = 10;
/**
* @property {number} maxLevels - The maximum number of levels to break down to.
* @default
*/
this.maxLevels = 4;
/**
* @property {number} level - The current level.
*/
this.level = 0;
/**
* @property {object} bounds - Object that contains the octree bounds.
*/
this.bounds = {};
/**
* @property {array} objects - Array of octree children.
*/
this.objects = [];
/**
* @property {array} nodes - Array of associated child nodes.
*/
this.nodes = [];
/**
* @property {array} _empty - Internal empty array.
* @private
*/
this._empty = [];
this.reset(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level);
};
Phaser.Plugin.Isometric.Octree.prototype = {
/**
* Resets the QuadTree.
*
* @method Phaser.Plugin.Isometric.Octree#reset
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
reset: function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
this.maxObjects = maxObjects || 10;
this.maxLevels = maxLevels || 4;
this.level = level || 0;
this.bounds = {
x: Math.round(x),
y: Math.round(y),
z: Math.round(z),
widthX: widthX,
widthY: widthY,
height: height,
subWidthX: Math.floor(widthX * 0.5),
subWidthY: Math.floor(widthY * 0.5),
subHeight: Math.floor(height * 0.5),
frontX: Math.round(x) + Math.floor(widthX * 0.5),
frontY: Math.round(y) + Math.floor(widthY * 0.5),
top: Math.round(z) + Math.floor(height * 0.5)
};
this.objects.length = 0;
this.nodes.length = 0;
},
/**
* Populates this octree with the children of the given Group. In order to be added the child must exist and have a body property.
*
* @method Phaser.Plugin.Isometric.Octree#populate
* @param {Phaser.Group} group - The Group to add to the octree.
*/
populate: function (group) {
group.forEach(this.populateHandler, this, true);
},
/**
* Handler for the populate method.
*
* @method Phaser.Plugin.Isometric.Octree#populateHandler
* @param {Phaser.Plugin.Isometric.IsoSprite|object} sprite - The Sprite to check.
*/
populateHandler: function (sprite) {
if (sprite.body && sprite.exists) {
this.insert(sprite.body);
}
},
/**
* Split the node into 8 subnodes
*
* @method Phaser.Plugin.Isometric.Octree#split
*/
split: function () {
// bottom four octants
// -x-y-z
this.nodes[0] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y-z
this.nodes[1] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y-z
this.nodes[2] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y-z
this.nodes[3] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// top four octants
// -x-y+z
this.nodes[4] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y+z
this.nodes[5] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y+z
this.nodes[6] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y+z
this.nodes[7] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
},
/**
* Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
*
* @method Phaser.Plugin.Isometric.Octree#insert
* @param {Phaser.Plugin.Isometric.Body|Phaser.Plugin.Isometric.Cube|object} body - The Body object to insert into the octree. Can be any object so long as it exposes x, y, z, frontX, frontY and top properties.
*/
insert: function (body) {
var i = 0;
var index;
// if we have subnodes ...
if (this.nodes[0] !== null) {
index = this.getIndex(body);
if (index !== -1) {
this.nodes[index].insert(body);
return;
}
}
this.objects.push(body);
if (this.objects.length > this.maxObjects && this.level < this.maxLevels) {
// Split if we don't already have subnodes
if (this.nodes[0] === null) {
this.split();
}
// Add objects to subnodes
while (i < this.objects.length) {
index = this.getIndex(this.objects[i]);
if (index !== -1) {
// this is expensive - see what we can do about it
this.nodes[index].insert(this.objects.splice(i, 1)[0]);
} else {
i++;
}
}
}
},
/**
* Determine which node the object belongs to.
*
* @method Phaser.Plugin.Isometric.Octree#getIndex
* @param {Phaser.Plugin.Isometric.Cube|object} cube - The bounds in which to check.
* @return {number} index - Index of the subnode (0-7), or -1 if cube cannot completely fit within a subnode and is part of the parent node.
*/
getIndex: function (cube) {
// default is that cube doesn't fit, i.e. it straddles the internal octants
var index = -1;
if (cube.x < this.bounds.frontX && cube.frontX < this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x-y-z octant
index = 0;
} else if (cube.z > this.bounds.top) {
// cube fits into -x-y+z octant
index = 4;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x+y-z octant
index = 2;
} else if (cube.z > this.bounds.top) {
// cube fits into -x+y+z octant
index = 6;
}
}
} else if (cube.x > this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x-y-z octant
index = 1;
} else if (cube.z > this.bounds.top) {
// cube fits into +x-y+z octant
index = 5;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x+y-z octant
index = 3;
} else if (cube.z > this.bounds.top) {
// cube fits into +x+y+z octant
index = 7;
}
}
}
return index;
},
/**
* Return all objects that could collide with the given IsoSprite or Cube.
*
* @method Phaser.Plugin.Isometric.Octree#retrieve
* @param {Phaser.Plugin.Isometric.IsoSprite|Phaser.Plugin.Isometric.Cube} source - The source object to check the Octree against. Either a IsoSprite or Cube.
* @return {array} - Array with all detected objects.
*/
retrieve: function (source) {
var returnObjects, index;
if (source instanceof Phaser.Plugin.Isometric.Cube) {
returnObjects = this.objects;
index = this.getIndex(source);
} else {
if (!source.body) {
return this._empty;
}
returnObjects = this.objects;
index = this.getIndex(source.body);
}
if (this.nodes[0]) {
// If cube fits into a subnode ..
if (index !== -1) {
returnObjects = returnObjects.concat(this.nodes[index].retrieve(source));
} else {
// If cube does not fit into a subnode, check it against all subnodes (unrolled for speed)
returnObjects = returnObjects.concat(this.nodes[0].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[1].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[2].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[3].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[4].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[5].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[6].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[7].retrieve(source));
}
}
return returnObjects;
},
/**
* Clear the octree.
* @method Phaser.Plugin.Isometric.Octree#clear
*/
clear: function () {
this.objects.length = 0;
var i = this.nodes.length;
while (i--) {
this.nodes[i].clear();
this.nodes.splice(i, 1);
}
this.nodes.length = 0;
}
};
Phaser.Plugin.Isometric.Octree.prototype.constructor = Phaser.Plugin.Isometric.Octree;
/**
* Visually renders an Octree to the display.
*
* @method Phaser.Utils.Debug#octree
* @param {Phaser.Plugin.Isometric.Octree} octree - The octree to render.
* @param {string} color - The color of the lines in the quadtree.
*/
Phaser.Utils.Debug.prototype.octree = function (octree, color) {
color = color || 'rgba(255,0,0,0.3)';
this.start();
var bounds = octree.bounds,
i, points;
if (octree.nodes.length === 0) {
this.context.strokeStyle = color;
var cube = new Phaser.Plugin.Isometric.Cube(bounds.x, bounds.y, bounds.z, bounds.widthX, bounds.widthY, bounds.height);
var corners = cube.getCorners();
points = corners.slice(0, corners.length);
points = points.map(function (p) {
return this.game.iso.project(p);
});
this.context.moveTo(points[0].x, points[0].y);
this.context.beginPath();
this.context.strokeStyle = color;
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[3].x, points[3].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[0].x, points[0].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.moveTo(points[0].x, points[0].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.moveTo(points[3].x, points[3].y);
this.context.lineTo(points[7].x, points[7].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.moveTo(points[7].x, points[7].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.stroke();
this.context.closePath();
for (i = 0; i < octree.objects.length; i++) {
this.body(octree.objects[i].sprite, 'rgb(0,255,0)', false);
}
} else {
for (i = 0; i < octree.nodes.length; i++) {
this.octree(octree.nodes[i]);
}
}
this.stop();
};
;/**
* @class Phaser.Plugin.Isometric.Point3
*
* @classdesc
* The Point3 object represents a location in a three-dimensional coordinate system,
* where x and y represent the horizontal axes and z represents the vertical axis.
* The following code creates a point at (0,0,0):
* `var myPoint = new Phaser.Plugin.Isometric.Point3();`
*/
/**
*
* Creates a new Point3 object. If you pass no parameters a Point3 is created set to (0, 0, 0).
*
* @constructor
@@ -1158,9 +1564,11 @@ Phaser.Plugin.Isometric.Point3.equals = function (a, b) {
};
;/**
* 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
*
* @classdesc
* Creates a new Isometric Projector object, which has helpers for projecting x, y and z coordinates into axonometric x and y equivalents.
*
* @constructor
* @param {Phaser.Game} game - The current game object.
* @param {number} projectionRatio - The ratio of the axonometric projection.
@@ -1234,11 +1642,12 @@ Phaser.Plugin.Isometric.Projector.prototype = {
};
;/**
* @class Phaser.Plugin.Isometric.Body
*
* @classdesc
* The Physics Body is linked to a single IsoSprite. All physics operations should be performed against the body rather than
* the IsoSprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.
*
* @class Phaser.Plugin.Isometric.Body
* @classdesc IsoArcade Physics Body Constructor
*
* @constructor
* @param {Phaser.Plugin.Isometric.IsoSprite} sprite - The IsoSprite object this physics body belongs to.
*/
@@ -1947,7 +2356,7 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.position.x = x + ((this.widthX * -this.sprite.anchor.x) + this.widthX * 0.5) + this.offset.x;
this.position.y = y + ((this.widthY * this.sprite.anchor.x) - this.widthY * 0.5) + this.offset.y;
this.position.z = z - ((this.height * -this.sprite.anchor.y * 2) + this.height) + this.offset.z;
this.position.z = z - (Math.abs(this.sprite.height) * (1 - this.sprite.anchor.y)) + (Math.abs(this.sprite.width * 0.5)) + this.offset.z;
this.prev.x = this.position.x;
this.prev.y = this.position.y;
@@ -1961,6 +2370,8 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.center.setTo(this.position.x + this.halfWidthX, this.position.y + this.halfWidthY, this.position.z + this.halfHeight);
this.sprite._isoPositionChanged = true;
},
/**
@@ -2325,395 +2736,6 @@ Phaser.Plugin.Isometric.Body.renderBodyInfo = function (debug, body) {
Phaser.Plugin.Isometric.Body.prototype.constructor = Phaser.Plugin.Isometric.Body;
/**
* Octree Constructor
*
* @class Phaser.Plugin.Isometric.Octree
* @classdesc A Octree implementation. The original code was a conversion of the Java code posted to GameDevTuts.
* However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result.
* Original version at https://github.com/timohausmann/quadtree-js/
* @constructor
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
Phaser.Plugin.Isometric.Octree = function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
/**
* @property {number} maxObjects - The maximum number of objects per node.
* @default
*/
this.maxObjects = 10;
/**
* @property {number} maxLevels - The maximum number of levels to break down to.
* @default
*/
this.maxLevels = 4;
/**
* @property {number} level - The current level.
*/
this.level = 0;
/**
* @property {object} bounds - Object that contains the octree bounds.
*/
this.bounds = {};
/**
* @property {array} objects - Array of octree children.
*/
this.objects = [];
/**
* @property {array} nodes - Array of associated child nodes.
*/
this.nodes = [];
/**
* @property {array} _empty - Internal empty array.
* @private
*/
this._empty = [];
this.reset(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level);
};
Phaser.Plugin.Isometric.Octree.prototype = {
/**
* Resets the QuadTree.
*
* @method Phaser.Plugin.Isometric.Octree#reset
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
reset: function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
this.maxObjects = maxObjects || 10;
this.maxLevels = maxLevels || 4;
this.level = level || 0;
this.bounds = {
x: Math.round(x),
y: Math.round(y),
z: Math.round(z),
widthX: widthX,
widthY: widthY,
height: height,
subWidthX: Math.floor(widthX * 0.5),
subWidthY: Math.floor(widthY * 0.5),
subHeight: Math.floor(height * 0.5),
frontX: Math.round(x) + Math.floor(widthX * 0.5),
frontY: Math.round(y) + Math.floor(widthY * 0.5),
top: Math.round(z) + Math.floor(height * 0.5)
};
this.objects.length = 0;
this.nodes.length = 0;
},
/**
* Populates this octree with the children of the given Group. In order to be added the child must exist and have a body property.
*
* @method Phaser.Plugin.Isometric.Octree#populate
* @param {Phaser.Group} group - The Group to add to the octree.
*/
populate: function (group) {
group.forEach(this.populateHandler, this, true);
},
/**
* Handler for the populate method.
*
* @method Phaser.Plugin.Isometric.Octree#populateHandler
* @param {Phaser.Plugin.Isometric.IsoSprite|object} sprite - The Sprite to check.
*/
populateHandler: function (sprite) {
if (sprite.body && sprite.exists) {
this.insert(sprite.body);
}
},
/**
* Split the node into 8 subnodes
*
* @method Phaser.Plugin.Isometric.Octree#split
*/
split: function () {
// bottom four octants
// -x-y-z
this.nodes[0] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y-z
this.nodes[1] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y-z
this.nodes[2] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y-z
this.nodes[3] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// top four octants
// -x-y+z
this.nodes[4] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y+z
this.nodes[5] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y+z
this.nodes[6] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y+z
this.nodes[7] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
},
/**
* Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
*
* @method Phaser.Plugin.Isometric.Octree#insert
* @param {Phaser.Plugin.Isometric.Body|Phaser.Plugin.Isometric.Cube|object} body - The Body object to insert into the octree. Can be any object so long as it exposes x, y, z, frontX, frontY and top properties.
*/
insert: function (body) {
var i = 0;
var index;
// if we have subnodes ...
if (this.nodes[0] !== null) {
index = this.getIndex(body);
if (index !== -1) {
this.nodes[index].insert(body);
return;
}
}
this.objects.push(body);
if (this.objects.length > this.maxObjects && this.level < this.maxLevels) {
// Split if we don't already have subnodes
if (this.nodes[0] === null) {
this.split();
}
// Add objects to subnodes
while (i < this.objects.length) {
index = this.getIndex(this.objects[i]);
if (index !== -1) {
// this is expensive - see what we can do about it
this.nodes[index].insert(this.objects.splice(i, 1)[0]);
} else {
i++;
}
}
}
},
/**
* Determine which node the object belongs to.
*
* @method Phaser.Plugin.Isometric.Octree#getIndex
* @param {Phaser.Plugin.Isometric.Cube|object} cube - The bounds in which to check.
* @return {number} index - Index of the subnode (0-7), or -1 if cube cannot completely fit within a subnode and is part of the parent node.
*/
getIndex: function (cube) {
// default is that cube doesn't fit, i.e. it straddles the internal octants
var index = -1;
if (cube.x < this.bounds.frontX && cube.frontX < this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x-y-z octant
index = 0;
} else if (cube.z > this.bounds.top) {
// cube fits into -x-y+z octant
index = 4;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x+y-z octant
index = 2;
} else if (cube.z > this.bounds.top) {
// cube fits into -x+y+z octant
index = 6;
}
}
} else if (cube.x > this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x-y-z octant
index = 1;
} else if (cube.z > this.bounds.top) {
// cube fits into +x-y+z octant
index = 5;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x+y-z octant
index = 3;
} else if (cube.z > this.bounds.top) {
// cube fits into +x+y+z octant
index = 7;
}
}
}
return index;
},
/**
* Return all objects that could collide with the given IsoSprite or Cube.
*
* @method Phaser.Plugin.Isometric.Octree#retrieve
* @param {Phaser.Plugin.Isometric.IsoSprite|Phaser.Plugin.Isometric.Cube} source - The source object to check the Octree against. Either a IsoSprite or Cube.
* @return {array} - Array with all detected objects.
*/
retrieve: function (source) {
var returnObjects, index;
if (source instanceof Phaser.Plugin.Isometric.Cube) {
returnObjects = this.objects;
index = this.getIndex(source);
} else {
if (!source.body) {
return this._empty;
}
returnObjects = this.objects;
index = this.getIndex(source.body);
}
if (this.nodes[0]) {
// If cube fits into a subnode ..
if (index !== -1) {
returnObjects = returnObjects.concat(this.nodes[index].retrieve(source));
} else {
// If cube does not fit into a subnode, check it against all subnodes (unrolled for speed)
returnObjects = returnObjects.concat(this.nodes[0].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[1].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[2].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[3].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[4].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[5].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[6].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[7].retrieve(source));
}
}
return returnObjects;
},
/**
* Clear the octree.
* @method Phaser.Plugin.Isometric.Octree#clear
*/
clear: function () {
this.objects.length = 0;
var i = this.nodes.length;
while (i--) {
this.nodes[i].clear();
this.nodes.splice(i, 1);
}
this.nodes.length = 0;
}
};
Phaser.Plugin.Isometric.Octree.prototype.constructor = Phaser.Plugin.Isometric.Octree;
/**
* Visually renders an Octree to the display.
*
* @method Phaser.Utils.Debug#octree
* @param {Phaser.Plugin.Isometric.Octree} octree - The octree to render.
* @param {string} color - The color of the lines in the quadtree.
*/
Phaser.Utils.Debug.prototype.octree = function (octree, color) {
color = color || 'rgba(255,0,0,0.3)';
this.start();
var bounds = octree.bounds,
i, points;
if (octree.nodes.length === 0) {
this.context.strokeStyle = color;
var cube = new Phaser.Plugin.Isometric.Cube(bounds.x, bounds.y, bounds.z, bounds.widthX, bounds.widthY, bounds.height);
var corners = cube.getCorners();
points = corners.slice(0, corners.length);
points = points.map(function (p) {
return this.game.iso.project(p);
});
this.context.moveTo(points[0].x, points[0].y);
this.context.beginPath();
this.context.strokeStyle = color;
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[3].x, points[3].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[0].x, points[0].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.moveTo(points[0].x, points[0].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.moveTo(points[3].x, points[3].y);
this.context.lineTo(points[7].x, points[7].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.moveTo(points[7].x, points[7].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.stroke();
this.context.closePath();
for (i = 0; i < octree.objects.length; i++) {
this.body(octree.objects[i].sprite, 'rgb(0,255,0)', false);
}
} else {
for (i = 0; i < octree.nodes.length; i++) {
this.octree(octree.nodes[i]);
}
}
this.stop();
};
Phaser.Utils.Debug.prototype.body = (function (_super) {
return function (sprite, color, filled) {
File diff suppressed because one or more lines are too long
+8 -394
View File
@@ -82,11 +82,12 @@
<article>
<pre
class="sunlight-highlight-javascript linenums">/**
* @class Phaser.Plugin.Isometric.Body
*
* @classdesc
* The Physics Body is linked to a single IsoSprite. All physics operations should be performed against the body rather than
* the IsoSprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.
*
* @class Phaser.Plugin.Isometric.Body
* @classdesc IsoArcade Physics Body Constructor
*
* @constructor
* @param {Phaser.Plugin.Isometric.IsoSprite} sprite - The IsoSprite object this physics body belongs to.
*/
@@ -795,7 +796,7 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.position.x = x + ((this.widthX * -this.sprite.anchor.x) + this.widthX * 0.5) + this.offset.x;
this.position.y = y + ((this.widthY * this.sprite.anchor.x) - this.widthY * 0.5) + this.offset.y;
this.position.z = z - ((this.height * -this.sprite.anchor.y * 2) + this.height) + this.offset.z;
this.position.z = z - (Math.abs(this.sprite.height) * (1 - this.sprite.anchor.y)) + (Math.abs(this.sprite.width * 0.5)) + this.offset.z;
this.prev.x = this.position.x;
this.prev.y = this.position.y;
@@ -809,6 +810,8 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.center.setTo(this.position.x + this.halfWidthX, this.position.y + this.halfWidthY, this.position.z + this.halfHeight);
this.sprite._isoPositionChanged = true;
},
/**
@@ -1173,395 +1176,6 @@ Phaser.Plugin.Isometric.Body.renderBodyInfo = function (debug, body) {
Phaser.Plugin.Isometric.Body.prototype.constructor = Phaser.Plugin.Isometric.Body;
/**
* Octree Constructor
*
* @class Phaser.Plugin.Isometric.Octree
* @classdesc A Octree implementation. The original code was a conversion of the Java code posted to GameDevTuts.
* However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result.
* Original version at https://github.com/timohausmann/quadtree-js/
* @constructor
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
Phaser.Plugin.Isometric.Octree = function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
/**
* @property {number} maxObjects - The maximum number of objects per node.
* @default
*/
this.maxObjects = 10;
/**
* @property {number} maxLevels - The maximum number of levels to break down to.
* @default
*/
this.maxLevels = 4;
/**
* @property {number} level - The current level.
*/
this.level = 0;
/**
* @property {object} bounds - Object that contains the octree bounds.
*/
this.bounds = {};
/**
* @property {array} objects - Array of octree children.
*/
this.objects = [];
/**
* @property {array} nodes - Array of associated child nodes.
*/
this.nodes = [];
/**
* @property {array} _empty - Internal empty array.
* @private
*/
this._empty = [];
this.reset(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level);
};
Phaser.Plugin.Isometric.Octree.prototype = {
/**
* Resets the QuadTree.
*
* @method Phaser.Plugin.Isometric.Octree#reset
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
reset: function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
this.maxObjects = maxObjects || 10;
this.maxLevels = maxLevels || 4;
this.level = level || 0;
this.bounds = {
x: Math.round(x),
y: Math.round(y),
z: Math.round(z),
widthX: widthX,
widthY: widthY,
height: height,
subWidthX: Math.floor(widthX * 0.5),
subWidthY: Math.floor(widthY * 0.5),
subHeight: Math.floor(height * 0.5),
frontX: Math.round(x) + Math.floor(widthX * 0.5),
frontY: Math.round(y) + Math.floor(widthY * 0.5),
top: Math.round(z) + Math.floor(height * 0.5)
};
this.objects.length = 0;
this.nodes.length = 0;
},
/**
* Populates this octree with the children of the given Group. In order to be added the child must exist and have a body property.
*
* @method Phaser.Plugin.Isometric.Octree#populate
* @param {Phaser.Group} group - The Group to add to the octree.
*/
populate: function (group) {
group.forEach(this.populateHandler, this, true);
},
/**
* Handler for the populate method.
*
* @method Phaser.Plugin.Isometric.Octree#populateHandler
* @param {Phaser.Plugin.Isometric.IsoSprite|object} sprite - The Sprite to check.
*/
populateHandler: function (sprite) {
if (sprite.body && sprite.exists) {
this.insert(sprite.body);
}
},
/**
* Split the node into 8 subnodes
*
* @method Phaser.Plugin.Isometric.Octree#split
*/
split: function () {
// bottom four octants
// -x-y-z
this.nodes[0] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y-z
this.nodes[1] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y-z
this.nodes[2] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y-z
this.nodes[3] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// top four octants
// -x-y+z
this.nodes[4] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y+z
this.nodes[5] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y+z
this.nodes[6] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y+z
this.nodes[7] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
},
/**
* Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
*
* @method Phaser.Plugin.Isometric.Octree#insert
* @param {Phaser.Plugin.Isometric.Body|Phaser.Plugin.Isometric.Cube|object} body - The Body object to insert into the octree. Can be any object so long as it exposes x, y, z, frontX, frontY and top properties.
*/
insert: function (body) {
var i = 0;
var index;
// if we have subnodes ...
if (this.nodes[0] !== null) {
index = this.getIndex(body);
if (index !== -1) {
this.nodes[index].insert(body);
return;
}
}
this.objects.push(body);
if (this.objects.length > this.maxObjects && this.level &lt; this.maxLevels) {
// Split if we don't already have subnodes
if (this.nodes[0] === null) {
this.split();
}
// Add objects to subnodes
while (i &lt; this.objects.length) {
index = this.getIndex(this.objects[i]);
if (index !== -1) {
// this is expensive - see what we can do about it
this.nodes[index].insert(this.objects.splice(i, 1)[0]);
} else {
i++;
}
}
}
},
/**
* Determine which node the object belongs to.
*
* @method Phaser.Plugin.Isometric.Octree#getIndex
* @param {Phaser.Plugin.Isometric.Cube|object} cube - The bounds in which to check.
* @return {number} index - Index of the subnode (0-7), or -1 if cube cannot completely fit within a subnode and is part of the parent node.
*/
getIndex: function (cube) {
// default is that cube doesn't fit, i.e. it straddles the internal octants
var index = -1;
if (cube.x &lt; this.bounds.frontX && cube.frontX &lt; this.bounds.frontX) {
if (cube.y &lt; this.bounds.frontY && cube.frontY &lt; this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into -x-y-z octant
index = 0;
} else if (cube.z > this.bounds.top) {
// cube fits into -x-y+z octant
index = 4;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into -x+y-z octant
index = 2;
} else if (cube.z > this.bounds.top) {
// cube fits into -x+y+z octant
index = 6;
}
}
} else if (cube.x > this.bounds.frontX) {
if (cube.y &lt; this.bounds.frontY && cube.frontY &lt; this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into +x-y-z octant
index = 1;
} else if (cube.z > this.bounds.top) {
// cube fits into +x-y+z octant
index = 5;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into +x+y-z octant
index = 3;
} else if (cube.z > this.bounds.top) {
// cube fits into +x+y+z octant
index = 7;
}
}
}
return index;
},
/**
* Return all objects that could collide with the given IsoSprite or Cube.
*
* @method Phaser.Plugin.Isometric.Octree#retrieve
* @param {Phaser.Plugin.Isometric.IsoSprite|Phaser.Plugin.Isometric.Cube} source - The source object to check the Octree against. Either a IsoSprite or Cube.
* @return {array} - Array with all detected objects.
*/
retrieve: function (source) {
var returnObjects, index;
if (source instanceof Phaser.Plugin.Isometric.Cube) {
returnObjects = this.objects;
index = this.getIndex(source);
} else {
if (!source.body) {
return this._empty;
}
returnObjects = this.objects;
index = this.getIndex(source.body);
}
if (this.nodes[0]) {
// If cube fits into a subnode ..
if (index !== -1) {
returnObjects = returnObjects.concat(this.nodes[index].retrieve(source));
} else {
// If cube does not fit into a subnode, check it against all subnodes (unrolled for speed)
returnObjects = returnObjects.concat(this.nodes[0].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[1].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[2].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[3].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[4].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[5].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[6].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[7].retrieve(source));
}
}
return returnObjects;
},
/**
* Clear the octree.
* @method Phaser.Plugin.Isometric.Octree#clear
*/
clear: function () {
this.objects.length = 0;
var i = this.nodes.length;
while (i--) {
this.nodes[i].clear();
this.nodes.splice(i, 1);
}
this.nodes.length = 0;
}
};
Phaser.Plugin.Isometric.Octree.prototype.constructor = Phaser.Plugin.Isometric.Octree;
/**
* Visually renders an Octree to the display.
*
* @method Phaser.Utils.Debug#octree
* @param {Phaser.Plugin.Isometric.Octree} octree - The octree to render.
* @param {string} color - The color of the lines in the quadtree.
*/
Phaser.Utils.Debug.prototype.octree = function (octree, color) {
color = color || 'rgba(255,0,0,0.3)';
this.start();
var bounds = octree.bounds,
i, points;
if (octree.nodes.length === 0) {
this.context.strokeStyle = color;
var cube = new Phaser.Plugin.Isometric.Cube(bounds.x, bounds.y, bounds.z, bounds.widthX, bounds.widthY, bounds.height);
var corners = cube.getCorners();
points = corners.slice(0, corners.length);
points = points.map(function (p) {
return this.game.iso.project(p);
});
this.context.moveTo(points[0].x, points[0].y);
this.context.beginPath();
this.context.strokeStyle = color;
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[3].x, points[3].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[0].x, points[0].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.moveTo(points[0].x, points[0].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.moveTo(points[3].x, points[3].y);
this.context.lineTo(points[7].x, points[7].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.moveTo(points[7].x, points[7].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.stroke();
this.context.closePath();
for (i = 0; i &lt; octree.objects.length; i++) {
this.body(octree.objects[i].sprite, 'rgb(0,255,0)', false);
}
} else {
for (i = 0; i &lt; octree.nodes.length; i++) {
this.octree(octree.nodes[i]);
}
}
this.stop();
};
Phaser.Utils.Debug.prototype.body = (function (_super) {
return function (sprite, color, filled) {
@@ -1610,7 +1224,7 @@ Phaser.Utils.Debug.prototype.bodyInfo = (function (_super) {
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+5 -3
View File
@@ -82,9 +82,11 @@
<article>
<pre
class="sunlight-highlight-javascript linenums">/**
* Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.
*
* @class Phaser.Plugin.Isometric.Cube
*
* @classdesc
* Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.
*
* @constructor
* @param {number} x - The x coordinate of the bottom-back corner of the Cube.
* @param {number} y - The y coordinate of the bottom-back corner of the Cube.
@@ -690,7 +692,7 @@ Phaser.Plugin.Isometric.Cube.intersects = function (a, b) {
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+29 -13
View File
@@ -82,13 +82,26 @@
<article>
<pre
class="sunlight-highlight-javascript linenums">/**
* Phaser IsoSprite constructor
* @class Phaser.Plugin.Isometric.IsoSprite
* @constructor
* @class Phaser.Plugin.Isometric.IsoSprite
*
* @classdesc
* Create a new `IsoSprite` object. IsoSprites are extended versions of standard Sprites that are suitable for axonometric positioning.
*
* IsoSprites are simply Sprites that have three new position properties (isoX, isoY and isoZ) and ask the instance of Phaser.Plugin.Isometric.Projector what their position should be in a 2D scene whenever these properties are changed.
* The IsoSprites retain their 2D position property to prevent any problems and allow you to interact with them as you would a normal Sprite. The upside of this simplicity is that things should behave predictably for those already used to Phaser.
*
* @constructor
* @extends Phaser.Sprite
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {number} x - The x coordinate (in 3D space) to position the IsoSprite at.
* @param {number} y - The y coordinate (in 3D space) to position the IsoSprite at.
* @param {number} z - The z coordinate (in 3D space) to position the IsoSprite at.
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the IsoSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
* @param {string|number} frame - If this IsoSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
*/
Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent) {
Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame) {
Phaser.Sprite.call(this, game, x, y, key, frame, parent);
Phaser.Sprite.call(this, game, x, y, key, frame);
/**
* @property {number} type - The const type of this object.
@@ -103,7 +116,7 @@ Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent)
this._isoPosition = new Phaser.Plugin.Isometric.Point3(x, y, z);
/**
* @property {number} snap - Snap this IsoSprite's position to this value; handy for keeping pixel art snapped to whole pixels.
* @property {number} snap - Snap this IsoSprite's position to the specified value; handy for keeping pixel art snapped to whole pixels.
* @default
*/
this.snap = 0;
@@ -111,18 +124,21 @@ Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent)
/**
* @property {number} _depth - Internal cached depth value.
* @readonly
* @private
*/
this._depth = 0;
/**
* @property {boolean} _depthChanged - Internal invalidation control for depth management.
* @readonly
* @private
*/
this._depthChanged = true;
/**
* @property {boolean} _isoPositionChanged - Internal invalidation control for positioning.
* @readonly
* @private
*/
this._isoPositionChanged = true;
@@ -166,7 +182,7 @@ Phaser.Plugin.Isometric.IsoSprite.prototype._project = function () {
/**
* The axonometric position of the IsoSprite on the x axis. Increasing the x coordinate will move the object down and to the right on the screen.
*
* @name Phaser.Sprite#isoX
* @name Phaser.Plugin.Isometric.IsoSprite#isoX
* @property {number} isoX - The axonometric position of the IsoSprite on the x axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", {
@@ -182,7 +198,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", {
/**
* The axonometric position of the IsoSprite on the y axis. Increasing the y coordinate will move the object down and to the left on the screen.
*
* @name Phaser.Sprite#isoY
* @name Phaser.Plugin.Isometric.IsoSprite#isoY
* @property {number} isoY - The axonometric position of the IsoSprite on the y axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", {
@@ -198,7 +214,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", {
/**
* The axonometric position of the IsoSprite on the z axis. Increasing the z coordinate will move the object directly upwards on the screen.
*
* @name Phaser.Sprite#isoZ
* @name Phaser.Plugin.Isometric.IsoSprite#isoZ
* @property {number} isoZ - The axonometric position of the IsoSprite on the z axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", {
@@ -214,7 +230,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", {
/**
* A Point3 object representing the axonometric position of the IsoSprite.
*
* @name Phaser.Sprite#isoPosition
* @name Phaser.Plugin.Isometric.IsoSprite#isoPosition
* @property {Point3} isoPosition - The axonometric position of the IsoSprite on the z axis.
* @readonly
*/
@@ -227,14 +243,14 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoPosition"
/**
* The non-unit distance of the IsoSprite from the 'front' of the scene. Used to correctly depth sort a group of IsoSprites.
*
* @name Phaser.Sprite#depth
* @name Phaser.Plugin.Isometric.IsoSprite#depth
* @property {number} depth - A calculated value used for depth sorting.
* @readonly
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "depth", {
get: function () {
if (this._depthChanged === true) {
this._depth = (this._isoPosition.x + this._isoPosition.y) + (this._isoPosition.z * 0.95);
this._depth = (this._isoPosition.x + this._isoPosition.y);
this._depthChanged = false;
}
return this._depth;
@@ -302,7 +318,7 @@ Phaser.GameObjectFactory.prototype.isoSprite = function (x, y, z, key, frame, gr
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+6 -5
View File
@@ -115,13 +115,14 @@
*/
/**
* @class Phaser.Plugin.Isometric
*
* @classdesc
* 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) {
@@ -135,7 +136,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.2';
Phaser.Plugin.Isometric.VERSION = '0.7.3';
// Directional consts
Phaser.Plugin.Isometric.UP = 0;
@@ -173,7 +174,7 @@ Phaser.Plugin.Isometric.TRUE = 0.6154797093263624;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+573
View File
@@ -0,0 +1,573 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Phaser Isometric Source: Octree.js</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<a class="brand" href="index.html">Phaser Isometric</a>
<ul class="nav">
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="Phaser.Plugin.Isometric.html">Phaser.Plugin.Isometric</a>
</li>
<li>
<a href="Phaser.Plugin.Isometric.Arcade.html">Phaser.Plugin.Isometric.Arcade</a>
</li>
<li>
<a href="Phaser.Plugin.Isometric.Body.html">Phaser.Plugin.Isometric.Body</a>
</li>
<li>
<a href="Phaser.Plugin.Isometric.Cube.html">Phaser.Plugin.Isometric.Cube</a>
</li>
<li>
<a href="Phaser.Plugin.Isometric.IsoSprite.html">Phaser.Plugin.Isometric.IsoSprite</a>
</li>
<li>
<a href="Phaser.Plugin.Isometric.Octree.html">Phaser.Plugin.Isometric.Octree</a>
</li>
<li>
<a href="Phaser.Plugin.Isometric.Point3.html">Phaser.Plugin.Isometric.Point3</a>
</li>
<li>
<a href="Phaser.Plugin.Isometric.Projector.html">Phaser.Plugin.Isometric.Projector</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div id="main">
<h1 class="page-title">Source: Octree.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">/**
* Octree Constructor
*
* @class Phaser.Plugin.Isometric.Octree
* @classdesc A Octree implementation based on Phaser.QuadTree.
* Original version at https://github.com/timohausmann/quadtree-js/
*
* @constructor
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
Phaser.Plugin.Isometric.Octree = function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
/**
* @property {number} maxObjects - The maximum number of objects per node.
* @default
*/
this.maxObjects = 10;
/**
* @property {number} maxLevels - The maximum number of levels to break down to.
* @default
*/
this.maxLevels = 4;
/**
* @property {number} level - The current level.
*/
this.level = 0;
/**
* @property {object} bounds - Object that contains the octree bounds.
*/
this.bounds = {};
/**
* @property {array} objects - Array of octree children.
*/
this.objects = [];
/**
* @property {array} nodes - Array of associated child nodes.
*/
this.nodes = [];
/**
* @property {array} _empty - Internal empty array.
* @private
*/
this._empty = [];
this.reset(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level);
};
Phaser.Plugin.Isometric.Octree.prototype = {
/**
* Resets the QuadTree.
*
* @method Phaser.Plugin.Isometric.Octree#reset
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
reset: function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
this.maxObjects = maxObjects || 10;
this.maxLevels = maxLevels || 4;
this.level = level || 0;
this.bounds = {
x: Math.round(x),
y: Math.round(y),
z: Math.round(z),
widthX: widthX,
widthY: widthY,
height: height,
subWidthX: Math.floor(widthX * 0.5),
subWidthY: Math.floor(widthY * 0.5),
subHeight: Math.floor(height * 0.5),
frontX: Math.round(x) + Math.floor(widthX * 0.5),
frontY: Math.round(y) + Math.floor(widthY * 0.5),
top: Math.round(z) + Math.floor(height * 0.5)
};
this.objects.length = 0;
this.nodes.length = 0;
},
/**
* Populates this octree with the children of the given Group. In order to be added the child must exist and have a body property.
*
* @method Phaser.Plugin.Isometric.Octree#populate
* @param {Phaser.Group} group - The Group to add to the octree.
*/
populate: function (group) {
group.forEach(this.populateHandler, this, true);
},
/**
* Handler for the populate method.
*
* @method Phaser.Plugin.Isometric.Octree#populateHandler
* @param {Phaser.Plugin.Isometric.IsoSprite|object} sprite - The Sprite to check.
*/
populateHandler: function (sprite) {
if (sprite.body && sprite.exists) {
this.insert(sprite.body);
}
},
/**
* Split the node into 8 subnodes
*
* @method Phaser.Plugin.Isometric.Octree#split
*/
split: function () {
// bottom four octants
// -x-y-z
this.nodes[0] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y-z
this.nodes[1] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y-z
this.nodes[2] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y-z
this.nodes[3] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// top four octants
// -x-y+z
this.nodes[4] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y+z
this.nodes[5] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y+z
this.nodes[6] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y+z
this.nodes[7] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
},
/**
* Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
*
* @method Phaser.Plugin.Isometric.Octree#insert
* @param {Phaser.Plugin.Isometric.Body|Phaser.Plugin.Isometric.Cube|object} body - The Body object to insert into the octree. Can be any object so long as it exposes x, y, z, frontX, frontY and top properties.
*/
insert: function (body) {
var i = 0;
var index;
// if we have subnodes ...
if (this.nodes[0] !== null) {
index = this.getIndex(body);
if (index !== -1) {
this.nodes[index].insert(body);
return;
}
}
this.objects.push(body);
if (this.objects.length > this.maxObjects && this.level &lt; this.maxLevels) {
// Split if we don't already have subnodes
if (this.nodes[0] === null) {
this.split();
}
// Add objects to subnodes
while (i &lt; this.objects.length) {
index = this.getIndex(this.objects[i]);
if (index !== -1) {
// this is expensive - see what we can do about it
this.nodes[index].insert(this.objects.splice(i, 1)[0]);
} else {
i++;
}
}
}
},
/**
* Determine which node the object belongs to.
*
* @method Phaser.Plugin.Isometric.Octree#getIndex
* @param {Phaser.Plugin.Isometric.Cube|object} cube - The bounds in which to check.
* @return {number} index - Index of the subnode (0-7), or -1 if cube cannot completely fit within a subnode and is part of the parent node.
*/
getIndex: function (cube) {
// default is that cube doesn't fit, i.e. it straddles the internal octants
var index = -1;
if (cube.x &lt; this.bounds.frontX && cube.frontX &lt; this.bounds.frontX) {
if (cube.y &lt; this.bounds.frontY && cube.frontY &lt; this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into -x-y-z octant
index = 0;
} else if (cube.z > this.bounds.top) {
// cube fits into -x-y+z octant
index = 4;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into -x+y-z octant
index = 2;
} else if (cube.z > this.bounds.top) {
// cube fits into -x+y+z octant
index = 6;
}
}
} else if (cube.x > this.bounds.frontX) {
if (cube.y &lt; this.bounds.frontY && cube.frontY &lt; this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into +x-y-z octant
index = 1;
} else if (cube.z > this.bounds.top) {
// cube fits into +x-y+z octant
index = 5;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z &lt; this.bounds.top && cube.top &lt; this.bounds.top) {
// cube fits into +x+y-z octant
index = 3;
} else if (cube.z > this.bounds.top) {
// cube fits into +x+y+z octant
index = 7;
}
}
}
return index;
},
/**
* Return all objects that could collide with the given IsoSprite or Cube.
*
* @method Phaser.Plugin.Isometric.Octree#retrieve
* @param {Phaser.Plugin.Isometric.IsoSprite|Phaser.Plugin.Isometric.Cube} source - The source object to check the Octree against. Either a IsoSprite or Cube.
* @return {array} - Array with all detected objects.
*/
retrieve: function (source) {
var returnObjects, index;
if (source instanceof Phaser.Plugin.Isometric.Cube) {
returnObjects = this.objects;
index = this.getIndex(source);
} else {
if (!source.body) {
return this._empty;
}
returnObjects = this.objects;
index = this.getIndex(source.body);
}
if (this.nodes[0]) {
// If cube fits into a subnode ..
if (index !== -1) {
returnObjects = returnObjects.concat(this.nodes[index].retrieve(source));
} else {
// If cube does not fit into a subnode, check it against all subnodes (unrolled for speed)
returnObjects = returnObjects.concat(this.nodes[0].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[1].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[2].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[3].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[4].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[5].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[6].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[7].retrieve(source));
}
}
return returnObjects;
},
/**
* Clear the octree.
* @method Phaser.Plugin.Isometric.Octree#clear
*/
clear: function () {
this.objects.length = 0;
var i = this.nodes.length;
while (i--) {
this.nodes[i].clear();
this.nodes.splice(i, 1);
}
this.nodes.length = 0;
}
};
Phaser.Plugin.Isometric.Octree.prototype.constructor = Phaser.Plugin.Isometric.Octree;
/**
* Visually renders an Octree to the display.
*
* @method Phaser.Utils.Debug#octree
* @param {Phaser.Plugin.Isometric.Octree} octree - The octree to render.
* @param {string} color - The color of the lines in the quadtree.
*/
Phaser.Utils.Debug.prototype.octree = function (octree, color) {
color = color || 'rgba(255,0,0,0.3)';
this.start();
var bounds = octree.bounds,
i, points;
if (octree.nodes.length === 0) {
this.context.strokeStyle = color;
var cube = new Phaser.Plugin.Isometric.Cube(bounds.x, bounds.y, bounds.z, bounds.widthX, bounds.widthY, bounds.height);
var corners = cube.getCorners();
points = corners.slice(0, corners.length);
points = points.map(function (p) {
return this.game.iso.project(p);
});
this.context.moveTo(points[0].x, points[0].y);
this.context.beginPath();
this.context.strokeStyle = color;
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[3].x, points[3].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[0].x, points[0].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.moveTo(points[0].x, points[0].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.moveTo(points[3].x, points[3].y);
this.context.lineTo(points[7].x, points[7].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.moveTo(points[7].x, points[7].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.stroke();
this.context.closePath();
for (i = 0; i &lt; octree.objects.length; i++) {
this.body(octree.objects[i].sprite, 'rgb(0,255,0)', false);
}
} else {
for (i = 0; i &lt; octree.nodes.length; i++) {
this.octree(octree.nodes[i]);
}
}
this.stop();
};
</pre>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
Copyright © 2014 Lewis Lane - Rotates.org
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
<br clear="both">
</div>
</div>
<!--<script src="scripts/sunlight.js"></script>-->
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/bootstrap-dropdown.js"></script>
<script src="scripts/toc.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : "100px"
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
// $( ".tutorial-section pre, .readme-section pre" ).addClass( "sunlight-highlight-javascript" ).addClass( "linenums" );
$( ".tutorial-section pre, .readme-section pre" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
lang = "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
</body>
</html>
+1 -1
View File
@@ -4091,7 +4091,7 @@ NOTE: This function is not recursive, and will not test against children of obje
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+85 -89
View File
@@ -86,7 +86,8 @@
Body
</h2>
<div class="class-description"><p>IsoArcade Physics Body Constructor</p></div>
<div class="class-description"><p>The Physics Body is linked to a single IsoSprite. All physics operations should be performed against the body rather than
the IsoSprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.</p></div>
</header>
@@ -104,11 +105,6 @@
<dd>
<div class="description">
<p>The Physics Body is linked to a single IsoSprite. All physics operations should be performed against the body rather than
the IsoSprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.</p>
</div>
@@ -193,7 +189,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-10">line 10</a>
<a href="Body.js.html#sunlight-1-line-11">line 11</a>
</li>
</ul>
</dd>
@@ -328,7 +324,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-139">line 139</a>
<a href="Body.js.html#sunlight-1-line-140">line 140</a>
</li>
</ul>
</dd>
@@ -444,7 +440,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-150">line 150</a>
<a href="Body.js.html#sunlight-1-line-151">line 151</a>
</li>
</ul>
</dd>
@@ -560,7 +556,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-54">line 54</a>
<a href="Body.js.html#sunlight-1-line-55">line 55</a>
</li>
</ul>
</dd>
@@ -669,7 +665,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-202">line 202</a>
<a href="Body.js.html#sunlight-1-line-203">line 203</a>
</li>
</ul>
</dd>
@@ -785,7 +781,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-178">line 178</a>
<a href="Body.js.html#sunlight-1-line-179">line 179</a>
</li>
</ul>
</dd>
@@ -901,7 +897,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-184">line 184</a>
<a href="Body.js.html#sunlight-1-line-185">line 185</a>
</li>
</ul>
</dd>
@@ -1017,7 +1013,7 @@ the IsoSprite itself. For example you can set the velocity, acceleration, bounce
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-172">line 172</a>
<a href="Body.js.html#sunlight-1-line-173">line 173</a>
</li>
</ul>
</dd>
@@ -1131,7 +1127,7 @@ For example if blocked.up is true then the Body cannot move up.</p>
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-335">line 335</a>
<a href="Body.js.html#sunlight-1-line-336">line 336</a>
</li>
</ul>
</dd>
@@ -1240,7 +1236,7 @@ For example if blocked.up is true then the Body cannot move up.</p>
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-928">line 928</a>
<a href="Body.js.html#sunlight-1-line-931">line 931</a>
</li>
</ul>
</dd>
@@ -1349,7 +1345,7 @@ For example if blocked.up is true then the Body cannot move up.</p>
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-160">line 160</a>
<a href="Body.js.html#sunlight-1-line-161">line 161</a>
</li>
</ul>
</dd>
@@ -1458,7 +1454,7 @@ For example if blocked.up is true then the Body cannot move up.</p>
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-118">line 118</a>
<a href="Body.js.html#sunlight-1-line-119">line 119</a>
</li>
</ul>
</dd>
@@ -1572,7 +1568,7 @@ For example checkCollision.up = false means it won't collide when the collision
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-290">line 290</a>
<a href="Body.js.html#sunlight-1-line-291">line 291</a>
</li>
</ul>
</dd>
@@ -1685,7 +1681,7 @@ For example checkCollision.up = false means it won't collide when the collision
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-283">line 283</a>
<a href="Body.js.html#sunlight-1-line-284">line 284</a>
</li>
</ul>
</dd>
@@ -1806,7 +1802,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-237">line 237</a>
<a href="Body.js.html#sunlight-1-line-238">line 238</a>
</li>
</ul>
</dd>
@@ -1927,7 +1923,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-245">line 245</a>
<a href="Body.js.html#sunlight-1-line-246">line 246</a>
</li>
</ul>
</dd>
@@ -2048,7 +2044,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-253">line 253</a>
<a href="Body.js.html#sunlight-1-line-254">line 254</a>
</li>
</ul>
</dd>
@@ -2157,7 +2153,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-134">line 134</a>
<a href="Body.js.html#sunlight-1-line-135">line 135</a>
</li>
</ul>
</dd>
@@ -2266,7 +2262,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-144">line 144</a>
<a href="Body.js.html#sunlight-1-line-145">line 145</a>
</li>
</ul>
</dd>
@@ -2379,7 +2375,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-277">line 277</a>
<a href="Body.js.html#sunlight-1-line-278">line 278</a>
</li>
</ul>
</dd>
@@ -2495,7 +2491,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-31">line 31</a>
<a href="Body.js.html#sunlight-1-line-32">line 32</a>
</li>
</ul>
</dd>
@@ -2604,7 +2600,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-214">line 214</a>
<a href="Body.js.html#sunlight-1-line-215">line 215</a>
</li>
</ul>
</dd>
@@ -2713,7 +2709,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-889">line 889</a>
<a href="Body.js.html#sunlight-1-line-892">line 892</a>
</li>
</ul>
</dd>
@@ -2822,7 +2818,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-915">line 915</a>
<a href="Body.js.html#sunlight-1-line-918">line 918</a>
</li>
</ul>
</dd>
@@ -2931,7 +2927,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-20">line 20</a>
<a href="Body.js.html#sunlight-1-line-21">line 21</a>
</li>
</ul>
</dd>
@@ -3040,7 +3036,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-155">line 155</a>
<a href="Body.js.html#sunlight-1-line-156">line 156</a>
</li>
</ul>
</dd>
@@ -3149,7 +3145,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-113">line 113</a>
<a href="Body.js.html#sunlight-1-line-114">line 114</a>
</li>
</ul>
</dd>
@@ -3258,7 +3254,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-103">line 103</a>
<a href="Body.js.html#sunlight-1-line-104">line 104</a>
</li>
</ul>
</dd>
@@ -3367,7 +3363,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-108">line 108</a>
<a href="Body.js.html#sunlight-1-line-109">line 109</a>
</li>
</ul>
</dd>
@@ -3476,7 +3472,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-98">line 98</a>
<a href="Body.js.html#sunlight-1-line-99">line 99</a>
</li>
</ul>
</dd>
@@ -3592,7 +3588,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-220">line 220</a>
<a href="Body.js.html#sunlight-1-line-221">line 221</a>
</li>
</ul>
</dd>
@@ -3708,7 +3704,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-196">line 196</a>
<a href="Body.js.html#sunlight-1-line-197">line 197</a>
</li>
</ul>
</dd>
@@ -3824,7 +3820,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-190">line 190</a>
<a href="Body.js.html#sunlight-1-line-191">line 191</a>
</li>
</ul>
</dd>
@@ -3933,7 +3929,7 @@ Used in combination with your own collision processHandler you can create whatev
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-166">line 166</a>
<a href="Body.js.html#sunlight-1-line-167">line 167</a>
</li>
</ul>
</dd>
@@ -4055,7 +4051,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-229">line 229</a>
<a href="Body.js.html#sunlight-1-line-230">line 230</a>
</li>
</ul>
</dd>
@@ -4164,7 +4160,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-129">line 129</a>
<a href="Body.js.html#sunlight-1-line-130">line 130</a>
</li>
</ul>
</dd>
@@ -4273,7 +4269,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-36">line 36</a>
<a href="Body.js.html#sunlight-1-line-37">line 37</a>
</li>
</ul>
</dd>
@@ -4386,7 +4382,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-259">line 259</a>
<a href="Body.js.html#sunlight-1-line-260">line 260</a>
</li>
</ul>
</dd>
@@ -4499,7 +4495,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-265">line 265</a>
<a href="Body.js.html#sunlight-1-line-266">line 266</a>
</li>
</ul>
</dd>
@@ -4612,7 +4608,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-271">line 271</a>
<a href="Body.js.html#sunlight-1-line-272">line 272</a>
</li>
</ul>
</dd>
@@ -4721,7 +4717,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-347">line 347</a>
<a href="Body.js.html#sunlight-1-line-348">line 348</a>
</li>
</ul>
</dd>
@@ -4830,7 +4826,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-42">line 42</a>
<a href="Body.js.html#sunlight-1-line-43">line 43</a>
</li>
</ul>
</dd>
@@ -4939,7 +4935,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-65">line 65</a>
<a href="Body.js.html#sunlight-1-line-66">line 66</a>
</li>
</ul>
</dd>
@@ -5048,7 +5044,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-48">line 48</a>
<a href="Body.js.html#sunlight-1-line-49">line 49</a>
</li>
</ul>
</dd>
@@ -5157,7 +5153,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-902">line 902</a>
<a href="Body.js.html#sunlight-1-line-905">line 905</a>
</li>
</ul>
</dd>
@@ -5266,7 +5262,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-59">line 59</a>
<a href="Body.js.html#sunlight-1-line-60">line 60</a>
</li>
</ul>
</dd>
@@ -5375,7 +5371,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-352">line 352</a>
<a href="Body.js.html#sunlight-1-line-353">line 353</a>
</li>
</ul>
</dd>
@@ -5484,7 +5480,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-83">line 83</a>
<a href="Body.js.html#sunlight-1-line-84">line 84</a>
</li>
</ul>
</dd>
@@ -5593,7 +5589,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-71">line 71</a>
<a href="Body.js.html#sunlight-1-line-72">line 72</a>
</li>
</ul>
</dd>
@@ -5702,7 +5698,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-77">line 77</a>
<a href="Body.js.html#sunlight-1-line-78">line 78</a>
</li>
</ul>
</dd>
@@ -5811,7 +5807,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-208">line 208</a>
<a href="Body.js.html#sunlight-1-line-209">line 209</a>
</li>
</ul>
</dd>
@@ -5920,7 +5916,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-15">line 15</a>
<a href="Body.js.html#sunlight-1-line-16">line 16</a>
</li>
</ul>
</dd>
@@ -6029,7 +6025,7 @@ If you want the physics system to move the body around, then set moves to true.<
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-876">line 876</a>
<a href="Body.js.html#sunlight-1-line-879">line 879</a>
</li>
</ul>
</dd>
@@ -6143,7 +6139,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-306">line 306</a>
<a href="Body.js.html#sunlight-1-line-307">line 307</a>
</li>
</ul>
</dd>
@@ -6252,7 +6248,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-25">line 25</a>
<a href="Body.js.html#sunlight-1-line-26">line 26</a>
</li>
</ul>
</dd>
@@ -6361,7 +6357,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-123">line 123</a>
<a href="Body.js.html#sunlight-1-line-124">line 124</a>
</li>
</ul>
</dd>
@@ -6474,7 +6470,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-320">line 320</a>
<a href="Body.js.html#sunlight-1-line-321">line 321</a>
</li>
</ul>
</dd>
@@ -6583,7 +6579,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-88">line 88</a>
<a href="Body.js.html#sunlight-1-line-89">line 89</a>
</li>
</ul>
</dd>
@@ -6692,7 +6688,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-93">line 93</a>
<a href="Body.js.html#sunlight-1-line-94">line 94</a>
</li>
</ul>
</dd>
@@ -6801,7 +6797,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-942">line 942</a>
<a href="Body.js.html#sunlight-1-line-945">line 945</a>
</li>
</ul>
</dd>
@@ -6910,7 +6906,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-959">line 959</a>
<a href="Body.js.html#sunlight-1-line-962">line 962</a>
</li>
</ul>
</dd>
@@ -7019,7 +7015,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-977">line 977</a>
<a href="Body.js.html#sunlight-1-line-980">line 980</a>
</li>
</ul>
</dd>
@@ -7091,7 +7087,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-617">line 617</a>
<a href="Body.js.html#sunlight-1-line-618">line 618</a>
</li>
</ul>
</dd>
@@ -7167,7 +7163,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-770">line 770</a>
<a href="Body.js.html#sunlight-1-line-773">line 773</a>
</li>
</ul>
</dd>
@@ -7266,7 +7262,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-782">line 782</a>
<a href="Body.js.html#sunlight-1-line-785">line 785</a>
</li>
</ul>
</dd>
@@ -7365,7 +7361,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-794">line 794</a>
<a href="Body.js.html#sunlight-1-line-797">line 797</a>
</li>
</ul>
</dd>
@@ -7464,7 +7460,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-842">line 842</a>
<a href="Body.js.html#sunlight-1-line-845">line 845</a>
</li>
</ul>
</dd>
@@ -7563,7 +7559,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-806">line 806</a>
<a href="Body.js.html#sunlight-1-line-809">line 809</a>
</li>
</ul>
</dd>
@@ -7662,7 +7658,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-818">line 818</a>
<a href="Body.js.html#sunlight-1-line-821">line 821</a>
</li>
</ul>
</dd>
@@ -7761,7 +7757,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-830">line 830</a>
<a href="Body.js.html#sunlight-1-line-833">line 833</a>
</li>
</ul>
</dd>
@@ -7860,7 +7856,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-606">line 606</a>
<a href="Body.js.html#sunlight-1-line-607">line 607</a>
</li>
</ul>
</dd>
@@ -7936,7 +7932,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-854">line 854</a>
<a href="Body.js.html#sunlight-1-line-857">line 857</a>
</li>
</ul>
</dd>
@@ -8130,7 +8126,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-731">line 731</a>
<a href="Body.js.html#sunlight-1-line-734">line 734</a>
</li>
</ul>
</dd>
@@ -8229,7 +8225,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-746">line 746</a>
<a href="Body.js.html#sunlight-1-line-749">line 749</a>
</li>
</ul>
</dd>
@@ -8328,7 +8324,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-758">line 758</a>
<a href="Body.js.html#sunlight-1-line-761">line 761</a>
</li>
</ul>
</dd>
@@ -8427,7 +8423,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-523">line 523</a>
<a href="Body.js.html#sunlight-1-line-524">line 524</a>
</li>
</ul>
</dd>
@@ -8503,7 +8499,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-435">line 435</a>
<a href="Body.js.html#sunlight-1-line-436">line 436</a>
</li>
</ul>
</dd>
@@ -8757,7 +8753,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-995">line 995</a>
<a href="Body.js.html#sunlight-1-line-998">line 998</a>
</li>
</ul>
</dd>
@@ -9007,7 +9003,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1070">line 1070</a>
<a href="Body.js.html#sunlight-1-line-1073">line 1073</a>
</li>
</ul>
</dd>
@@ -9178,7 +9174,7 @@ touching.up = true means the collision happened to the top of this Body for exam
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-697">line 697</a>
<a href="Body.js.html#sunlight-1-line-698">line 698</a>
</li>
</ul>
</dd>
@@ -9476,7 +9472,7 @@ is the position of the Body relative to the center of the Sprite.</p>
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-657">line 657</a>
<a href="Body.js.html#sunlight-1-line-658">line 658</a>
</li>
</ul>
</dd>
@@ -9552,7 +9548,7 @@ is the position of the Body relative to the center of the Sprite.</p>
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-408">line 408</a>
<a href="Body.js.html#sunlight-1-line-409">line 409</a>
</li>
</ul>
</dd>
@@ -9605,7 +9601,7 @@ is the position of the Body relative to the center of the Sprite.</p>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+40 -44
View File
@@ -86,7 +86,7 @@
Cube
</h2>
<div class="class-description"><p>Phaser.Plugin.Isometric.Cube</p></div>
<div class="class-description"><p>Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.</p></div>
</header>
@@ -104,10 +104,6 @@
<dd>
<div class="description">
<p>Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.</p>
</div>
@@ -307,7 +303,7 @@
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-14">line 14</a>
<a href="Cube.js.html#sunlight-1-line-16">line 16</a>
</li>
</ul>
</dd>
@@ -469,7 +465,7 @@
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-279">line 279</a>
<a href="Cube.js.html#sunlight-1-line-281">line 281</a>
</li>
</ul>
</dd>
@@ -582,7 +578,7 @@
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-301">line 301</a>
<a href="Cube.js.html#sunlight-1-line-303">line 303</a>
</li>
</ul>
</dd>
@@ -696,7 +692,7 @@ However it does affect the height property, whereas changing the z value does no
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-235">line 235</a>
<a href="Cube.js.html#sunlight-1-line-237">line 237</a>
</li>
</ul>
</dd>
@@ -809,7 +805,7 @@ However it does affect the height property, whereas changing the z value does no
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-379">line 379</a>
<a href="Cube.js.html#sunlight-1-line-381">line 381</a>
</li>
</ul>
</dd>
@@ -922,7 +918,7 @@ However it does affect the height property, whereas changing the z value does no
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-394">line 394</a>
<a href="Cube.js.html#sunlight-1-line-396">line 396</a>
</li>
</ul>
</dd>
@@ -1035,7 +1031,7 @@ However it does affect the height property, whereas changing the z value does no
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-409">line 409</a>
<a href="Cube.js.html#sunlight-1-line-411">line 411</a>
</li>
</ul>
</dd>
@@ -1149,7 +1145,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-472">line 472</a>
<a href="Cube.js.html#sunlight-1-line-474">line 474</a>
</li>
</ul>
</dd>
@@ -1262,7 +1258,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-323">line 323</a>
<a href="Cube.js.html#sunlight-1-line-325">line 325</a>
</li>
</ul>
</dd>
@@ -1375,7 +1371,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-344">line 344</a>
<a href="Cube.js.html#sunlight-1-line-346">line 346</a>
</li>
</ul>
</dd>
@@ -1484,7 +1480,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-222">line 222</a>
<a href="Cube.js.html#sunlight-1-line-224">line 224</a>
</li>
</ul>
</dd>
@@ -1593,7 +1589,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-196">line 196</a>
<a href="Cube.js.html#sunlight-1-line-198">line 198</a>
</li>
</ul>
</dd>
@@ -1702,7 +1698,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-209">line 209</a>
<a href="Cube.js.html#sunlight-1-line-211">line 211</a>
</li>
</ul>
</dd>
@@ -1811,7 +1807,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-51">line 51</a>
<a href="Cube.js.html#sunlight-1-line-53">line 53</a>
</li>
</ul>
</dd>
@@ -1924,7 +1920,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-424">line 424</a>
<a href="Cube.js.html#sunlight-1-line-426">line 426</a>
</li>
</ul>
</dd>
@@ -2037,7 +2033,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-440">line 440</a>
<a href="Cube.js.html#sunlight-1-line-442">line 442</a>
</li>
</ul>
</dd>
@@ -2150,7 +2146,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-456">line 456</a>
<a href="Cube.js.html#sunlight-1-line-458">line 458</a>
</li>
</ul>
</dd>
@@ -2263,7 +2259,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-258">line 258</a>
<a href="Cube.js.html#sunlight-1-line-260">line 260</a>
</li>
</ul>
</dd>
@@ -2376,7 +2372,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-365">line 365</a>
<a href="Cube.js.html#sunlight-1-line-367">line 367</a>
</li>
</ul>
</dd>
@@ -2485,7 +2481,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-41">line 41</a>
<a href="Cube.js.html#sunlight-1-line-43">line 43</a>
</li>
</ul>
</dd>
@@ -2594,7 +2590,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-46">line 46</a>
<a href="Cube.js.html#sunlight-1-line-48">line 48</a>
</li>
</ul>
</dd>
@@ -2703,7 +2699,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-26">line 26</a>
<a href="Cube.js.html#sunlight-1-line-28">line 28</a>
</li>
</ul>
</dd>
@@ -2812,7 +2808,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-31">line 31</a>
<a href="Cube.js.html#sunlight-1-line-33">line 33</a>
</li>
</ul>
</dd>
@@ -2921,7 +2917,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-36">line 36</a>
<a href="Cube.js.html#sunlight-1-line-38">line 38</a>
</li>
</ul>
</dd>
@@ -3085,7 +3081,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-511">line 511</a>
<a href="Cube.js.html#sunlight-1-line-513">line 513</a>
</li>
</ul>
</dd>
@@ -3298,7 +3294,7 @@ If set to true then all of the Cube properties are set to 0.</p>
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-528">line 528</a>
<a href="Cube.js.html#sunlight-1-line-530">line 530</a>
</li>
</ul>
</dd>
@@ -3470,7 +3466,7 @@ A Cube object is said to contain another if the second Cube object falls entirel
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-556">line 556</a>
<a href="Cube.js.html#sunlight-1-line-558">line 558</a>
</li>
</ul>
</dd>
@@ -3641,7 +3637,7 @@ A Cube object is said to contain another if the second Cube object falls entirel
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-545">line 545</a>
<a href="Cube.js.html#sunlight-1-line-547">line 547</a>
</li>
</ul>
</dd>
@@ -3813,7 +3809,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-575">line 575</a>
<a href="Cube.js.html#sunlight-1-line-577">line 577</a>
</li>
</ul>
</dd>
@@ -4004,7 +4000,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-494">line 494</a>
<a href="Cube.js.html#sunlight-1-line-496">line 496</a>
</li>
</ul>
</dd>
@@ -4164,7 +4160,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-139">line 139</a>
<a href="Cube.js.html#sunlight-1-line-141">line 141</a>
</li>
</ul>
</dd>
@@ -4308,7 +4304,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-96">line 96</a>
<a href="Cube.js.html#sunlight-1-line-98">line 98</a>
</li>
</ul>
</dd>
@@ -4456,7 +4452,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-108">line 108</a>
<a href="Cube.js.html#sunlight-1-line-110">line 110</a>
</li>
</ul>
</dd>
@@ -4555,7 +4551,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-164">line 164</a>
<a href="Cube.js.html#sunlight-1-line-166">line 166</a>
</li>
</ul>
</dd>
@@ -4704,7 +4700,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-151">line 151</a>
<a href="Cube.js.html#sunlight-1-line-153">line 153</a>
</li>
</ul>
</dd>
@@ -4967,7 +4963,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-72">line 72</a>
<a href="Cube.js.html#sunlight-1-line-74">line 74</a>
</li>
</ul>
</dd>
@@ -5127,7 +5123,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-127">line 127</a>
<a href="Cube.js.html#sunlight-1-line-129">line 129</a>
</li>
</ul>
</dd>
@@ -5226,7 +5222,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<ul class="dummy">
<li>
<a href="Cube.js.html">Cube.js</a>,
<a href="Cube.js.html#sunlight-1-line-184">line 184</a>
<a href="Cube.js.html#sunlight-1-line-186">line 186</a>
</li>
</ul>
</dd>
@@ -5302,7 +5298,7 @@ This method checks the x, y, z, widthX, widthY, and height properties of the Cub
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+538 -120
View File
@@ -86,7 +86,9 @@
IsoSprite
</h2>
<div class="class-description"><p>Phaser.Plugin.Isometric.IsoSprite</p></div>
<div class="class-description"><p>Create a new <code>IsoSprite</code> object. IsoSprites are extended versions of standard Sprites that are suitable for axonometric positioning.</p>
<p>IsoSprites are simply Sprites that have three new position properties (isoX, isoY and isoZ) and ask the instance of Phaser.Plugin.Isometric.Projector what their position should be in a 2D scene whenever these properties are changed.
The IsoSprites retain their 2D position property to prevent any problems and allow you to interact with them as you would a normal Sprite. The upside of this simplicity is that things should behave predictably for those already used to Phaser.</p></div>
</header>
@@ -97,116 +99,23 @@
<dt>
<h4 class="name" id="IsoSprite"><span class="type-signature"></span>new IsoSprite<span class="signature">()</span><span class="type-signature"></span></h4>
<h4 class="name" id="IsoSprite"><span class="type-signature"></span>new IsoSprite<span class="signature">(game, x, y, z, key, frame)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>Phaser IsoSprite constructor</p>
</div>
<dl class="details">
<h5>Parameters:</h5>
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-6">line 6</a>
</li>
</ul>
</dd>
</dl>
</dd>
</div>
<h3 class="subsection-title">Members</h3>
<dl>
<dt class="name" id="_depth">
<h4><span class="type-signature">&lt;readonly> </span>_depth<span class="type-signature"></span></h4>
</dt>
<dd>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<table class="params table table-striped">
<thead>
<tr>
@@ -228,7 +137,30 @@
<tr>
<td class="name"><code>_depth</code></td>
<td class="name"><code>game</code></td>
<td class="type">
<span class="param-type">Phaser.Game</span>
</td>
<td class="description last"><p>A reference to the currently running game.</p></td>
</tr>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
@@ -244,14 +176,121 @@
<td class="description last"><p>Internal cached depth value.</p></td>
<td class="description last"><p>The x coordinate (in 3D space) to position the IsoSprite at.</p></td>
</tr>
<tr>
<td class="name"><code>y</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The y coordinate (in 3D space) to position the IsoSprite at.</p></td>
</tr>
<tr>
<td class="name"><code>z</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The z coordinate (in 3D space) to position the IsoSprite at.</p></td>
</tr>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">Phaser.RenderTexture</span>
|
<span class="param-type">Phaser.BitmapData</span>
|
<span class="param-type">PIXI.Texture</span>
</td>
<td class="description last"><p>This is the image or texture used by the IsoSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.</p></td>
</tr>
<tr>
<td class="name"><code>frame</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">number</span>
</td>
<td class="description last"><p>If this IsoSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.</p></td>
</tr>
</tbody>
</table>
</dl>
<dl class="details">
@@ -278,7 +317,7 @@
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-32">line 32</a>
<a href="IsoSprite.js.html#sunlight-1-line-19">line 19</a>
</li>
</ul>
</dd>
@@ -291,19 +330,55 @@
</dl>
</dd>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>Phaser.Sprite</li>
</ul>
<h3 class="subsection-title">Members</h3>
<dl>
<dt class="name" id="_depthChanged">
<h4><span class="type-signature">&lt;readonly> </span>_depthChanged<span class="type-signature"></span></h4>
<dt class="name" id="depth">
<h4><span class="type-signature">&lt;readonly> </span>depth<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>The non-unit distance of the IsoSprite from the 'front' of the scene. Used to correctly depth sort a group of IsoSprites.</p>
</div>
@@ -337,13 +412,13 @@
<tr>
<td class="name"><code>_depthChanged</code></td>
<td class="name"><code>depth</code></td>
<td class="type">
<span class="param-type">boolean</span>
<span class="param-type">number</span>
@@ -353,7 +428,7 @@
<td class="description last"><p>Internal invalidation control for depth management.</p></td>
<td class="description last"><p>A calculated value used for depth sorting.</p></td>
</tr>
@@ -387,7 +462,7 @@
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-38">line 38</a>
<a href="IsoSprite.js.html#sunlight-1-line-160">line 160</a>
</li>
</ul>
</dd>
@@ -406,13 +481,17 @@
<dt class="name" id="_isoPositionChanged">
<h4><span class="type-signature">&lt;readonly> </span>_isoPositionChanged<span class="type-signature"></span></h4>
<dt class="name" id="isoPosition">
<h4><span class="type-signature">&lt;readonly> </span>isoPosition<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>A Point3 object representing the axonometric position of the IsoSprite.</p>
</div>
@@ -446,13 +525,13 @@
<tr>
<td class="name"><code>_isoPositionChanged</code></td>
<td class="name"><code>isoPosition</code></td>
<td class="type">
<span class="param-type">boolean</span>
<span class="param-type">Point3</span>
@@ -462,7 +541,7 @@
<td class="description last"><p>Internal invalidation control for positioning.</p></td>
<td class="description last"><p>The axonometric position of the IsoSprite on the z axis.</p></td>
</tr>
@@ -496,7 +575,346 @@
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-44">line 44</a>
<a href="IsoSprite.js.html#sunlight-1-line-147">line 147</a>
</li>
</ul>
</dd>
</dl>
</dd>
<dt class="name" id="isoX">
<h4><span class="type-signature"></span>isoX<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>The axonometric position of the IsoSprite on the x axis. Increasing the x coordinate will move the object down and to the right on the screen.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>isoX</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The axonometric position of the IsoSprite on the x axis.</p></td>
</tr>
</tbody>
</table>
</dl>
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-99">line 99</a>
</li>
</ul>
</dd>
</dl>
</dd>
<dt class="name" id="isoY">
<h4><span class="type-signature"></span>isoY<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>The axonometric position of the IsoSprite on the y axis. Increasing the y coordinate will move the object down and to the left on the screen.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>isoY</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The axonometric position of the IsoSprite on the y axis.</p></td>
</tr>
</tbody>
</table>
</dl>
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-115">line 115</a>
</li>
</ul>
</dd>
</dl>
</dd>
<dt class="name" id="isoZ">
<h4><span class="type-signature"></span>isoZ<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>The axonometric position of the IsoSprite on the z axis. Increasing the z coordinate will move the object directly upwards on the screen.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>isoZ</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The axonometric position of the IsoSprite on the z axis.</p></td>
</tr>
</tbody>
</table>
</dl>
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-131">line 131</a>
</li>
</ul>
</dd>
@@ -571,7 +989,7 @@
<td class="description last"><p>Snap this IsoSprite's position to this value; handy for keeping pixel art snapped to whole pixels.</p></td>
<td class="description last"><p>Snap this IsoSprite's position to the specified value; handy for keeping pixel art snapped to whole pixels.</p></td>
</tr>
@@ -612,7 +1030,7 @@
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-26">line 26</a>
<a href="IsoSprite.js.html#sunlight-1-line-39">line 39</a>
</li>
</ul>
</dd>
@@ -721,7 +1139,7 @@
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-14">line 14</a>
<a href="IsoSprite.js.html#sunlight-1-line-27">line 27</a>
</li>
</ul>
</dd>
@@ -793,7 +1211,7 @@
<ul class="dummy">
<li>
<a href="IsoSprite.js.html">IsoSprite.js</a>,
<a href="IsoSprite.js.html#sunlight-1-line-52">line 52</a>
<a href="IsoSprite.js.html#sunlight-1-line-68">line 68</a>
</li>
</ul>
</dd>
@@ -846,7 +1264,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+32 -33
View File
@@ -86,8 +86,7 @@
Octree
</h2>
<div class="class-description"><p>A Octree implementation. The original code was a conversion of the Java code posted to GameDevTuts.
However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result.
<div class="class-description"><p>A Octree implementation based on Phaser.QuadTree.
Original version at <a href="https://github.com/timohausmann/quadtree-js/">https://github.com/timohausmann/quadtree-js/</a></p></div>
</header>
@@ -501,8 +500,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1111">line 1111</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-19">line 19</a>
</li>
</ul>
</dd>
@@ -636,8 +635,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1133">line 1133</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-41">line 41</a>
</li>
</ul>
</dd>
@@ -745,8 +744,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1128">line 1128</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-36">line 36</a>
</li>
</ul>
</dd>
@@ -861,8 +860,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1123">line 1123</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-31">line 31</a>
</li>
</ul>
</dd>
@@ -977,8 +976,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1117">line 1117</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-25">line 25</a>
</li>
</ul>
</dd>
@@ -1086,8 +1085,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1143">line 1143</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-51">line 51</a>
</li>
</ul>
</dd>
@@ -1195,8 +1194,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1138">line 1138</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-46">line 46</a>
</li>
</ul>
</dd>
@@ -1267,8 +1266,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1396">line 1396</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-304">line 304</a>
</li>
</ul>
</dd>
@@ -1395,8 +1394,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1295">line 1295</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-203">line 203</a>
</li>
</ul>
</dd>
@@ -1549,8 +1548,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1251">line 1251</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-159">line 159</a>
</li>
</ul>
</dd>
@@ -1674,8 +1673,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1197">line 1197</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-105">line 105</a>
</li>
</ul>
</dd>
@@ -1802,8 +1801,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1209">line 1209</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-117">line 117</a>
</li>
</ul>
</dd>
@@ -2235,8 +2234,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1157">line 1157</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-65">line 65</a>
</li>
</ul>
</dd>
@@ -2363,8 +2362,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1350">line 1350</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-258">line 258</a>
</li>
</ul>
</dd>
@@ -2464,8 +2463,8 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Body.js.html">physics/Body.js</a>,
<a href="Body.js.html#sunlight-1-line-1223">line 1223</a>
<a href="Octree.js.html">Octree.js</a>,
<a href="Octree.js.html#sunlight-1-line-131">line 131</a>
</li>
</ul>
</dd>
@@ -2518,7 +2517,7 @@ Original version at <a href="https://github.com/timohausmann/quadtree-js/">https
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
File diff suppressed because it is too large Load Diff
+8 -12
View File
@@ -86,7 +86,7 @@
Projector
</h2>
<div class="class-description"><p>Phaser.Plugin.Isometric.Projector</p></div>
<div class="class-description"><p>Creates a new Isometric Projector object, which has helpers for projecting x, y and z coordinates into axonometric x and y equivalents.</p></div>
</header>
@@ -104,10 +104,6 @@
<dd>
<div class="description">
<p>Creates a new Isometric Projector object, which has helpers for projecting x, y and z coordinates into axonometric x and y equivalents.</p>
</div>
@@ -215,7 +211,7 @@
<ul class="dummy">
<li>
<a href="Projector.js.html">Projector.js</a>,
<a href="Projector.js.html#sunlight-1-line-10">line 10</a>
<a href="Projector.js.html#sunlight-1-line-12">line 12</a>
</li>
</ul>
</dd>
@@ -373,7 +369,7 @@
<ul class="dummy">
<li>
<a href="Projector.js.html">Projector.js</a>,
<a href="Projector.js.html#sunlight-1-line-27">line 27</a>
<a href="Projector.js.html#sunlight-1-line-29">line 29</a>
</li>
</ul>
</dd>
@@ -482,7 +478,7 @@
<ul class="dummy">
<li>
<a href="Projector.js.html">Projector.js</a>,
<a href="Projector.js.html#sunlight-1-line-15">line 15</a>
<a href="Projector.js.html#sunlight-1-line-17">line 17</a>
</li>
</ul>
</dd>
@@ -591,7 +587,7 @@
<ul class="dummy">
<li>
<a href="Projector.js.html">Projector.js</a>,
<a href="Projector.js.html#sunlight-1-line-21">line 21</a>
<a href="Projector.js.html#sunlight-1-line-23">line 23</a>
</li>
</ul>
</dd>
@@ -735,7 +731,7 @@
<ul class="dummy">
<li>
<a href="Projector.js.html">Projector.js</a>,
<a href="Projector.js.html#sunlight-1-line-32">line 32</a>
<a href="Projector.js.html#sunlight-1-line-34">line 34</a>
</li>
</ul>
</dd>
@@ -906,7 +902,7 @@
<ul class="dummy">
<li>
<a href="Projector.js.html">Projector.js</a>,
<a href="Projector.js.html#sunlight-1-line-54">line 54</a>
<a href="Projector.js.html#sunlight-1-line-56">line 56</a>
</li>
</ul>
</dd>
@@ -982,7 +978,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+5 -12
View File
@@ -84,7 +84,9 @@
Isometric
</h2>
<div class="class-description"><p>Phaser.Plugin.Isometric</p></div>
<div class="class-description"><p>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.</p></div>
</header>
@@ -102,12 +104,6 @@
<dd>
<div class="description">
<p>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.</p>
</div>
@@ -192,7 +188,7 @@ Also included is an Arcade-based 3D AABB physics engine, which again is closely
<ul class="dummy">
<li>
<a href="Isometric.js.html">Isometric.js</a>,
<a href="Isometric.js.html#sunlight-1-line-44">line 44</a>
<a href="Isometric.js.html#sunlight-1-line-45">line 45</a>
</li>
</ul>
</dd>
@@ -250,9 +246,6 @@ Also included is an Arcade-based 3D AABB physics engine, which again is closely
<dt><a href="Phaser.Plugin.Isometric.Point3.html">Point3</a></dt>
<dd></dd>
<dt><a href="Phaser.Plugin.Isometric.Point3.html">Point3</a></dt>
<dd></dd>
<dt><a href="Phaser.Plugin.Isometric.Projector.html">Projector</a></dt>
<dd></dd>
</dl>
@@ -287,7 +280,7 @@ Also included is an Arcade-based 3D AABB physics engine, which again is closely
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+3 -4
View File
@@ -83,14 +83,13 @@
<pre
class="sunlight-highlight-javascript linenums">/**
* @class Phaser.Plugin.Isometric.Point3
*
* @classdesc
* The Point3 object represents a location in a three-dimensional coordinate system,
* where x and y represent the horizontal axes and z represents the vertical axis.
* The following code creates a point at (0,0,0):
* `var myPoint = new Phaser.Plugin.Isometric.Point3();`
*/
/**
*
* Creates a new Point3 object. If you pass no parameters a Point3 is created set to (0, 0, 0).
*
* @constructor
@@ -402,7 +401,7 @@ Phaser.Plugin.Isometric.Point3.equals = function (a, b) {
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+5 -3
View File
@@ -82,9 +82,11 @@
<article>
<pre
class="sunlight-highlight-javascript linenums">/**
* 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
*
* @classdesc
* Creates a new Isometric Projector object, which has helpers for projecting x, y and z coordinates into axonometric x and y equivalents.
*
* @constructor
* @param {Phaser.Game} game - The current game object.
* @param {number} projectionRatio - The ratio of the axonometric projection.
@@ -178,7 +180,7 @@ Phaser.Plugin.Isometric.Projector.prototype = {
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+1 -1
View File
@@ -1179,7 +1179,7 @@ Phaser.Physics.prototype.destroy = (function (_super) {
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+1 -4
View File
@@ -160,9 +160,6 @@
<dt><a href="Phaser.Plugin.Isometric.Point3.html">Point3</a></dt>
<dd></dd>
<dt><a href="Phaser.Plugin.Isometric.Point3.html">Point3</a></dt>
<dd></dd>
<dt><a href="Phaser.Plugin.Isometric.Projector.html">Projector</a></dt>
<dd></dd>
</dl>
@@ -197,7 +194,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+1 -1
View File
@@ -118,7 +118,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Wed Aug 6th 2014 using the <a
on Thu Aug 7th 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
+13
View File
@@ -0,0 +1,13 @@
{
"name": "phaser-plugin-isometric",
"version": "0.7.3",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "^0.5.0",
"grunt-contrib-jshint": "^0.9.2",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-watch": "*",
"grunt-jsdoc": "~0.5.6"
}
}
+4 -2
View File
@@ -1,7 +1,9 @@
/**
* Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.
*
* @class Phaser.Plugin.Isometric.Cube
*
* @classdesc
* Creates a new Cube object with the bottom-back corner specified by the x, y and z parameters, with the specified breadth (widthX), depth (widthY) and height parameters. If you call this function without parameters, a Cube with x, y, z, breadth, depth and height properties set to 0 is created.
*
* @constructor
* @param {number} x - The x coordinate of the bottom-back corner of the Cube.
* @param {number} y - The y coordinate of the bottom-back corner of the Cube.
+28 -12
View File
@@ -1,11 +1,24 @@
/**
* Phaser IsoSprite constructor
* @class Phaser.Plugin.Isometric.IsoSprite
* @constructor
* @class Phaser.Plugin.Isometric.IsoSprite
*
* @classdesc
* Create a new `IsoSprite` object. IsoSprites are extended versions of standard Sprites that are suitable for axonometric positioning.
*
* IsoSprites are simply Sprites that have three new position properties (isoX, isoY and isoZ) and ask the instance of Phaser.Plugin.Isometric.Projector what their position should be in a 2D scene whenever these properties are changed.
* The IsoSprites retain their 2D position property to prevent any problems and allow you to interact with them as you would a normal Sprite. The upside of this simplicity is that things should behave predictably for those already used to Phaser.
*
* @constructor
* @extends Phaser.Sprite
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {number} x - The x coordinate (in 3D space) to position the IsoSprite at.
* @param {number} y - The y coordinate (in 3D space) to position the IsoSprite at.
* @param {number} z - The z coordinate (in 3D space) to position the IsoSprite at.
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the IsoSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
* @param {string|number} frame - If this IsoSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
*/
Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent) {
Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame) {
Phaser.Sprite.call(this, game, x, y, key, frame, parent);
Phaser.Sprite.call(this, game, x, y, key, frame);
/**
* @property {number} type - The const type of this object.
@@ -20,7 +33,7 @@ Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent)
this._isoPosition = new Phaser.Plugin.Isometric.Point3(x, y, z);
/**
* @property {number} snap - Snap this IsoSprite's position to this value; handy for keeping pixel art snapped to whole pixels.
* @property {number} snap - Snap this IsoSprite's position to the specified value; handy for keeping pixel art snapped to whole pixels.
* @default
*/
this.snap = 0;
@@ -28,18 +41,21 @@ Phaser.Plugin.Isometric.IsoSprite = function (game, x, y, z, key, frame, parent)
/**
* @property {number} _depth - Internal cached depth value.
* @readonly
* @private
*/
this._depth = 0;
/**
* @property {boolean} _depthChanged - Internal invalidation control for depth management.
* @readonly
* @private
*/
this._depthChanged = true;
/**
* @property {boolean} _isoPositionChanged - Internal invalidation control for positioning.
* @readonly
* @private
*/
this._isoPositionChanged = true;
@@ -83,7 +99,7 @@ Phaser.Plugin.Isometric.IsoSprite.prototype._project = function () {
/**
* The axonometric position of the IsoSprite on the x axis. Increasing the x coordinate will move the object down and to the right on the screen.
*
* @name Phaser.Sprite#isoX
* @name Phaser.Plugin.Isometric.IsoSprite#isoX
* @property {number} isoX - The axonometric position of the IsoSprite on the x axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", {
@@ -99,7 +115,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoX", {
/**
* The axonometric position of the IsoSprite on the y axis. Increasing the y coordinate will move the object down and to the left on the screen.
*
* @name Phaser.Sprite#isoY
* @name Phaser.Plugin.Isometric.IsoSprite#isoY
* @property {number} isoY - The axonometric position of the IsoSprite on the y axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", {
@@ -115,7 +131,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoY", {
/**
* The axonometric position of the IsoSprite on the z axis. Increasing the z coordinate will move the object directly upwards on the screen.
*
* @name Phaser.Sprite#isoZ
* @name Phaser.Plugin.Isometric.IsoSprite#isoZ
* @property {number} isoZ - The axonometric position of the IsoSprite on the z axis.
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", {
@@ -131,7 +147,7 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoZ", {
/**
* A Point3 object representing the axonometric position of the IsoSprite.
*
* @name Phaser.Sprite#isoPosition
* @name Phaser.Plugin.Isometric.IsoSprite#isoPosition
* @property {Point3} isoPosition - The axonometric position of the IsoSprite on the z axis.
* @readonly
*/
@@ -144,14 +160,14 @@ Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "isoPosition"
/**
* The non-unit distance of the IsoSprite from the 'front' of the scene. Used to correctly depth sort a group of IsoSprites.
*
* @name Phaser.Sprite#depth
* @name Phaser.Plugin.Isometric.IsoSprite#depth
* @property {number} depth - A calculated value used for depth sorting.
* @readonly
*/
Object.defineProperty(Phaser.Plugin.Isometric.IsoSprite.prototype, "depth", {
get: function () {
if (this._depthChanged === true) {
this._depth = (this._isoPosition.x + this._isoPosition.y) + (this._isoPosition.z * 0.95);
this._depth = (this._isoPosition.x + this._isoPosition.y);
this._depthChanged = false;
}
return this._depth;
+5 -4
View File
@@ -32,13 +32,14 @@
*/
/**
* @class Phaser.Plugin.Isometric
*
* @classdesc
* 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) {
@@ -52,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.7.2';
Phaser.Plugin.Isometric.VERSION = '0.7.3';
// Directional consts
Phaser.Plugin.Isometric.UP = 0;
+388
View File
@@ -0,0 +1,388 @@
/**
* Octree Constructor
*
* @class Phaser.Plugin.Isometric.Octree
* @classdesc A Octree implementation based on Phaser.QuadTree.
* Original version at https://github.com/timohausmann/quadtree-js/
*
* @constructor
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
Phaser.Plugin.Isometric.Octree = function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
/**
* @property {number} maxObjects - The maximum number of objects per node.
* @default
*/
this.maxObjects = 10;
/**
* @property {number} maxLevels - The maximum number of levels to break down to.
* @default
*/
this.maxLevels = 4;
/**
* @property {number} level - The current level.
*/
this.level = 0;
/**
* @property {object} bounds - Object that contains the octree bounds.
*/
this.bounds = {};
/**
* @property {array} objects - Array of octree children.
*/
this.objects = [];
/**
* @property {array} nodes - Array of associated child nodes.
*/
this.nodes = [];
/**
* @property {array} _empty - Internal empty array.
* @private
*/
this._empty = [];
this.reset(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level);
};
Phaser.Plugin.Isometric.Octree.prototype = {
/**
* Resets the QuadTree.
*
* @method Phaser.Plugin.Isometric.Octree#reset
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
reset: function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
this.maxObjects = maxObjects || 10;
this.maxLevels = maxLevels || 4;
this.level = level || 0;
this.bounds = {
x: Math.round(x),
y: Math.round(y),
z: Math.round(z),
widthX: widthX,
widthY: widthY,
height: height,
subWidthX: Math.floor(widthX * 0.5),
subWidthY: Math.floor(widthY * 0.5),
subHeight: Math.floor(height * 0.5),
frontX: Math.round(x) + Math.floor(widthX * 0.5),
frontY: Math.round(y) + Math.floor(widthY * 0.5),
top: Math.round(z) + Math.floor(height * 0.5)
};
this.objects.length = 0;
this.nodes.length = 0;
},
/**
* Populates this octree with the children of the given Group. In order to be added the child must exist and have a body property.
*
* @method Phaser.Plugin.Isometric.Octree#populate
* @param {Phaser.Group} group - The Group to add to the octree.
*/
populate: function (group) {
group.forEach(this.populateHandler, this, true);
},
/**
* Handler for the populate method.
*
* @method Phaser.Plugin.Isometric.Octree#populateHandler
* @param {Phaser.Plugin.Isometric.IsoSprite|object} sprite - The Sprite to check.
*/
populateHandler: function (sprite) {
if (sprite.body && sprite.exists) {
this.insert(sprite.body);
}
},
/**
* Split the node into 8 subnodes
*
* @method Phaser.Plugin.Isometric.Octree#split
*/
split: function () {
// bottom four octants
// -x-y-z
this.nodes[0] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y-z
this.nodes[1] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y-z
this.nodes[2] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y-z
this.nodes[3] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// top four octants
// -x-y+z
this.nodes[4] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y+z
this.nodes[5] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y+z
this.nodes[6] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y+z
this.nodes[7] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
},
/**
* Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
*
* @method Phaser.Plugin.Isometric.Octree#insert
* @param {Phaser.Plugin.Isometric.Body|Phaser.Plugin.Isometric.Cube|object} body - The Body object to insert into the octree. Can be any object so long as it exposes x, y, z, frontX, frontY and top properties.
*/
insert: function (body) {
var i = 0;
var index;
// if we have subnodes ...
if (this.nodes[0] !== null) {
index = this.getIndex(body);
if (index !== -1) {
this.nodes[index].insert(body);
return;
}
}
this.objects.push(body);
if (this.objects.length > this.maxObjects && this.level < this.maxLevels) {
// Split if we don't already have subnodes
if (this.nodes[0] === null) {
this.split();
}
// Add objects to subnodes
while (i < this.objects.length) {
index = this.getIndex(this.objects[i]);
if (index !== -1) {
// this is expensive - see what we can do about it
this.nodes[index].insert(this.objects.splice(i, 1)[0]);
} else {
i++;
}
}
}
},
/**
* Determine which node the object belongs to.
*
* @method Phaser.Plugin.Isometric.Octree#getIndex
* @param {Phaser.Plugin.Isometric.Cube|object} cube - The bounds in which to check.
* @return {number} index - Index of the subnode (0-7), or -1 if cube cannot completely fit within a subnode and is part of the parent node.
*/
getIndex: function (cube) {
// default is that cube doesn't fit, i.e. it straddles the internal octants
var index = -1;
if (cube.x < this.bounds.frontX && cube.frontX < this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x-y-z octant
index = 0;
} else if (cube.z > this.bounds.top) {
// cube fits into -x-y+z octant
index = 4;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x+y-z octant
index = 2;
} else if (cube.z > this.bounds.top) {
// cube fits into -x+y+z octant
index = 6;
}
}
} else if (cube.x > this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x-y-z octant
index = 1;
} else if (cube.z > this.bounds.top) {
// cube fits into +x-y+z octant
index = 5;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x+y-z octant
index = 3;
} else if (cube.z > this.bounds.top) {
// cube fits into +x+y+z octant
index = 7;
}
}
}
return index;
},
/**
* Return all objects that could collide with the given IsoSprite or Cube.
*
* @method Phaser.Plugin.Isometric.Octree#retrieve
* @param {Phaser.Plugin.Isometric.IsoSprite|Phaser.Plugin.Isometric.Cube} source - The source object to check the Octree against. Either a IsoSprite or Cube.
* @return {array} - Array with all detected objects.
*/
retrieve: function (source) {
var returnObjects, index;
if (source instanceof Phaser.Plugin.Isometric.Cube) {
returnObjects = this.objects;
index = this.getIndex(source);
} else {
if (!source.body) {
return this._empty;
}
returnObjects = this.objects;
index = this.getIndex(source.body);
}
if (this.nodes[0]) {
// If cube fits into a subnode ..
if (index !== -1) {
returnObjects = returnObjects.concat(this.nodes[index].retrieve(source));
} else {
// If cube does not fit into a subnode, check it against all subnodes (unrolled for speed)
returnObjects = returnObjects.concat(this.nodes[0].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[1].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[2].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[3].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[4].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[5].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[6].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[7].retrieve(source));
}
}
return returnObjects;
},
/**
* Clear the octree.
* @method Phaser.Plugin.Isometric.Octree#clear
*/
clear: function () {
this.objects.length = 0;
var i = this.nodes.length;
while (i--) {
this.nodes[i].clear();
this.nodes.splice(i, 1);
}
this.nodes.length = 0;
}
};
Phaser.Plugin.Isometric.Octree.prototype.constructor = Phaser.Plugin.Isometric.Octree;
/**
* Visually renders an Octree to the display.
*
* @method Phaser.Utils.Debug#octree
* @param {Phaser.Plugin.Isometric.Octree} octree - The octree to render.
* @param {string} color - The color of the lines in the quadtree.
*/
Phaser.Utils.Debug.prototype.octree = function (octree, color) {
color = color || 'rgba(255,0,0,0.3)';
this.start();
var bounds = octree.bounds,
i, points;
if (octree.nodes.length === 0) {
this.context.strokeStyle = color;
var cube = new Phaser.Plugin.Isometric.Cube(bounds.x, bounds.y, bounds.z, bounds.widthX, bounds.widthY, bounds.height);
var corners = cube.getCorners();
points = corners.slice(0, corners.length);
points = points.map(function (p) {
return this.game.iso.project(p);
});
this.context.moveTo(points[0].x, points[0].y);
this.context.beginPath();
this.context.strokeStyle = color;
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[3].x, points[3].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[0].x, points[0].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.moveTo(points[0].x, points[0].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.moveTo(points[3].x, points[3].y);
this.context.lineTo(points[7].x, points[7].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.moveTo(points[7].x, points[7].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.stroke();
this.context.closePath();
for (i = 0; i < octree.objects.length; i++) {
this.body(octree.objects[i].sprite, 'rgb(0,255,0)', false);
}
} else {
for (i = 0; i < octree.nodes.length; i++) {
this.octree(octree.nodes[i]);
}
}
this.stop();
};
+2 -3
View File
@@ -1,13 +1,12 @@
/**
* @class Phaser.Plugin.Isometric.Point3
*
* @classdesc
* The Point3 object represents a location in a three-dimensional coordinate system,
* where x and y represent the horizontal axes and z represents the vertical axis.
* The following code creates a point at (0,0,0):
* `var myPoint = new Phaser.Plugin.Isometric.Point3();`
*/
/**
*
* Creates a new Point3 object. If you pass no parameters a Point3 is created set to (0, 0, 0).
*
* @constructor
+4 -2
View File
@@ -1,7 +1,9 @@
/**
* 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
*
* @classdesc
* Creates a new Isometric Projector object, which has helpers for projecting x, y and z coordinates into axonometric x and y equivalents.
*
* @constructor
* @param {Phaser.Game} game - The current game object.
* @param {number} projectionRatio - The ratio of the axonometric projection.
+7 -393
View File
@@ -1,9 +1,10 @@
/**
* @class Phaser.Plugin.Isometric.Body
*
* @classdesc
* The Physics Body is linked to a single IsoSprite. All physics operations should be performed against the body rather than
* the IsoSprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.
*
* @class Phaser.Plugin.Isometric.Body
* @classdesc IsoArcade Physics Body Constructor
*
* @constructor
* @param {Phaser.Plugin.Isometric.IsoSprite} sprite - The IsoSprite object this physics body belongs to.
*/
@@ -712,7 +713,7 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.position.x = x + ((this.widthX * -this.sprite.anchor.x) + this.widthX * 0.5) + this.offset.x;
this.position.y = y + ((this.widthY * this.sprite.anchor.x) - this.widthY * 0.5) + this.offset.y;
this.position.z = z - ((this.height * -this.sprite.anchor.y * 2) + this.height) + this.offset.z;
this.position.z = z - (Math.abs(this.sprite.height) * (1 - this.sprite.anchor.y)) + (Math.abs(this.sprite.width * 0.5)) + this.offset.z;
this.prev.x = this.position.x;
this.prev.y = this.position.y;
@@ -726,6 +727,8 @@ Phaser.Plugin.Isometric.Body.prototype = {
this.center.setTo(this.position.x + this.halfWidthX, this.position.y + this.halfWidthY, this.position.z + this.halfHeight);
this.sprite._isoPositionChanged = true;
},
/**
@@ -1090,395 +1093,6 @@ Phaser.Plugin.Isometric.Body.renderBodyInfo = function (debug, body) {
Phaser.Plugin.Isometric.Body.prototype.constructor = Phaser.Plugin.Isometric.Body;
/**
* Octree Constructor
*
* @class Phaser.Plugin.Isometric.Octree
* @classdesc A Octree implementation. The original code was a conversion of the Java code posted to GameDevTuts.
* However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result.
* Original version at https://github.com/timohausmann/quadtree-js/
* @constructor
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
Phaser.Plugin.Isometric.Octree = function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
/**
* @property {number} maxObjects - The maximum number of objects per node.
* @default
*/
this.maxObjects = 10;
/**
* @property {number} maxLevels - The maximum number of levels to break down to.
* @default
*/
this.maxLevels = 4;
/**
* @property {number} level - The current level.
*/
this.level = 0;
/**
* @property {object} bounds - Object that contains the octree bounds.
*/
this.bounds = {};
/**
* @property {array} objects - Array of octree children.
*/
this.objects = [];
/**
* @property {array} nodes - Array of associated child nodes.
*/
this.nodes = [];
/**
* @property {array} _empty - Internal empty array.
* @private
*/
this._empty = [];
this.reset(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level);
};
Phaser.Plugin.Isometric.Octree.prototype = {
/**
* Resets the QuadTree.
*
* @method Phaser.Plugin.Isometric.Octree#reset
* @param {number} x - The bottom-back coordinate of the octree.
* @param {number} y - The bottom-back coordinate of the octree.
* @param {number} z - The bottom-back coordinate of the octree.
* @param {number} widthX - The width X (breadth) of the octree.
* @param {number} widthY - The width Y (depth) of the octree.
* @param {number} height - The height (Z) of the octree.
* @param {number} [maxObjects=10] - The maximum number of objects per node.
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
* @param {number} [level=0] - Which level is this?
*/
reset: function (x, y, z, widthX, widthY, height, maxObjects, maxLevels, level) {
this.maxObjects = maxObjects || 10;
this.maxLevels = maxLevels || 4;
this.level = level || 0;
this.bounds = {
x: Math.round(x),
y: Math.round(y),
z: Math.round(z),
widthX: widthX,
widthY: widthY,
height: height,
subWidthX: Math.floor(widthX * 0.5),
subWidthY: Math.floor(widthY * 0.5),
subHeight: Math.floor(height * 0.5),
frontX: Math.round(x) + Math.floor(widthX * 0.5),
frontY: Math.round(y) + Math.floor(widthY * 0.5),
top: Math.round(z) + Math.floor(height * 0.5)
};
this.objects.length = 0;
this.nodes.length = 0;
},
/**
* Populates this octree with the children of the given Group. In order to be added the child must exist and have a body property.
*
* @method Phaser.Plugin.Isometric.Octree#populate
* @param {Phaser.Group} group - The Group to add to the octree.
*/
populate: function (group) {
group.forEach(this.populateHandler, this, true);
},
/**
* Handler for the populate method.
*
* @method Phaser.Plugin.Isometric.Octree#populateHandler
* @param {Phaser.Plugin.Isometric.IsoSprite|object} sprite - The Sprite to check.
*/
populateHandler: function (sprite) {
if (sprite.body && sprite.exists) {
this.insert(sprite.body);
}
},
/**
* Split the node into 8 subnodes
*
* @method Phaser.Plugin.Isometric.Octree#split
*/
split: function () {
// bottom four octants
// -x-y-z
this.nodes[0] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y-z
this.nodes[1] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y-z
this.nodes[2] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y-z
this.nodes[3] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.z, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// top four octants
// -x-y+z
this.nodes[4] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x-y+z
this.nodes[5] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.y, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// -x+y+z
this.nodes[6] = new Phaser.Plugin.Isometric.Octree(this.bounds.x, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
// +x+y+z
this.nodes[7] = new Phaser.Plugin.Isometric.Octree(this.bounds.frontX, this.bounds.frontY, this.bounds.top, this.bounds.subWidthX, this.bounds.subWidthY, this.bounds.subHeight, this.maxLevels, (this.level + 1));
},
/**
* Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
*
* @method Phaser.Plugin.Isometric.Octree#insert
* @param {Phaser.Plugin.Isometric.Body|Phaser.Plugin.Isometric.Cube|object} body - The Body object to insert into the octree. Can be any object so long as it exposes x, y, z, frontX, frontY and top properties.
*/
insert: function (body) {
var i = 0;
var index;
// if we have subnodes ...
if (this.nodes[0] !== null) {
index = this.getIndex(body);
if (index !== -1) {
this.nodes[index].insert(body);
return;
}
}
this.objects.push(body);
if (this.objects.length > this.maxObjects && this.level < this.maxLevels) {
// Split if we don't already have subnodes
if (this.nodes[0] === null) {
this.split();
}
// Add objects to subnodes
while (i < this.objects.length) {
index = this.getIndex(this.objects[i]);
if (index !== -1) {
// this is expensive - see what we can do about it
this.nodes[index].insert(this.objects.splice(i, 1)[0]);
} else {
i++;
}
}
}
},
/**
* Determine which node the object belongs to.
*
* @method Phaser.Plugin.Isometric.Octree#getIndex
* @param {Phaser.Plugin.Isometric.Cube|object} cube - The bounds in which to check.
* @return {number} index - Index of the subnode (0-7), or -1 if cube cannot completely fit within a subnode and is part of the parent node.
*/
getIndex: function (cube) {
// default is that cube doesn't fit, i.e. it straddles the internal octants
var index = -1;
if (cube.x < this.bounds.frontX && cube.frontX < this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x-y-z octant
index = 0;
} else if (cube.z > this.bounds.top) {
// cube fits into -x-y+z octant
index = 4;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into -x+y-z octant
index = 2;
} else if (cube.z > this.bounds.top) {
// cube fits into -x+y+z octant
index = 6;
}
}
} else if (cube.x > this.bounds.frontX) {
if (cube.y < this.bounds.frontY && cube.frontY < this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x-y-z octant
index = 1;
} else if (cube.z > this.bounds.top) {
// cube fits into +x-y+z octant
index = 5;
}
} else if (cube.y > this.bounds.frontY) {
if (cube.z < this.bounds.top && cube.top < this.bounds.top) {
// cube fits into +x+y-z octant
index = 3;
} else if (cube.z > this.bounds.top) {
// cube fits into +x+y+z octant
index = 7;
}
}
}
return index;
},
/**
* Return all objects that could collide with the given IsoSprite or Cube.
*
* @method Phaser.Plugin.Isometric.Octree#retrieve
* @param {Phaser.Plugin.Isometric.IsoSprite|Phaser.Plugin.Isometric.Cube} source - The source object to check the Octree against. Either a IsoSprite or Cube.
* @return {array} - Array with all detected objects.
*/
retrieve: function (source) {
var returnObjects, index;
if (source instanceof Phaser.Plugin.Isometric.Cube) {
returnObjects = this.objects;
index = this.getIndex(source);
} else {
if (!source.body) {
return this._empty;
}
returnObjects = this.objects;
index = this.getIndex(source.body);
}
if (this.nodes[0]) {
// If cube fits into a subnode ..
if (index !== -1) {
returnObjects = returnObjects.concat(this.nodes[index].retrieve(source));
} else {
// If cube does not fit into a subnode, check it against all subnodes (unrolled for speed)
returnObjects = returnObjects.concat(this.nodes[0].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[1].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[2].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[3].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[4].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[5].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[6].retrieve(source));
returnObjects = returnObjects.concat(this.nodes[7].retrieve(source));
}
}
return returnObjects;
},
/**
* Clear the octree.
* @method Phaser.Plugin.Isometric.Octree#clear
*/
clear: function () {
this.objects.length = 0;
var i = this.nodes.length;
while (i--) {
this.nodes[i].clear();
this.nodes.splice(i, 1);
}
this.nodes.length = 0;
}
};
Phaser.Plugin.Isometric.Octree.prototype.constructor = Phaser.Plugin.Isometric.Octree;
/**
* Visually renders an Octree to the display.
*
* @method Phaser.Utils.Debug#octree
* @param {Phaser.Plugin.Isometric.Octree} octree - The octree to render.
* @param {string} color - The color of the lines in the quadtree.
*/
Phaser.Utils.Debug.prototype.octree = function (octree, color) {
color = color || 'rgba(255,0,0,0.3)';
this.start();
var bounds = octree.bounds,
i, points;
if (octree.nodes.length === 0) {
this.context.strokeStyle = color;
var cube = new Phaser.Plugin.Isometric.Cube(bounds.x, bounds.y, bounds.z, bounds.widthX, bounds.widthY, bounds.height);
var corners = cube.getCorners();
points = corners.slice(0, corners.length);
points = points.map(function (p) {
return this.game.iso.project(p);
});
this.context.moveTo(points[0].x, points[0].y);
this.context.beginPath();
this.context.strokeStyle = color;
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[3].x, points[3].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.lineTo(points[1].x, points[1].y);
this.context.lineTo(points[0].x, points[0].y);
this.context.lineTo(points[4].x, points[4].y);
this.context.moveTo(points[0].x, points[0].y);
this.context.lineTo(points[2].x, points[2].y);
this.context.moveTo(points[3].x, points[3].y);
this.context.lineTo(points[7].x, points[7].y);
this.context.lineTo(points[6].x, points[6].y);
this.context.moveTo(points[7].x, points[7].y);
this.context.lineTo(points[5].x, points[5].y);
this.context.stroke();
this.context.closePath();
for (i = 0; i < octree.objects.length; i++) {
this.body(octree.objects[i].sprite, 'rgb(0,255,0)', false);
}
} else {
for (i = 0; i < octree.nodes.length; i++) {
this.octree(octree.nodes[i]);
}
}
this.stop();
};
Phaser.Utils.Debug.prototype.body = (function (_super) {
return function (sprite, color, filled) {