/**
-* @author Richard Davey <rich@photonstorm.com>
-* @copyright 2014 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Create a new DOMSprite.
-* @class Phaser.DOMSprite
-* @constructor
-* @param {Phaser.Game} game - Current game instance.
-* @param {string} id - DOM ID.
-* @param {number} x - X position of the new text object.
-* @param {number} y - Y position of the new text object.
-* @param {string} text - The actual text that will be written.
-* @param {object} style - The style object containing style attributes like font, font size ,
-*/
-Phaser.DOMSprite = function (game, element, x, y, style) {
-
- x = x || 0;
- y = y || 0;
- style = style || '';
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = game;
-
- /**
- * @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
- * @default
- */
- this.exists = true;
-
- /**
- * @property {boolean} alive - This is a handy little var your game can use to determine if an object is alive or not, it doesn't effect rendering.
- * @default
- */
- this.alive = true;
-
- /**
- * @property {Phaser.Group} group - The parent Group of this Text object.
- */
- this.group = null;
-
- /**
- * @property {string} name - The user defined name given to this object.
- * @default
- */
- this.name = '';
-
- /**
- * @property {number} type - The const type of this object.
- * @default
- */
- this.type = Phaser.DOMSPRITE;
-
- /**
- * @property {boolean} visible - Sets the visible state of this DOMSprite.
- * @default
- */
- this.visible = true;
-
- /*
- if (parent)
- {
- if (typeof parent === 'string')
- {
- // hopefully an element ID
- target = document.getElementById(parent);
- }
- else if (typeof parent === 'object' && parent.nodeType === 1)
- {
- // quick test for a HTMLelement
- target = parent;
- }
-
- if (overflowHidden)
- {
- target.style.overflow = 'hidden';
- }
- }
- */
-
-};
-
-// Phaser.DOMSprite.prototype = Object.create(PIXI.DOMSprite.prototype);
-// Phaser.DOMSprite.prototype.constructor = Phaser.DOMSprite;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/Debug.js.html b/docs/Debug.js.html
index c8275034..4a452d40 100644
--- a/docs/Debug.js.html
+++ b/docs/Debug.js.html
@@ -879,26 +879,7 @@ Phaser.Utils.Debug.prototype = {
this.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1));
this.line('angle: ' + sprite.angle.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1));
this.line('visible: ' + sprite.visible + ' in camera: ' + sprite.inCamera);
- this.line('body x: ' + sprite.body.x.toFixed(1) + ' y: ' + sprite.body.y.toFixed(1));
- // 0 = scaleX
- // 1 = skewY
- // 2 = translateX
- // 3 = skewX
- // 4 = scaleY
- // 5 = translateY
-
- this.line('id: ' + sprite._id);
- this.line('scale x: ' + sprite.worldTransform[0]);
- this.line('scale y: ' + sprite.worldTransform[4]);
- this.line('tx: ' + sprite.worldTransform[2]);
- this.line('ty: ' + sprite.worldTransform[5]);
- this.line('skew x: ' + sprite.worldTransform[3]);
- this.line('skew y: ' + sprite.worldTransform[1]);
- this.line('sdx: ' + sprite.deltaX);
- this.line('sdy: ' + sprite.deltaY);
-
- // this.line('inCamera: ' + this.game.renderer.spriteRenderer.inCamera(this.game.camera, sprite));
this.stop();
},
@@ -1364,7 +1345,7 @@ Phaser.Utils.Debug.prototype.constructor = Phaser.Utils.Debug;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Device.js.html b/docs/Device.js.html
index 0c9d8eec..01766458 100644
--- a/docs/Device.js.html
+++ b/docs/Device.js.html
@@ -1190,7 +1190,7 @@ Phaser.Device.prototype.constructor = Phaser.Device;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Easing.js.html b/docs/Easing.js.html
index 97fddaba..f316751e 100644
--- a/docs/Easing.js.html
+++ b/docs/Easing.js.html
@@ -1073,7 +1073,7 @@ Phaser.Easing = {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Ellipse.js.html b/docs/Ellipse.js.html
index a00cc84c..52cb5b8a 100644
--- a/docs/Ellipse.js.html
+++ b/docs/Ellipse.js.html
@@ -806,7 +806,7 @@ PIXI.Ellipse = Phaser.Ellipse;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:33 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Emitter.js.html b/docs/Emitter.js.html
index b439b724..70092927 100644
--- a/docs/Emitter.js.html
+++ b/docs/Emitter.js.html
@@ -1144,7 +1144,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Events.js.html b/docs/Events.js.html
index 17dcf631..96ecf3b0 100644
--- a/docs/Events.js.html
+++ b/docs/Events.js.html
@@ -589,7 +589,7 @@ Phaser.Events.prototype.constructor = Phaser.Events;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Filter.js.html b/docs/Filter.js.html
index 7aabecfd..faa5b71a 100644
--- a/docs/Filter.js.html
+++ b/docs/Filter.js.html
@@ -675,7 +675,7 @@ Object.defineProperty(Phaser.Filter.prototype, 'height', {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Frame.js.html b/docs/Frame.js.html
index 89fd7663..92463a1f 100644
--- a/docs/Frame.js.html
+++ b/docs/Frame.js.html
@@ -694,7 +694,7 @@ Phaser.Frame.prototype.constructor = Phaser.Frame;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/FrameData.js.html b/docs/FrameData.js.html
index 1d3f82e2..ffff6614 100644
--- a/docs/FrameData.js.html
+++ b/docs/FrameData.js.html
@@ -749,7 +749,7 @@ Object.defineProperty(Phaser.FrameData.prototype, "total", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Game.js.html b/docs/Game.js.html
index ab063cb3..771235ff 100644
--- a/docs/Game.js.html
+++ b/docs/Game.js.html
@@ -568,7 +568,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
this.renderer = Phaser.AUTO;
/**
- * @property {number} renderType - The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL.
+ * @property {number} renderType - The Renderer this game will use. Either Phaser.AUTO, Phaser.CANVAS or Phaser.WEBGL.
*/
this.renderType = Phaser.AUTO;
@@ -1031,6 +1031,13 @@ Phaser.Game.prototype = {
*/
setUpRenderer: function () {
+ if (this.device.trident)
+ {
+ // Pixi WebGL renderer on IE11 doesn't work correctly at the moment, the pre-multiplied alpha gets all washed out.
+ // So we're forcing canvas for now until this is fixed, sorry. It's got to be better than no game appearing at all, right?
+ this.renderType = Phaser.CANVAS;
+ }
+
if (this.renderType === Phaser.HEADLESS || this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL === false))
{
if (this.device.canvas)
@@ -1257,7 +1264,7 @@ Object.defineProperty(Phaser.Game.prototype, "paused", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/GameObjectCreator.js.html b/docs/GameObjectCreator.js.html
index 9595f769..0313d971 100644
--- a/docs/GameObjectCreator.js.html
+++ b/docs/GameObjectCreator.js.html
@@ -870,7 +870,7 @@ Phaser.GameObjectCreator.prototype.constructor = Phaser.GameObjectCreator;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/GameObjectFactory.js.html b/docs/GameObjectFactory.js.html
index 4be9f92a..4801f499 100644
--- a/docs/GameObjectFactory.js.html
+++ b/docs/GameObjectFactory.js.html
@@ -901,7 +901,7 @@ Phaser.GameObjectFactory.prototype.constructor = Phaser.GameObjectFactory;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Gamepad.js.html b/docs/Gamepad.js.html
index f91ec741..500b3815 100644
--- a/docs/Gamepad.js.html
+++ b/docs/Gamepad.js.html
@@ -1088,7 +1088,7 @@ Phaser.Gamepad.XBOX360_STICK_RIGHT_Y = 3;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/GamepadButton.js.html b/docs/GamepadButton.js.html
index 95ab2241..a6227c03 100644
--- a/docs/GamepadButton.js.html
+++ b/docs/GamepadButton.js.html
@@ -519,7 +519,7 @@ Phaser.GamepadButton = function (game, buttoncode) {
* @property {boolean} isUp - The "up" state of the button.
* @default
*/
- this.isUp = false;
+ this.isUp = true;
/**
* @property {number} timeDown - The timestamp when the button was last pressed down.
@@ -685,7 +685,7 @@ Phaser.GamepadButton.prototype.constructor = Phaser.GamepadButton;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Graphics.js.html b/docs/Graphics.js.html
index 5b335934..9f98156e 100644
--- a/docs/Graphics.js.html
+++ b/docs/Graphics.js.html
@@ -734,7 +734,7 @@ Object.defineProperty(Phaser.Graphics.prototype, "fixedToCamera", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Group.js.html b/docs/Group.js.html
index cb6dbd75..0ce417a3 100644
--- a/docs/Group.js.html
+++ b/docs/Group.js.html
@@ -1791,7 +1791,7 @@ Object.defineProperty(Phaser.Group.prototype, "fixedToCamera", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Image.js.html b/docs/Image.js.html
index 9a66294a..7603405f 100644
--- a/docs/Image.js.html
+++ b/docs/Image.js.html
@@ -1210,7 +1210,7 @@ Object.defineProperty(Phaser.Image.prototype, "fixedToCamera", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Input.js.html b/docs/Input.js.html
index ffb168cf..76aa0812 100644
--- a/docs/Input.js.html
+++ b/docs/Input.js.html
@@ -1221,6 +1221,22 @@ Phaser.Input.prototype = {
return false;
}
+ else if (displayObject instanceof Phaser.TileSprite)
+ {
+ var width = displayObject.width;
+ var height = displayObject.height;
+ var x1 = -width * displayObject.anchor.x;
+
+ if (this._localPoint.x > x1 && this._localPoint.x < x1 + width)
+ {
+ var y1 = -height * displayObject.anchor.y;
+
+ if (this._localPoint.y > y1 && this._localPoint.y < y1 + height)
+ {
+ return true;
+ }
+ }
+ }
else if (displayObject instanceof PIXI.Sprite)
{
var width = displayObject.texture.frame.width;
@@ -1386,7 +1402,7 @@ Object.defineProperty(Phaser.Input.prototype, "worldY", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/InputHandler.js.html b/docs/InputHandler.js.html
index 89a7aab2..42746a56 100644
--- a/docs/InputHandler.js.html
+++ b/docs/InputHandler.js.html
@@ -1794,7 +1794,7 @@ Phaser.InputHandler.prototype.constructor = Phaser.InputHandler;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/IntroDocs.js.html b/docs/IntroDocs.js.html
deleted file mode 100644
index 664fba12..00000000
--- a/docs/IntroDocs.js.html
+++ /dev/null
@@ -1,540 +0,0 @@
-
-
-
-
-
- Phaser Source: IntroDocs.js
-
-
-
-
-
-
-
-
-
-
-
/**
-* @author Richard Davey <rich@photonstorm.com>
-* @copyright 2014 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* @overview
-*
-* 
-*
-* Phaser - http://www.phaser.io
-*
-* v1.1.4 - Released February 5th 2014.
-*
-* By Richard Davey http://www.photonstorm.com @photonstorm
-*
-* A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and
-* constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm).
-*
-* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com/ @Doormat23.
-*
-* View the [Official Website](http://phaser.io)<br />
-* Follow on [Twitter](https://twitter.com/photonstorm)<br />
-* Join the [Forum](http://www.html5gamedevs.com/forum/14-phaser/)<br />
-* Try out 210+ [Phaser Examples](http://examples.phaser.io)<br />
-* Read the [documentation online](http://docs.phaser.io)
-*
-* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from which both Phaser
-* and my love of game development originate.
-*
-* "If you want your children to be intelligent, read them fairy tales."
-* "If you want them to be more intelligent, read them more fairy tales."
-* -- Albert Einstein
-*/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/InversePointProxy.js.html b/docs/InversePointProxy.js.html
index 1d2676cb..8be99ca0 100644
--- a/docs/InversePointProxy.js.html
+++ b/docs/InversePointProxy.js.html
@@ -573,7 +573,7 @@ Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "y", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Key.js.html b/docs/Key.js.html
index 228cda7a..5657050c 100644
--- a/docs/Key.js.html
+++ b/docs/Key.js.html
@@ -519,7 +519,7 @@ Phaser.Key = function (game, keycode) {
* @property {boolean} isUp - The "up" state of the key.
* @default
*/
- this.isUp = false;
+ this.isUp = true;
/**
* @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key.
@@ -683,7 +683,7 @@ Phaser.Key.prototype.constructor = Phaser.Key;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Keyboard.js.html b/docs/Keyboard.js.html
index 672751ff..403fd0c1 100644
--- a/docs/Keyboard.js.html
+++ b/docs/Keyboard.js.html
@@ -1007,7 +1007,7 @@ Phaser.Keyboard.NUM_LOCK = 144;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Line.js.html b/docs/Line.js.html
index 38f812aa..69bbc7f7 100644
--- a/docs/Line.js.html
+++ b/docs/Line.js.html
@@ -774,7 +774,7 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/LinkedList.js.html b/docs/LinkedList.js.html
index 09967842..2b992250 100644
--- a/docs/LinkedList.js.html
+++ b/docs/LinkedList.js.html
@@ -666,7 +666,7 @@ Phaser.LinkedList.prototype.constructor = Phaser.LinkedList;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Loader.js.html b/docs/Loader.js.html
index 68302b3c..dcb2a2fb 100644
--- a/docs/Loader.js.html
+++ b/docs/Loader.js.html
@@ -635,10 +635,10 @@ Phaser.Loader.prototype = {
/**
* You can set a Sprite to be a "preload" sprite by passing it to this method.
* A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time.
- * This allows you to easily make loading bars for games.
+ * This allows you to easily make loading bars for games. Note that Sprite.visible = true will be set when calling this.
*
* @method Phaser.Loader#setPreloadSprite
- * @param {Phaser.Sprite} sprite - The sprite that will be cropped during the load.
+ * @param {Phaser.Sprite|Phaser.Image} sprite - The sprite that will be cropped during the load.
* @param {number} [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped.
*/
setPreloadSprite: function (sprite, direction) {
@@ -660,6 +660,8 @@ Phaser.Loader.prototype = {
sprite.crop(this.preloadSprite.crop);
+ sprite.visible = true;
+
},
/**
@@ -850,6 +852,32 @@ Phaser.Loader.prototype = {
},
+ /**
+ * Add a json file to the Loader.
+ *
+ * @method Phaser.Loader#json
+ * @param {string} key - Unique asset key of the json file.
+ * @param {string} url - URL of the json file.
+ * @param {boolean} [overwrite=false] - If an unloaded file with a matching key already exists in the queue, this entry will overwrite it.
+ * @return {Phaser.Loader} This Loader instance.
+ */
+ json: function (key, url, overwrite) {
+
+ if (typeof overwrite === "undefined") { overwrite = false; }
+
+ if (overwrite)
+ {
+ this.replaceInFileList('json', key, url);
+ }
+ else
+ {
+ this.addToFileList('json', key, url);
+ }
+
+ return this;
+
+ },
+
/**
* Add a JavaScript file to the Loader. Once loaded the JavaScript file will be automatically turned into a script tag (and executed), so be careful what you load!
*
@@ -1374,6 +1402,15 @@ Phaser.Loader.prototype = {
break;
+ case 'json':
+ this._xhr.open("GET", this.baseURL + file.url, true);
+ this._xhr.responseType = "text";
+ this._xhr.onload = function () {
+ return _this.jsonLoadComplete(_this._fileIndex);
+ };
+ this._xhr.send();
+ break;
+
case 'tilemap':
this._xhr.open("GET", this.baseURL + file.url, true);
this._xhr.responseType = "text";
@@ -1665,6 +1702,10 @@ Phaser.Loader.prototype = {
{
this.game.cache.addTilemap(file.key, file.url, data, file.format);
}
+ else if (file.type === 'json')
+ {
+ this.game.cache.addJSON(file.key, file.url, data);
+ }
else
{
this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
@@ -1796,8 +1837,6 @@ Phaser.Loader.prototype = {
{
this.preloadSprite.crop.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
}
-
- // this.preloadSprite.sprite.crop = this.preloadSprite.crop;
}
this.onFileComplete.dispatch(this.progress, this._fileList[previousIndex].key, success, this.totalLoadedFiles(), this._fileList.length);
@@ -1885,7 +1924,7 @@ Phaser.Loader.prototype.constructor = Phaser.Loader;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/LoaderParser.js.html b/docs/LoaderParser.js.html
index e8f7a48d..b4b38369 100644
--- a/docs/LoaderParser.js.html
+++ b/docs/LoaderParser.js.html
@@ -594,7 +594,7 @@ Phaser.LoaderParser = {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/MSPointer.js.html b/docs/MSPointer.js.html
index a081c04d..a7ce4f6b 100644
--- a/docs/MSPointer.js.html
+++ b/docs/MSPointer.js.html
@@ -680,7 +680,7 @@ Phaser.MSPointer.prototype.constructor = Phaser.MSPointer;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Material.js.html b/docs/Material.js.html
index 33160a2e..abf073ff 100644
--- a/docs/Material.js.html
+++ b/docs/Material.js.html
@@ -537,7 +537,7 @@ Phaser.Physics.Material.prototype.constructor = Phaser.Physics.Material;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Math.js.html b/docs/Math.js.html
index 9103d3c2..9173ec3c 100644
--- a/docs/Math.js.html
+++ b/docs/Math.js.html
@@ -1891,7 +1891,7 @@ Phaser.Math = {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Mouse.js.html b/docs/Mouse.js.html
index f153fc58..13b4b324 100644
--- a/docs/Mouse.js.html
+++ b/docs/Mouse.js.html
@@ -656,7 +656,7 @@ Phaser.Mouse.prototype = {
event.preventDefault();
}
- this.button = event.which;
+ this.button = event.button;
if (this.mouseDownCallback)
{
@@ -841,7 +841,7 @@ Phaser.Mouse.prototype.constructor = Phaser.Mouse;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Net.js.html b/docs/Net.js.html
index f0e00fcb..fb3b9c39 100644
--- a/docs/Net.js.html
+++ b/docs/Net.js.html
@@ -676,7 +676,7 @@ Phaser.Net.prototype.constructor = Phaser.Net;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Particles.js.html b/docs/Particles.js.html
index 51ef760a..0766fa49 100644
--- a/docs/Particles.js.html
+++ b/docs/Particles.js.html
@@ -591,7 +591,7 @@ Phaser.Particles.prototype.constructor = Phaser.Particles;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Animation.html b/docs/Phaser.Animation.html
index f17dbc50..0390b15a 100644
--- a/docs/Phaser.Animation.html
+++ b/docs/Phaser.Animation.html
@@ -2986,7 +2986,7 @@ You could use this function to generate those by doing: Phaser.Animation.generat
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.AnimationManager.html b/docs/Phaser.AnimationManager.html
index 4159d793..b5450799 100644
--- a/docs/Phaser.AnimationManager.html
+++ b/docs/Phaser.AnimationManager.html
@@ -3033,7 +3033,7 @@ The currentAnim property of the AnimationManager is automatically set to the ani
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:23 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:35 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.AnimationParser.html b/docs/Phaser.AnimationParser.html
index 889c8af8..9fdaa163 100644
--- a/docs/Phaser.AnimationParser.html
+++ b/docs/Phaser.AnimationParser.html
@@ -1554,7 +1554,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:23 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:35 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.BitmapData.html b/docs/Phaser.BitmapData.html
index fda23b64..db0f5fa3 100644
--- a/docs/Phaser.BitmapData.html
+++ b/docs/Phaser.BitmapData.html
@@ -3941,7 +3941,7 @@ This is called automatically if the BitmapData is being used by a Sprite, otherw
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:23 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:35 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.BitmapFont.html b/docs/Phaser.BitmapFont.html
index 33300a0c..0a89a8b2 100644
--- a/docs/Phaser.BitmapFont.html
+++ b/docs/Phaser.BitmapFont.html
@@ -5142,7 +5142,7 @@ If text is wider than the width specified it will be cropped off.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:23 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:35 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.BitmapText.html b/docs/Phaser.BitmapText.html
index 3201ebe8..b5dc388e 100644
--- a/docs/Phaser.BitmapText.html
+++ b/docs/Phaser.BitmapText.html
@@ -2908,7 +2908,7 @@ activated for this object and it will then start to process click/touch events a
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:23 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:35 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Button.html b/docs/Phaser.Button.html
index 1ed147da..9a13f5b2 100644
--- a/docs/Phaser.Button.html
+++ b/docs/Phaser.Button.html
@@ -7838,7 +7838,7 @@ Call this function with no parameters at all to reset all sounds on this Button.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:23 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:35 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Cache.html b/docs/Phaser.Cache.html
index 5eb87d31..d8017b33 100644
--- a/docs/Phaser.Cache.html
+++ b/docs/Phaser.Cache.html
@@ -682,7 +682,7 @@
@@ -8995,7 +9478,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:24 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:36 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Camera.html b/docs/Phaser.Camera.html
index f5f06e61..956a22ff 100644
--- a/docs/Phaser.Camera.html
+++ b/docs/Phaser.Camera.html
@@ -3572,7 +3572,7 @@ without having to use game.camera.x and game.camera.y.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:24 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:36 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Canvas.html b/docs/Phaser.Canvas.html
index fa9f77b6..c16b141a 100644
--- a/docs/Phaser.Canvas.html
+++ b/docs/Phaser.Canvas.html
@@ -2698,7 +2698,7 @@ patchy on earlier browsers, especially on mobile.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:24 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:36 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Circle.html b/docs/Phaser.Circle.html
index 606e11d1..c26af70c 100644
--- a/docs/Phaser.Circle.html
+++ b/docs/Phaser.Circle.html
@@ -4376,7 +4376,7 @@ This method checks the radius distances between the two Circle objects to see if
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:24 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:36 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Color.html b/docs/Phaser.Color.html
index a4f0e04c..104fa4ec 100644
--- a/docs/Phaser.Color.html
+++ b/docs/Phaser.Color.html
@@ -3685,7 +3685,7 @@ Set the max value to restrict the maximum color used per channel.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:24 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:36 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.DOMSprite.html b/docs/Phaser.DOMSprite.html
deleted file mode 100644
index a9785517..00000000
--- a/docs/Phaser.DOMSprite.html
+++ /dev/null
@@ -1,1510 +0,0 @@
-
-
-
-
-
- Phaser Class: DOMSprite
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/Phaser.Device.html b/docs/Phaser.Device.html
index 40bf8638..915e4fed 100644
--- a/docs/Phaser.Device.html
+++ b/docs/Phaser.Device.html
@@ -6111,7 +6111,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:24 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:36 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Back.html b/docs/Phaser.Easing.Back.html
index 62c31444..a19386a1 100644
--- a/docs/Phaser.Easing.Back.html
+++ b/docs/Phaser.Easing.Back.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Bounce.html b/docs/Phaser.Easing.Bounce.html
index 6e5d55bb..ea3a9bee 100644
--- a/docs/Phaser.Easing.Bounce.html
+++ b/docs/Phaser.Easing.Bounce.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Circular.html b/docs/Phaser.Easing.Circular.html
index 00ed68f4..dd512014 100644
--- a/docs/Phaser.Easing.Circular.html
+++ b/docs/Phaser.Easing.Circular.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Cubic.html b/docs/Phaser.Easing.Cubic.html
index de949020..cce0514e 100644
--- a/docs/Phaser.Easing.Cubic.html
+++ b/docs/Phaser.Easing.Cubic.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Elastic.html b/docs/Phaser.Easing.Elastic.html
index dd576741..09e907af 100644
--- a/docs/Phaser.Easing.Elastic.html
+++ b/docs/Phaser.Easing.Elastic.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Exponential.html b/docs/Phaser.Easing.Exponential.html
index 45c14e65..288e667a 100644
--- a/docs/Phaser.Easing.Exponential.html
+++ b/docs/Phaser.Easing.Exponential.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Linear.html b/docs/Phaser.Easing.Linear.html
index 4e57b3d0..d8cdde5b 100644
--- a/docs/Phaser.Easing.Linear.html
+++ b/docs/Phaser.Easing.Linear.html
@@ -755,7 +755,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Quadratic.html b/docs/Phaser.Easing.Quadratic.html
index f78d7388..66e0124f 100644
--- a/docs/Phaser.Easing.Quadratic.html
+++ b/docs/Phaser.Easing.Quadratic.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Quartic.html b/docs/Phaser.Easing.Quartic.html
index 4a34dab2..a3230a0c 100644
--- a/docs/Phaser.Easing.Quartic.html
+++ b/docs/Phaser.Easing.Quartic.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Quintic.html b/docs/Phaser.Easing.Quintic.html
index a81af0e9..560d6eb7 100644
--- a/docs/Phaser.Easing.Quintic.html
+++ b/docs/Phaser.Easing.Quintic.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.Sinusoidal.html b/docs/Phaser.Easing.Sinusoidal.html
index ff000306..b3baf6c7 100644
--- a/docs/Phaser.Easing.Sinusoidal.html
+++ b/docs/Phaser.Easing.Sinusoidal.html
@@ -1037,7 +1037,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Easing.html b/docs/Phaser.Easing.html
index cf176139..a919ad22 100644
--- a/docs/Phaser.Easing.html
+++ b/docs/Phaser.Easing.html
@@ -647,7 +647,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:25 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:37 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Ellipse.html b/docs/Phaser.Ellipse.html
index cda99152..3337ffff 100644
--- a/docs/Phaser.Ellipse.html
+++ b/docs/Phaser.Ellipse.html
@@ -2792,7 +2792,7 @@ If set to true it will reset all of the Ellipse objects properties to 0. An Elli
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Events.html b/docs/Phaser.Events.html
index 404b7863..4df74403 100644
--- a/docs/Phaser.Events.html
+++ b/docs/Phaser.Events.html
@@ -661,7 +661,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Filter.html b/docs/Phaser.Filter.html
index f975ddf0..222b9b74 100644
--- a/docs/Phaser.Filter.html
+++ b/docs/Phaser.Filter.html
@@ -1946,7 +1946,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Frame.html b/docs/Phaser.Frame.html
index 24f17f94..b6835adc 100644
--- a/docs/Phaser.Frame.html
+++ b/docs/Phaser.Frame.html
@@ -3175,7 +3175,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:26 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:38 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.FrameData.html b/docs/Phaser.FrameData.html
index 7291c13f..04992b6b 100644
--- a/docs/Phaser.FrameData.html
+++ b/docs/Phaser.FrameData.html
@@ -1969,7 +1969,7 @@ The frames are returned in the output array, or if none is provided in a new Arr
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:39 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Game.html b/docs/Phaser.Game.html
index 7dacceb9..e1449568 100644
--- a/docs/Phaser.Game.html
+++ b/docs/Phaser.Game.html
@@ -3090,7 +3090,7 @@ When a game is paused the onPause event is dispatched. When it is resumed the on
@@ -5798,7 +5798,7 @@ This is extremely useful to hard to track down errors! Use the internal stepCoun
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:39 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.GameObjectCreator.html b/docs/Phaser.GameObjectCreator.html
index 445486d7..940766a5 100644
--- a/docs/Phaser.GameObjectCreator.html
+++ b/docs/Phaser.GameObjectCreator.html
@@ -5530,7 +5530,7 @@ It can still rotate, scale, crop and receive input events. This makes it perfect
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:39 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.GameObjectFactory.html b/docs/Phaser.GameObjectFactory.html
index 00e0947d..e4da5ccf 100644
--- a/docs/Phaser.GameObjectFactory.html
+++ b/docs/Phaser.GameObjectFactory.html
@@ -5952,7 +5952,7 @@ It can still rotate, scale, crop and receive input events. This makes it perfect
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:39 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Gamepad.html b/docs/Phaser.Gamepad.html
index 7659cb05..3450467e 100644
--- a/docs/Phaser.Gamepad.html
+++ b/docs/Phaser.Gamepad.html
@@ -3294,7 +3294,7 @@ This MUST be called manually before Phaser will start polling the Gamepad API.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:39 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.GamepadButton.html b/docs/Phaser.GamepadButton.html
index 10cd7f77..4a017fcc 100644
--- a/docs/Phaser.GamepadButton.html
+++ b/docs/Phaser.GamepadButton.html
@@ -1159,7 +1159,7 @@ If the button is up it holds the duration of the previous down session.
Default Value:
-
false
+
true
@@ -2614,7 +2614,7 @@ If the button is up it holds the duration of the previous down session.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:39 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Graphics.html b/docs/Phaser.Graphics.html
index 90dcf7dd..387c3c58 100644
--- a/docs/Phaser.Graphics.html
+++ b/docs/Phaser.Graphics.html
@@ -1892,7 +1892,7 @@ Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:39 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Group.html b/docs/Phaser.Group.html
index 739cda62..a9ce977b 100644
--- a/docs/Phaser.Group.html
+++ b/docs/Phaser.Group.html
@@ -9216,7 +9216,7 @@ You cannot swap a child with itself, or swap un-parented children, doing so will
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:27 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:40 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Image.html b/docs/Phaser.Image.html
index 8d104257..25b662a1 100644
--- a/docs/Phaser.Image.html
+++ b/docs/Phaser.Image.html
@@ -3969,7 +3969,7 @@ It will dispatch the onRevived event, you can listen to Image.events.onRevived f
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:28 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:40 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Input.html b/docs/Phaser.Input.html
index 5d60b167..ee062205 100644
--- a/docs/Phaser.Input.html
+++ b/docs/Phaser.Input.html
@@ -4521,7 +4521,7 @@ If you need to disable just one type of input; for example mouse; use Input.mous
@@ -7725,7 +7725,7 @@ to only use if you've limited input to a single pointer (i.e. mouse or touch)
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:28 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:40 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.InputHandler.html b/docs/Phaser.InputHandler.html
index 46d72ae1..0560a869 100644
--- a/docs/Phaser.InputHandler.html
+++ b/docs/Phaser.InputHandler.html
@@ -8038,7 +8038,7 @@ This value is only set when the pointer is over this Sprite.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:28 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:40 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Key.html b/docs/Phaser.Key.html
index d2bcf38c..444aec37 100644
--- a/docs/Phaser.Key.html
+++ b/docs/Phaser.Key.html
@@ -1267,7 +1267,7 @@ If the key is up it holds the duration of the previous down session.
Default Value:
-
false
+
true
@@ -2604,7 +2604,7 @@ If the key is up it holds the duration of the previous down session.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:28 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:40 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Keyboard.html b/docs/Phaser.Keyboard.html
index 01f67f65..2d074cb1 100644
--- a/docs/Phaser.Keyboard.html
+++ b/docs/Phaser.Keyboard.html
@@ -3031,7 +3031,7 @@ This is called automatically by Phaser.Input and should not normally be invoked
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:28 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:40 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Line.html b/docs/Phaser.Line.html
index daeec541..3dffaf4a 100644
--- a/docs/Phaser.Line.html
+++ b/docs/Phaser.Line.html
@@ -3127,7 +3127,7 @@ Returns the intersection segment of AB and EF as a Point, or null if there is no
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:28 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:41 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.LinkedList.html b/docs/Phaser.LinkedList.html
index 96159673..766fd96d 100644
--- a/docs/Phaser.LinkedList.html
+++ b/docs/Phaser.LinkedList.html
@@ -1523,7 +1523,7 @@ The function must exist on the member.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:29 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:41 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Loader.html b/docs/Phaser.Loader.html
index 28c248c0..ced7c3a8 100644
--- a/docs/Phaser.Loader.html
+++ b/docs/Phaser.Loader.html
@@ -2307,7 +2307,7 @@ If you do so the Sprites width or height will be cropped based on the percentage
@@ -6204,7 +6435,7 @@ The data must be in Lime + Corona JSON format. Physics Editor by code'n'web expo
You can set a Sprite to be a "preload" sprite by passing it to this method.
A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time.
-This allows you to easily make loading bars for games.
+This allows you to easily make loading bars for games. Note that Sprite.visible = true will be set when calling this.
@@ -6249,6 +6480,9 @@ This allows you to easily make loading bars for games.
Phaser.Sprite
+|
+
+Phaser.Image
@@ -6697,7 +6931,7 @@ This allows you to easily make loading bars for games.
@@ -7643,7 +7877,7 @@ This allows you to easily make loading bars for games.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:29 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:41 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.LoaderParser.html b/docs/Phaser.LoaderParser.html
index 97e159ce..4ff486c9 100644
--- a/docs/Phaser.LoaderParser.html
+++ b/docs/Phaser.LoaderParser.html
@@ -778,7 +778,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:29 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:41 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.MSPointer.html b/docs/Phaser.MSPointer.html
index e01070ed..f583663d 100644
--- a/docs/Phaser.MSPointer.html
+++ b/docs/Phaser.MSPointer.html
@@ -1473,7 +1473,7 @@ It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 a
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:29 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Math.html b/docs/Phaser.Math.html
index 42e9587f..38f5852c 100644
--- a/docs/Phaser.Math.html
+++ b/docs/Phaser.Math.html
@@ -11975,7 +11975,7 @@ Should be called whenever the angle is updated on the Sprite to stop it from goi
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:29 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:41 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Mouse.html b/docs/Phaser.Mouse.html
index 315fe8fb..1d60bce0 100644
--- a/docs/Phaser.Mouse.html
+++ b/docs/Phaser.Mouse.html
@@ -2790,7 +2790,7 @@ If the browser successfully enters a locked state the event Phaser.Mouse.pointer
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:29 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:41 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Net.html b/docs/Phaser.Net.html
index 9aa65a27..4565129e 100644
--- a/docs/Phaser.Net.html
+++ b/docs/Phaser.Net.html
@@ -1417,7 +1417,7 @@ Optionally you can redirect to the new url, or just return it as a string.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:29 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Particles.Arcade.Emitter.html b/docs/Phaser.Particles.Arcade.Emitter.html
index 6b69c8de..90b1ccb6 100644
--- a/docs/Phaser.Particles.Arcade.Emitter.html
+++ b/docs/Phaser.Particles.Arcade.Emitter.html
@@ -13351,7 +13351,7 @@ You cannot swap a child with itself, or swap un-parented children, doing so will
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:30 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Particles.html b/docs/Phaser.Particles.html
index 4514734a..9623435c 100644
--- a/docs/Phaser.Particles.html
+++ b/docs/Phaser.Particles.html
@@ -1306,7 +1306,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:30 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.Arcade.Body.html b/docs/Phaser.Physics.Arcade.Body.html
deleted file mode 100644
index 9472bab6..00000000
--- a/docs/Phaser.Physics.Arcade.Body.html
+++ /dev/null
@@ -1,10195 +0,0 @@
-
-
-
-
-
- Phaser Class: Body
-
-
-
-
-
-
-
-
-
-
-
The Physics Body is linked to a single Sprite and defines properties that determine how the physics body is simulated.
-These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. In most cases, the properties are used to simulate physical effects.
-Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene.
This object is populated with boolean values when the Body collides with the World bounds or a Tile.
-For example if blocked.up is true then the Body cannot move up.
-
-
-
-
-
-
-
-
-
-
Properties:
-
-
-
-
-
-
-
-
Name
-
-
-
Type
-
-
-
-
-
-
Description
-
-
-
-
-
-
-
-
-
blocked
-
-
-
-
-
-object
-
-
-
-
-
-
-
-
-
-
An object containing on which faces this Body is blocked from moving, if any.
Set the checkCollision properties to control which directions collision is processed for this Body.
-For example checkCollision.up = false means it won't collide when the collision happened while moving up.
If set this callback will be fired whenever this Body is hit (on any face). It will send three parameters, the face it hit on, this Body and the Body that hit it.
A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
linearDamping is used to calculate friction on the body as it moves through the world. For example, this might be used to simulate air or water friction.
A Body set to rebound will exchange velocity with another Body during collision. Set to false to allow this body to be 'pushed' rather than exchange velocity.
This object is populated with boolean values when the Body collides with another.
-touching.up = true means the collision happened to the top of this Body for example.
Process a collision with the bottom face of this Body.
-Collision and separation can be further checked by setting a collideCallback.
-This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
-If the callback returns true then separation, rebounds and the touching flags will all be set.
-If it returns false this will be skipped and must be handled manually.
Process a collision with the left face of this Body.
-Collision and separation can be further checked by setting a collideCallback.
-This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
-If the callback returns true then separation, rebounds and the touching flags will all be set.
-If it returns false this will be skipped and must be handled manually.
Process a collision with the right face of this Body.
-Collision and separation can be further checked by setting a collideCallback.
-This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
-If the callback returns true then separation, rebounds and the touching flags will all be set.
-If it returns false this will be skipped and must be handled manually.
Process a collision with the top face of this Body.
-Collision and separation can be further checked by setting a collideCallback.
-This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
-If the callback returns true then separation, rebounds and the touching flags will all be set.
-If it returns false this will be skipped and must be handled manually.
True if the given Body was removed from this contact list, false if wasn't on it.
-
-
-
-
-
-
- Type
-
-
-
-boolean
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
reset(full)
-
-
-
-
-
-
-
-
Resets the Body motion values: velocity, acceleration, angularVelocity and angularAcceleration.
-Also resets the forces to defaults: gravity, bounce, minVelocity,maxVelocity, angularDrag, maxAngular, mass, friction and checkCollision if 'full' specified.
-
-
-
-
-
-
-
-
-
Parameters:
-
-
-
-
-
-
-
Name
-
-
-
Type
-
-
-
Argument
-
-
-
-
Default
-
-
-
Description
-
-
-
-
-
-
-
-
-
full
-
-
-
-
-
-boolean
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
-
A full reset clears down settings you may have set, such as gravity, bounce and drag. A non-full reset just clears motion values.
This separates this Body from the given Body unless a customSeparateCallback is set.
-It assumes they have already been overlap checked and the resulting overlap is stored in the SAT response.
True if the bodies were separated, false if not (for example checkCollide allows them to pass through)
-
-
-
-
-
-
- Type
-
-
-
-boolean
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
setCircle(radius, offsetX, offsetY)
-
-
-
-
-
-
-
-
Sets this Body to use a circle of the given radius for all collision.
-The Circle will be centered on the center of the Sprite by default, but can be adjusted via the Body.offset property and the setCircle x/y parameters.
-
-
-
-
-
-
-
-
-
Parameters:
-
-
-
-
-
-
-
Name
-
-
-
Type
-
-
-
Argument
-
-
-
-
Default
-
-
-
Description
-
-
-
-
-
-
-
-
-
radius
-
-
-
-
-
-number
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
The radius of this circle (in pixels)
-
-
-
-
-
-
-
offsetX
-
-
-
-
-
-number
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
The x amount the circle will be offset from the Sprites center.
-
-
-
-
-
-
-
offsetY
-
-
-
-
-
-number
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
The y amount the circle will be offset from the Sprites center.
Sets this Body to use a convex polygon for collision.
-The points are specified in a counter-clockwise direction and must create a convex polygon.
-Use Body.translate and/or Body.offset to re-position the polygon from the Sprite origin.
This can be an array of Vectors that form the polygon,
- a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be
- all the points of the polygon e.g. setPolygon(new SAT.Vector(), new SAT.Vector(), ...), or the
- arguments passed can be flat x,y values e.g. setPolygon(x,y, x,y, x,y, ...) where x and y are Numbers.
Sets this Body to use a rectangle for all collision.
-If you don't specify any parameters it will be sized to match the parent Sprites current width and height (including scale factor) and centered on the sprite.
-
-
-
-
-
-
-
-
-
Parameters:
-
-
-
-
-
-
-
Name
-
-
-
Type
-
-
-
Argument
-
-
-
-
-
Description
-
-
-
-
-
-
-
-
-
width
-
-
-
-
-
-number
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
The width of the rectangle. If not specified it will default to the width of the parent Sprite.
-
-
-
-
-
-
-
height
-
-
-
-
-
-number
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
The height of the rectangle. If not specified it will default to the height of the parent Sprite.
-
-
-
-
-
-
-
translateX
-
-
-
-
-
-number
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
The x amount the rectangle will be translated from the Sprites center.
-
-
-
-
-
-
-
translateY
-
-
-
-
-
-number
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
The y amount the rectangle will be translated from the Sprites center.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/Phaser.Physics.Arcade.html b/docs/Phaser.Physics.Arcade.html
index 423fc955..b4d9a961 100644
--- a/docs/Phaser.Physics.Arcade.html
+++ b/docs/Phaser.Physics.Arcade.html
@@ -8130,7 +8130,7 @@ One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) whi
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:30 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.Body.html b/docs/Phaser.Physics.Body.html
index 8632030f..99830afe 100644
--- a/docs/Phaser.Physics.Body.html
+++ b/docs/Phaser.Physics.Body.html
@@ -11849,7 +11849,7 @@ The speed is represented in pixels per second. So a value of 100 would move 100
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:30 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.CollisionGroup.html b/docs/Phaser.Physics.CollisionGroup.html
index 658142af..f9d68a97 100644
--- a/docs/Phaser.Physics.CollisionGroup.html
+++ b/docs/Phaser.Physics.CollisionGroup.html
@@ -718,7 +718,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:30 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.ContactMaterial.html b/docs/Phaser.Physics.ContactMaterial.html
index c7ed1202..9d8c9d37 100644
--- a/docs/Phaser.Physics.ContactMaterial.html
+++ b/docs/Phaser.Physics.ContactMaterial.html
@@ -735,7 +735,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:30 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.InversePointProxy.html b/docs/Phaser.Physics.InversePointProxy.html
index b15fd958..6bccc24c 100644
--- a/docs/Phaser.Physics.InversePointProxy.html
+++ b/docs/Phaser.Physics.InversePointProxy.html
@@ -892,7 +892,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.Material.html b/docs/Phaser.Physics.Material.html
index f1df5d18..f397e671 100644
--- a/docs/Phaser.Physics.Material.html
+++ b/docs/Phaser.Physics.Material.html
@@ -721,7 +721,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.PointProxy.html b/docs/Phaser.Physics.PointProxy.html
index d02d81c5..13a99cd7 100644
--- a/docs/Phaser.Physics.PointProxy.html
+++ b/docs/Phaser.Physics.PointProxy.html
@@ -892,7 +892,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.Spring.html b/docs/Phaser.Physics.Spring.html
index 9e49ed45..2dbb280d 100644
--- a/docs/Phaser.Physics.Spring.html
+++ b/docs/Phaser.Physics.Spring.html
@@ -1118,7 +1118,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.World.html b/docs/Phaser.Physics.World.html
index 1d1c5eb9..ef6d1f9d 100644
--- a/docs/Phaser.Physics.World.html
+++ b/docs/Phaser.Physics.World.html
@@ -7455,7 +7455,7 @@ You can optionally set which 'walls' to create: left, right, top or bottom.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Physics.html b/docs/Phaser.Physics.html
index b43c6356..79274a31 100644
--- a/docs/Phaser.Physics.html
+++ b/docs/Phaser.Physics.html
@@ -2083,7 +2083,7 @@ You can optionally set which 'walls' to create: left, right, top or bottom.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:30 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:42 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Plugin.html b/docs/Phaser.Plugin.html
index 93e78c8a..d1451400 100644
--- a/docs/Phaser.Plugin.html
+++ b/docs/Phaser.Plugin.html
@@ -1980,7 +1980,7 @@ It is only called if active is set to true.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:43 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.PluginManager.html b/docs/Phaser.PluginManager.html
index 9bcb5f32..cc5baf3b 100644
--- a/docs/Phaser.PluginManager.html
+++ b/docs/Phaser.PluginManager.html
@@ -1645,7 +1645,7 @@ It only calls plugins who have active=true.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Point.html b/docs/Phaser.Point.html
index 8a39d141..24efa0e4 100644
--- a/docs/Phaser.Point.html
+++ b/docs/Phaser.Point.html
@@ -5505,7 +5505,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Pointer.html b/docs/Phaser.Pointer.html
index 2bf4fc01..5858b5f5 100644
--- a/docs/Phaser.Pointer.html
+++ b/docs/Phaser.Pointer.html
@@ -4483,7 +4483,7 @@ If you wish to check if the Pointer was released just once then see the Sprite.e
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:31 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Polygon.html b/docs/Phaser.Polygon.html
index bfba0ab3..33f4215d 100644
--- a/docs/Phaser.Polygon.html
+++ b/docs/Phaser.Polygon.html
@@ -1138,7 +1138,7 @@ arguments passed can be flat x,y values e.g. new Phaser.Polygon(x,y, x,y,
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.QuadTree.html b/docs/Phaser.QuadTree.html
deleted file mode 100644
index 845733ae..00000000
--- a/docs/Phaser.QuadTree.html
+++ /dev/null
@@ -1,1709 +0,0 @@
-
-
-
-
-
- Phaser Class: QuadTree
-
-
-
-
-
-
-
-
-
-
-
A QuadTree 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/
-
-
-
-
-
-
-
-
-
-
-
new QuadTree(x, y, width, height, maxObjects, maxLevels, level)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/Phaser.RandomDataGenerator.html b/docs/Phaser.RandomDataGenerator.html
index 1abc018c..0920b7b0 100644
--- a/docs/Phaser.RandomDataGenerator.html
+++ b/docs/Phaser.RandomDataGenerator.html
@@ -2111,7 +2111,7 @@ Random number generator from
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Rectangle.html b/docs/Phaser.Rectangle.html
index ec1300ea..ed4cd879 100644
--- a/docs/Phaser.Rectangle.html
+++ b/docs/Phaser.Rectangle.html
@@ -7708,7 +7708,7 @@ This method checks the x, y, width, and height properties of the Rectangles.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.RenderTexture.html b/docs/Phaser.RenderTexture.html
index 95788e6d..b8abd193 100644
--- a/docs/Phaser.RenderTexture.html
+++ b/docs/Phaser.RenderTexture.html
@@ -1620,7 +1620,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.RequestAnimationFrame.html b/docs/Phaser.RequestAnimationFrame.html
index f4611c86..d618ecdd 100644
--- a/docs/Phaser.RequestAnimationFrame.html
+++ b/docs/Phaser.RequestAnimationFrame.html
@@ -1534,7 +1534,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:44 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Signal.html b/docs/Phaser.Signal.html
index 18afda0b..1075e446 100644
--- a/docs/Phaser.Signal.html
+++ b/docs/Phaser.Signal.html
@@ -2362,7 +2362,7 @@ IMPORTANT: should be called only during signal dispatch, calling it before/after
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:45 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.SinglePad.html b/docs/Phaser.SinglePad.html
index 251dff3a..1b45fbb0 100644
--- a/docs/Phaser.SinglePad.html
+++ b/docs/Phaser.SinglePad.html
@@ -3991,7 +3991,7 @@ analog trigger buttons on the XBOX 360 controller
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:45 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Sound.html b/docs/Phaser.Sound.html
index e5f9ed40..ee8690d4 100644
--- a/docs/Phaser.Sound.html
+++ b/docs/Phaser.Sound.html
@@ -5873,7 +5873,7 @@ This allows you to bundle multiple sounds together into a single audio file and
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:32 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:45 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.SoundManager.html b/docs/Phaser.SoundManager.html
index 55cac110..b9a44303 100644
--- a/docs/Phaser.SoundManager.html
+++ b/docs/Phaser.SoundManager.html
@@ -1143,7 +1143,7 @@ Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:conf
@@ -2514,45 +2514,6 @@ Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:conf
-
-
-
-
destroyOnComplete
-
-
-
-
-
-boolean
-
-
-
-
-
-
-
-
- <optional>
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
-
If true the Sound will destroy itself once it has finished playing, or is stopped.
-
-
-
@@ -2931,7 +2892,7 @@ Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:conf
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:33 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:45 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Sprite.html b/docs/Phaser.Sprite.html
index 8475e04b..55e15a09 100644
--- a/docs/Phaser.Sprite.html
+++ b/docs/Phaser.Sprite.html
@@ -5348,7 +5348,7 @@ It will dispatch the onRevived event, you can listen to Sprite.events.onRevived
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:33 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:45 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.SpriteBatch.html b/docs/Phaser.SpriteBatch.html
index 35553d3d..29500248 100644
--- a/docs/Phaser.SpriteBatch.html
+++ b/docs/Phaser.SpriteBatch.html
@@ -9199,7 +9199,7 @@ You cannot swap a child with itself, or swap un-parented children, doing so will
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:33 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:45 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Stage.html b/docs/Phaser.Stage.html
index 3e0a12ad..729433cf 100644
--- a/docs/Phaser.Stage.html
+++ b/docs/Phaser.Stage.html
@@ -780,7 +780,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
@@ -1975,7 +2044,7 @@ Most objects have preUpdate methods and it's where initial movement and position
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:33 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:45 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.StageScaleMode.html b/docs/Phaser.StageScaleMode.html
index ef73be97..affdd587 100644
--- a/docs/Phaser.StageScaleMode.html
+++ b/docs/Phaser.StageScaleMode.html
@@ -5264,7 +5264,7 @@ Please note that this needs to be supported by the web browser and isn't the sam
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:33 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:46 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.State.html b/docs/Phaser.State.html
index 2344d187..e2cf2223 100644
--- a/docs/Phaser.State.html
+++ b/docs/Phaser.State.html
@@ -2642,7 +2642,7 @@ If you need to use the loader, you may need to use them here.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:33 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:46 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.StateManager.html b/docs/Phaser.StateManager.html
index 4cf5f866..fadbd1c5 100644
--- a/docs/Phaser.StateManager.html
+++ b/docs/Phaser.StateManager.html
@@ -1709,6 +1709,108 @@
+
+
+
+
+
+
+
+
+
+
onResumedCallback
+
+
+
+
+
+
+
+
+
+
+
+
+
Properties:
+
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
+
+
+
Description
+
+
+
+
+
+
+
+
+
onResumedCallback
+
+
+
+
+
+function
+
+
+
+
+
+
+
+
+
+
This will be called when the state is resumed from a paused state.
@@ -3346,7 +3448,7 @@ State must exist and have at least one callback function registered..
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:46 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Text.html b/docs/Phaser.Text.html
index 584e5b3b..16e1cd43 100644
--- a/docs/Phaser.Text.html
+++ b/docs/Phaser.Text.html
@@ -4404,7 +4404,7 @@ activated for this object and it will then start to process click/touch events a
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:46 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Tile.html b/docs/Phaser.Tile.html
index 4d1a6ec1..cc8fa8a3 100644
--- a/docs/Phaser.Tile.html
+++ b/docs/Phaser.Tile.html
@@ -4039,7 +4039,7 @@ The callback must true true for collision processing to take place.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:46 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.TileSprite.html b/docs/Phaser.TileSprite.html
index a692a5d9..eacb38d2 100644
--- a/docs/Phaser.TileSprite.html
+++ b/docs/Phaser.TileSprite.html
@@ -881,7 +881,7 @@ If you wish to work in radians instead of degrees use the property Sprite.rotati
By default a TileSprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
+activated for this object and it will then start to process click/touch events and more.
+
+
+
+
+
+
+
+
+
+
Properties:
+
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
+
+
+
Description
+
+
+
+
+
+
+
+
+
inputEnabled
+
+
+
+
+
+boolean
+
+
+
+
+
+
+
+
+
+
Set to true to allow this object to receive input events.
@@ -2912,7 +3124,7 @@ If the requested animation is already playing this request will be ignored. If y
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Tilemap.html b/docs/Phaser.Tilemap.html
index 53b74e55..62195fad 100644
--- a/docs/Phaser.Tilemap.html
+++ b/docs/Phaser.Tilemap.html
@@ -10995,7 +10995,7 @@ If you want to set a callback for a tile at a specific location on the map then
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:46 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.TilemapLayer.html b/docs/Phaser.TilemapLayer.html
index 3ee341c3..ba0185ec 100644
--- a/docs/Phaser.TilemapLayer.html
+++ b/docs/Phaser.TilemapLayer.html
@@ -4674,7 +4674,7 @@ half as quickly as the 'normal' camera-locked layers do)
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.TilemapParser.html b/docs/Phaser.TilemapParser.html
index f6f5793d..409618c3 100644
--- a/docs/Phaser.TilemapParser.html
+++ b/docs/Phaser.TilemapParser.html
@@ -1609,7 +1609,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Tileset.html b/docs/Phaser.Tileset.html
index 557a06a2..80b1e4a4 100644
--- a/docs/Phaser.Tileset.html
+++ b/docs/Phaser.Tileset.html
@@ -2676,7 +2676,7 @@ You should not normally instantiate this class directly.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:34 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Time.html b/docs/Phaser.Time.html
index 543419d3..60996890 100644
--- a/docs/Phaser.Time.html
+++ b/docs/Phaser.Time.html
@@ -3156,7 +3156,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Timer.html b/docs/Phaser.Timer.html
index 72e43077..edbe1c64 100644
--- a/docs/Phaser.Timer.html
+++ b/docs/Phaser.Timer.html
@@ -3820,7 +3820,7 @@ If the Timer is already running the delay will be calculated based on the timers
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.TimerEvent.html b/docs/Phaser.TimerEvent.html
index 68696d96..71f6e8d5 100644
--- a/docs/Phaser.TimerEvent.html
+++ b/docs/Phaser.TimerEvent.html
@@ -1745,7 +1745,7 @@ It can call a specific callback, passing in optional parameters.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Touch.html b/docs/Phaser.Touch.html
index 5f77cf04..c57d48e3 100644
--- a/docs/Phaser.Touch.html
+++ b/docs/Phaser.Touch.html
@@ -2715,7 +2715,7 @@ Doesn't appear to be supported by most browsers on a canvas element yet.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Tween.html b/docs/Phaser.Tween.html
index 1c051b46..3428ebc5 100644
--- a/docs/Phaser.Tween.html
+++ b/docs/Phaser.Tween.html
@@ -3204,7 +3204,7 @@ Used in combination with repeat you can create endless loops.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:48 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.TweenManager.html b/docs/Phaser.TweenManager.html
index 0a9df269..56b95513 100644
--- a/docs/Phaser.TweenManager.html
+++ b/docs/Phaser.TweenManager.html
@@ -1708,7 +1708,7 @@ Please see https://github.com/sole/tw
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:48 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Utils.Debug.html b/docs/Phaser.Utils.Debug.html
index ecec4f96..44677928 100644
--- a/docs/Phaser.Utils.Debug.html
+++ b/docs/Phaser.Utils.Debug.html
@@ -1986,7 +1986,7 @@ your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL
@@ -7140,7 +7140,7 @@ your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:48 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.Utils.html b/docs/Phaser.Utils.html
index 7e61abb8..54cf0b2f 100644
--- a/docs/Phaser.Utils.html
+++ b/docs/Phaser.Utils.html
@@ -1333,7 +1333,7 @@ dir = 1 (left), 2 (right), 3 (both)
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:35 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:48 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.World.html b/docs/Phaser.World.html
index 00366e5b..c0d0973d 100644
--- a/docs/Phaser.World.html
+++ b/docs/Phaser.World.html
@@ -10182,7 +10182,7 @@ You cannot swap a child with itself, or swap un-parented children, doing so will
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:36 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:48 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.html b/docs/Phaser.html
index 2dbbe412..1b8bd313 100644
--- a/docs/Phaser.html
+++ b/docs/Phaser.html
@@ -810,7 +810,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Phaser.js.html b/docs/Phaser.js.html
index 4490ca6b..6d44c50f 100644
--- a/docs/Phaser.js.html
+++ b/docs/Phaser.js.html
@@ -590,7 +590,7 @@ PIXI.InteractionManager = function (dummy) {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Plugin.js.html b/docs/Plugin.js.html
index f40ede86..ba57b9ab 100644
--- a/docs/Plugin.js.html
+++ b/docs/Plugin.js.html
@@ -633,7 +633,7 @@ Phaser.Plugin.prototype.constructor = Phaser.Plugin;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/PluginManager.js.html b/docs/PluginManager.js.html
index f0d45c44..fb140a30 100644
--- a/docs/PluginManager.js.html
+++ b/docs/PluginManager.js.html
@@ -809,7 +809,7 @@ Phaser.PluginManager.prototype.constructor = Phaser.PluginManager;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Point.js.html b/docs/Point.js.html
index 3eb655a9..35a20115 100644
--- a/docs/Point.js.html
+++ b/docs/Point.js.html
@@ -969,7 +969,7 @@ PIXI.Point = Phaser.Point;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/PointProxy.js.html b/docs/PointProxy.js.html
index e5ba42ca..a04d40aa 100644
--- a/docs/PointProxy.js.html
+++ b/docs/PointProxy.js.html
@@ -573,7 +573,7 @@ Object.defineProperty(Phaser.Physics.PointProxy.prototype, "y", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Pointer.js.html b/docs/Pointer.js.html
index fd02125f..6b6cacac 100644
--- a/docs/Pointer.js.html
+++ b/docs/Pointer.js.html
@@ -1156,7 +1156,7 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Polygon.js.html b/docs/Polygon.js.html
index 40673184..b1f61d60 100644
--- a/docs/Polygon.js.html
+++ b/docs/Polygon.js.html
@@ -620,7 +620,7 @@ PIXI.Polygon = Phaser.Polygon;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/QuadTree.js.html b/docs/QuadTree.js.html
deleted file mode 100644
index 95f7c93a..00000000
--- a/docs/QuadTree.js.html
+++ /dev/null
@@ -1,808 +0,0 @@
-
-
-
-
-
- Phaser Source: math/QuadTree.js
-
-
-
-
-
-
-
-
-
-
-
// Version 0.2 - Copyright 2013 - Jim Riecken <jimr@jimr.ca>
-//
-// Released under the MIT License - https://github.com/jriecken/sat-js
-//
-// A simple library for determining intersections of circles and
-// polygons using the Separating Axis Theorem.
-/** @preserve SAT.js - Version 0.2 - Copyright 2013 - Jim Riecken <jimr@jimr.ca> - released under the MIT License. https://github.com/jriecken/sat-js */
-
-/*global define: false, module: false*/
-/*jshint shadow:true, sub:true, forin:true, noarg:true, noempty:true,
- eqeqeq:true, bitwise:true, strict:true, undef:true,
- curly:true, browser:true */
-
-// Create a UMD wrapper for SAT. Works in:
-//
-// - Plain browser via global SAT variable
-// - AMD loader (like require.js)
-// - Node.js
-//
-// The quoted properties all over the place are used so that the Closure Compiler
-// does not mangle the exposed API in advanced mode.
-/**
- * @param {*} root - The global scope
- * @param {Function} factory - Factory that creates SAT module
- */
-(function (root, factory) {
- "use strict";
- if (typeof define === 'function' && define['amd']) {
- define(factory);
- } else if (typeof exports === 'object') {
- module['exports'] = factory();
- } else {
- root['SAT'] = factory();
- }
-}(this, function () {
- "use strict";
-
- var SAT = {};
-
- //
- // ## Vector
- //
- // Represents a vector in two dimensions with `x` and `y` properties.
-
-
- // Create a new Vector, optionally passing in the `x` and `y` coordinates. If
- // a coordinate is not specified, it will be set to `0`
- /**
- * @param {?number=} x The x position.
- * @param {?number=} y The y position.
- * @constructor
- */
- function Vector(x, y) {
- this['x'] = x || 0;
- this['y'] = y || 0;
- }
- SAT['Vector'] = Vector;
- // Alias `Vector` as `V`
- SAT['V'] = Vector;
-
-
- // Copy the values of another Vector into this one.
- /**
- * @param {Vector} other The other Vector.
- * @return {Vector} This for chaining.
- */
- Vector.prototype['copy'] = Vector.prototype.copy = function(other) {
- this['x'] = other['x'];
- this['y'] = other['y'];
- return this;
- };
-
- // Change this vector to be perpendicular to what it was before. (Effectively
- // roatates it 90 degrees in a clockwise direction)
- /**
- * @return {Vector} This for chaining.
- */
- Vector.prototype['perp'] = Vector.prototype.perp = function() {
- var x = this['x'];
- this['x'] = this['y'];
- this['y'] = -x;
- return this;
- };
-
- // Rotate this vector (counter-clockwise) by the specified angle (in radians).
- /**
- * @param {number} angle The angle to rotate (in radians)
- * @return {Vector} This for chaining.
- */
- Vector.prototype['rotate'] = Vector.prototype.rotate = function (angle) {
- var x = this['x'];
- var y = this['y'];
- this['x'] = x * Math.cos(angle) - y * Math.sin(angle);
- this['y'] = x * Math.sin(angle) + y * Math.cos(angle);
- return this;
- };
-
- // Rotate this vector (counter-clockwise) by the specified angle (in radians) which has already been calculated into sin and cos.
- /**
- * @param {number} sin - The Math.sin(angle)
- * @param {number} cos - The Math.cos(angle)
- * @return {Vector} This for chaining.
- */
- Vector.prototype['rotatePrecalc'] = Vector.prototype.rotatePrecalc = function (sin, cos) {
- var x = this['x'];
- var y = this['y'];
- this['x'] = x * cos - y * sin;
- this['y'] = x * sin + y * cos;
- return this;
- };
-
- // Reverse this vector.
- /**
- * @return {Vector} This for chaining.
- */
- Vector.prototype['reverse'] = Vector.prototype.reverse = function() {
- this['x'] = -this['x'];
- this['y'] = -this['y'];
- return this;
- };
-
-
- // Normalize this vector. (make it have length of `1`)
- /**
- * @return {Vector} This for chaining.
- */
- Vector.prototype['normalize'] = Vector.prototype.normalize = function() {
- var d = this.len();
- if(d > 0) {
- this['x'] = this['x'] / d;
- this['y'] = this['y'] / d;
- }
- return this;
- };
-
- // Add another vector to this one.
- /**
- * @param {Vector} other The other Vector.
- * @return {Vector} This for chaining.
- */
- Vector.prototype['add'] = Vector.prototype.add = function(other) {
- this['x'] += other['x'];
- this['y'] += other['y'];
- return this;
- };
-
- // Subtract another vector from this one.
- /**
- * @param {Vector} other The other Vector.
- * @return {Vector} This for chaiing.
- */
- Vector.prototype['sub'] = Vector.prototype.sub = function(other) {
- this['x'] -= other['x'];
- this['y'] -= other['y'];
- return this;
- };
-
- // Scale this vector. An independant scaling factor can be provided
- // for each axis, or a single scaling factor that will scale both `x` and `y`.
- /**
- * @param {number} x The scaling factor in the x direction.
- * @param {?number=} y The scaling factor in the y direction. If this
- * is not specified, the x scaling factor will be used.
- * @return {Vector} This for chaining.
- */
- Vector.prototype['scale'] = Vector.prototype.scale = function(x,y) {
- this['x'] *= x;
- this['y'] *= y || x;
- return this;
- };
-
- // Project this vector on to another vector.
- /**
- * @param {Vector} other The vector to project onto.
- * @return {Vector} This for chaining.
- */
- Vector.prototype['project'] = Vector.prototype.project = function(other) {
- var amt = this.dot(other) / other.len2();
- this['x'] = amt * other['x'];
- this['y'] = amt * other['y'];
- return this;
- };
-
- // Project this vector onto a vector of unit length. This is slightly more efficient
- // than `project` when dealing with unit vectors.
- /**
- * @param {Vector} other The unit vector to project onto.
- * @return {Vector} This for chaining.
- */
- Vector.prototype['projectN'] = Vector.prototype.projectN = function(other) {
- var amt = this.dot(other);
- this['x'] = amt * other['x'];
- this['y'] = amt * other['y'];
- return this;
- };
-
- // Reflect this vector on an arbitrary axis.
- /**
- * @param {Vector} axis The vector representing the axis.
- * @return {Vector} This for chaining.
- */
- Vector.prototype['reflect'] = Vector.prototype.reflect = function(axis) {
- var x = this['x'];
- var y = this['y'];
- this.project(axis).scale(2);
- this['x'] -= x;
- this['y'] -= y;
- return this;
- };
-
- // Reflect this vector on an arbitrary axis (represented by a unit vector). This is
- // slightly more efficient than `reflect` when dealing with an axis that is a unit vector.
- /**
- * @param {Vector} axis The unit vector representing the axis.
- * @return {Vector} This for chaining.
- */
- Vector.prototype['reflectN'] = Vector.prototype.reflectN = function(axis) {
- var x = this['x'];
- var y = this['y'];
- this.projectN(axis).scale(2);
- this['x'] -= x;
- this['y'] -= y;
- return this;
- };
-
- // Get the dot product of this vector and another.
- /**
- * @param {Vector} other The vector to dot this one against.
- * @return {number} The dot product.
- */
- Vector.prototype['dot'] = Vector.prototype.dot = function(other) {
- return this['x'] * other['x'] + this['y'] * other['y'];
- };
-
- // Get the squared length of this vector.
- /**
- * @return {number} The length^2 of this vector.
- */
- Vector.prototype['len2'] = Vector.prototype.len2 = function() {
- return this.dot(this);
- };
-
- // Get the length of this vector.
- /**
- * @return {number} The length of this vector.
- */
- Vector.prototype['len'] = Vector.prototype.len = function() {
- return Math.sqrt(this.len2());
- };
-
- // ## Circle
- //
- // Represents a circle with a position and a radius.
-
- // Create a new circle, optionally passing in a position and/or radius. If no position
- // is given, the circle will be at `(0,0)`. If no radius is provided, the circle will
- // have a radius of `0`.
- /**
- * @param {Vector=} pos A vector representing the position of the center of the circle
- * @param {?number=} r The radius of the circle
- * @constructor
- */
- function Circle(pos, r) {
- this['pos'] = pos || new Vector();
- this['r'] = r || 0;
- }
- SAT['Circle'] = Circle;
-
- // ## Polygon
- //
- // Represents a *convex* polygon with any number of points (specified in counter-clockwise order)
- //
- // The edges/normals of the polygon will be calculated on creation and stored in the
- // `edges` and `normals` properties. If you change the polygon's points, you will need
- // to call `recalc` to recalculate the edges/normals.
-
- // Create a new polygon, passing in a position vector, and an array of points (represented
- // by vectors relative to the position vector). If no position is passed in, the position
- // of the polygon will be `(0,0)`.
- /**
- * @param {Vector=} pos A vector representing the origin of the polygon. (all other
- * points are relative to this one)
- * @param {Array.<Vector>=} points An array of vectors representing the points in the polygon,
- * in counter-clockwise order.
- * @constructor
- */
- function Polygon(pos, points) {
- this['pos'] = pos || new Vector();
- this['points'] = points || [];
- this.recalc();
- }
- SAT['Polygon'] = Polygon;
-
- // Recalculates the edges and normals of the polygon. This **must** be called
- // if the `points` array is modified at all and the edges or normals are to be
- // accessed.
- /**
- * @return {Polygon} This for chaining.
- */
- Polygon.prototype['recalc'] = Polygon.prototype.recalc = function() {
- // The edges here are the direction of the `n`th edge of the polygon, relative to
- // the `n`th point. If you want to draw a given edge from the edge value, you must
- // first translate to the position of the starting point.
- this['edges'] = [];
- // The normals here are the direction of the normal for the `n`th edge of the polygon, relative
- // to the position of the `n`th point. If you want to draw an edge normal, you must first
- // translate to the position of the starting point.
- this['normals'] = [];
- var points = this['points'];
- var len = points.length;
- for (var i = 0; i < len; i++) {
- var p1 = points[i];
- var p2 = i < len - 1 ? points[i + 1] : points[0];
- var e = new Vector().copy(p2).sub(p1);
- var n = new Vector().copy(e).perp().normalize();
- this['edges'].push(e);
- this['normals'].push(n);
- }
- return this;
- };
-
- // Rotates this polygon counter-clockwise around the origin of *its local coordinate system* (i.e. `pos`).
- //
- // Note: You do **not** need to call `recalc` after rotation.
- /**
- * @param {number} angle The angle to rotate (in radians)
- * @return {Polygon} This for chaining.
- */
- Polygon.prototype['rotate'] = Polygon.prototype.rotate = function(angle) {
- var i;
- var points = this['points'];
- var edges = this['edges'];
- var normals = this['normals'];
- var len = points.length;
-
- // Calc it just the once, rather than 4 times per array element
- var cos = Math.cos(angle);
- var sin = Math.sin(angle);
-
- for (i = 0; i < len; i++) {
- points[i].rotatePrecalc(sin, cos);
- edges[i].rotatePrecalc(sin, cos);
- normals[i].rotatePrecalc(sin, cos);
- }
- return this;
- };
-
- // Rotates this polygon counter-clockwise around the origin of *its local coordinate system* (i.e. `pos`).
- //
- // Note: You do **not** need to call `recalc` after rotation.
- /**
- * @param {number} angle The angle to rotate (in radians)
- * @return {Polygon} This for chaining.
- */
- Polygon.prototype['scale'] = Polygon.prototype.scale = function(x, y) {
- var i;
- var points = this['points'];
- var edges = this['edges'];
- var normals = this['normals'];
- var len = points.length;
- for (i = 0; i < len; i++) {
- points[i].scale(x,y);
- edges[i].scale(x,y);
- normals[i].scale(x,y);
- }
- return this;
- };
-
- // Translates the points of this polygon by a specified amount relative to the origin of *its own coordinate
- // system* (i.e. `pos`).
- //
- // This is most useful to change the "center point" of a polygon.
- //
- // Note: You do **not** need to call `recalc` after translation.
- /**
- * @param {number} x The horizontal amount to translate.
- * @param {number} y The vertical amount to translate.
- * @return {Polygon} This for chaining.
- */
- Polygon.prototype['translate'] = Polygon.prototype.translate = function (x, y) {
- var i;
- var points = this['points'];
- var len = points.length;
- for (i = 0; i < len; i++) {
- points[i].x += x;
- points[i].y += y;
- }
- return this;
- };
-
- // ## Box
- //
- // Represents an axis-aligned box, with a width and height.
-
-
- // Create a new box, with the specified position, width, and height. If no position
- // is given, the position will be `(0,0)`. If no width or height are given, they will
- // be set to `0`.
- /**
- * @param {Vector=} pos A vector representing the top-left of the box.
- * @param {?number=} w The width of the box.
- * @param {?number=} h The height of the box.
- * @constructor
- */
- function Box(pos, w, h) {
- this['pos'] = pos || new Vector();
- this['w'] = w || 0;
- this['h'] = h || 0;
- }
- SAT['Box'] = Box;
-
- // Returns a polygon whose edges are the same as this box.
- /**
- * @return {Polygon} A new Polygon that represents this box.
- */
- Box.prototype['toPolygon'] = Box.prototype.toPolygon = function() {
- var pos = this['pos'];
- var w = this['w'];
- var h = this['h'];
- return new Polygon(new Vector(pos['x'], pos['y']), [
- new Vector(), new Vector(w, 0),
- new Vector(w,h), new Vector(0,h)
- ]);
- };
-
- // ## Response
- //
- // An object representing the result of an intersection. Contains:
- // - The two objects participating in the intersection
- // - The vector representing the minimum change necessary to extract the first object
- // from the second one (as well as a unit vector in that direction and the magnitude
- // of the overlap)
- // - Whether the first object is entirely inside the second, and vice versa.
- /**
- * @constructor
- */
- function Response() {
- this['a'] = null;
- this['b'] = null;
- this['overlapN'] = new Vector();
- this['overlapV'] = new Vector();
- this.clear();
- }
- SAT['Response'] = Response;
-
- // Set some values of the response back to their defaults. Call this between tests if
- // you are going to reuse a single Response object for multiple intersection tests (recommented
- // as it will avoid allcating extra memory)
- /**
- * @return {Response} This for chaining
- */
- Response.prototype['clear'] = Response.prototype.clear = function() {
- this['aInB'] = true;
- this['bInA'] = true;
- this['overlap'] = Number.MAX_VALUE;
- return this;
- };
-
- // ## Object Pools
-
- // A pool of `Vector` objects that are used in calculations to avoid
- // allocating memory.
- /**
- * @type {Array.<Vector>}
- */
- var T_VECTORS = [];
- for (var i = 0; i < 10; i++) { T_VECTORS.push(new Vector()); }
-
- // A pool of arrays of numbers used in calculations to avoid allocating
- // memory.
- /**
- * @type {Array.<Array.<number>>}
- */
- var T_ARRAYS = [];
- for (var i = 0; i < 5; i++) { T_ARRAYS.push([]); }
-
- // ## Helper Functions
-
- // Flattens the specified array of points onto a unit vector axis,
- // resulting in a one dimensional range of the minimum and
- // maximum value on that axis.
- /**
- * @param {Array.<Vector>} points The points to flatten.
- * @param {Vector} normal The unit vector axis to flatten on.
- * @param {Array.<number>} result An array. After calling this function,
- * result[0] will be the minimum value,
- * result[1] will be the maximum value.
- */
- function flattenPointsOn(points, normal, result) {
- var min = Number.MAX_VALUE;
- var max = -Number.MAX_VALUE;
- var len = points.length;
- for (var i = 0; i < len; i++ ) {
- // The magnitude of the projection of the point onto the normal
- var dot = points[i].dot(normal);
- if (dot < min) { min = dot; }
- if (dot > max) { max = dot; }
- }
- result[0] = min; result[1] = max;
- }
-
- // Check whether two convex polygons are separated by the specified
- // axis (must be a unit vector).
- /**
- * @param {Vector} aPos The position of the first polygon.
- * @param {Vector} bPos The position of the second polygon.
- * @param {Array.<Vector>} aPoints The points in the first polygon.
- * @param {Array.<Vector>} bPoints The points in the second polygon.
- * @param {Vector} axis The axis (unit sized) to test against. The points of both polygons
- * will be projected onto this axis.
- * @param {Response=} response A Response object (optional) which will be populated
- * if the axis is not a separating axis.
- * @return {boolean} true if it is a separating axis, false otherwise. If false,
- * and a response is passed in, information about how much overlap and
- * the direction of the overlap will be populated.
- */
- function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
- var rangeA = T_ARRAYS.pop();
- var rangeB = T_ARRAYS.pop();
- // The magnitude of the offset between the two polygons
- var offsetV = T_VECTORS.pop().copy(bPos).sub(aPos);
- var projectedOffset = offsetV.dot(axis);
- // Project the polygons onto the axis.
- flattenPointsOn(aPoints, axis, rangeA);
- flattenPointsOn(bPoints, axis, rangeB);
- // Move B's range to its position relative to A.
- rangeB[0] += projectedOffset;
- rangeB[1] += projectedOffset;
- // Check if there is a gap. If there is, this is a separating axis and we can stop
- if (rangeA[0] > rangeB[1] || rangeB[0] > rangeA[1]) {
- T_VECTORS.push(offsetV);
- T_ARRAYS.push(rangeA);
- T_ARRAYS.push(rangeB);
- return true;
- }
- // This is not a separating axis. If we're calculating a response, calculate the overlap.
- if (response) {
- var overlap = 0;
- // A starts further left than B
- if (rangeA[0] < rangeB[0]) {
- response['aInB'] = false;
- // A ends before B does. We have to pull A out of B
- if (rangeA[1] < rangeB[1]) {
- overlap = rangeA[1] - rangeB[0];
- response['bInA'] = false;
- // B is fully inside A. Pick the shortest way out.
- } else {
- var option1 = rangeA[1] - rangeB[0];
- var option2 = rangeB[1] - rangeA[0];
- overlap = option1 < option2 ? option1 : -option2;
- }
- // B starts further left than A
- } else {
- response['bInA'] = false;
- // B ends before A ends. We have to push A out of B
- if (rangeA[1] > rangeB[1]) {
- overlap = rangeA[0] - rangeB[1];
- response['aInB'] = false;
- // A is fully inside B. Pick the shortest way out.
- } else {
- var option1 = rangeA[1] - rangeB[0];
- var option2 = rangeB[1] - rangeA[0];
- overlap = option1 < option2 ? option1 : -option2;
- }
- }
- // If this is the smallest amount of overlap we've seen so far, set it as the minimum overlap.
- var absOverlap = Math.abs(overlap);
- if (absOverlap < response['overlap']) {
- response['overlap'] = absOverlap;
- response['overlapN'].copy(axis);
- if (overlap < 0) {
- response['overlapN'].reverse();
- }
- }
- }
- T_VECTORS.push(offsetV);
- T_ARRAYS.push(rangeA);
- T_ARRAYS.push(rangeB);
- return false;
- }
-
- // Calculates which Vornoi region a point is on a line segment.
- // It is assumed that both the line and the point are relative to `(0,0)`
- //
- // | (0) |
- // (-1) [S]--------------[E] (1)
- // | (0) |
- /**
- * @param {Vector} line The line segment.
- * @param {Vector} point The point.
- * @return {number} LEFT_VORNOI_REGION (-1) if it is the left region,
- * MIDDLE_VORNOI_REGION (0) if it is the middle region,
- * RIGHT_VORNOI_REGION (1) if it is the right region.
- */
- function vornoiRegion(line, point) {
- var len2 = line.len2();
- var dp = point.dot(line);
- // If the point is beyond the start of the line, it is in the
- // left vornoi region.
- if (dp < 0) { return LEFT_VORNOI_REGION; }
- // If the point is beyond the end of the line, it is in the
- // right vornoi region.
- else if (dp > len2) { return RIGHT_VORNOI_REGION; }
- // Otherwise, it's in the middle one.
- else { return MIDDLE_VORNOI_REGION; }
- }
- // Constants for Vornoi regions
- /**
- * @const
- */
- var LEFT_VORNOI_REGION = -1;
- /**
- * @const
- */
- var MIDDLE_VORNOI_REGION = 0;
- /**
- * @const
- */
- var RIGHT_VORNOI_REGION = 1;
-
- // ## Collision Tests
-
- // Check if two circles collide.
- /**
- * @param {Circle} a The first circle.
- * @param {Circle} b The second circle.
- * @param {Response=} response Response object (optional) that will be populated if
- * the circles intersect.
- * @return {boolean} true if the circles intersect, false if they don't.
- */
- function testCircleCircle(a, b, response) {
- // Check if the distance between the centers of the two
- // circles is greater than their combined radius.
- var differenceV = T_VECTORS.pop().copy(b['pos']).sub(a['pos']);
- var totalRadius = a['r'] + b['r'];
- var totalRadiusSq = totalRadius * totalRadius;
- var distanceSq = differenceV.len2();
- // If the distance is bigger than the combined radius, they don't intersect.
- if (distanceSq > totalRadiusSq) {
- T_VECTORS.push(differenceV);
- return false;
- }
- // They intersect. If we're calculating a response, calculate the overlap.
- if (response) {
- var dist = Math.sqrt(distanceSq);
- response['a'] = a;
- response['b'] = b;
- response['overlap'] = totalRadius - dist;
- response['overlapN'].copy(differenceV.normalize());
- response['overlapV'].copy(differenceV).scale(response['overlap']);
- response['aInB']= a['r'] <= b['r'] && dist <= b['r'] - a['r'];
- response['bInA'] = b['r'] <= a['r'] && dist <= a['r'] - b['r'];
- }
- T_VECTORS.push(differenceV);
- return true;
- }
- SAT['testCircleCircle'] = testCircleCircle;
-
- // Check if a polygon and a circle collide.
- /**
- * @param {Polygon} polygon The polygon.
- * @param {Circle} circle The circle.
- * @param {Response=} response Response object (optional) that will be populated if
- * they interset.
- * @return {boolean} true if they intersect, false if they don't.
- */
- function testPolygonCircle(polygon, circle, response) {
- // Get the position of the circle relative to the polygon.
- var circlePos = T_VECTORS.pop().copy(circle['pos']).sub(polygon['pos']);
- var radius = circle['r'];
- var radius2 = radius * radius;
- var points = polygon['points'];
- var len = points.length;
- var edge = T_VECTORS.pop();
- var point = T_VECTORS.pop();
-
- // For each edge in the polygon:
- for (var i = 0; i < len; i++) {
- var next = i === len - 1 ? 0 : i + 1;
- var prev = i === 0 ? len - 1 : i - 1;
- var overlap = 0;
- var overlapN = null;
-
- // Get the edge.
- edge.copy(polygon['edges'][i]);
- // Calculate the center of the circle relative to the starting point of the edge.
- point.copy(circlePos).sub(points[i]);
-
- // If the distance between the center of the circle and the point
- // is bigger than the radius, the polygon is definitely not fully in
- // the circle.
- if (response && point.len2() > radius2) {
- response['aInB'] = false;
- }
-
- // Calculate which Vornoi region the center of the circle is in.
- var region = vornoiRegion(edge, point);
- // If it's the left region:
- if (region === LEFT_VORNOI_REGION) {
- // We need to make sure we're in the RIGHT_VORNOI_REGION of the previous edge.
- edge.copy(polygon['edges'][prev]);
- // Calculate the center of the circle relative the starting point of the previous edge
- var point2 = T_VECTORS.pop().copy(circlePos).sub(points[prev]);
- region = vornoiRegion(edge, point2);
- if (region === RIGHT_VORNOI_REGION) {
- // It's in the region we want. Check if the circle intersects the point.
- var dist = point.len();
- if (dist > radius) {
- // No intersection
- T_VECTORS.push(circlePos);
- T_VECTORS.push(edge);
- T_VECTORS.push(point);
- T_VECTORS.push(point2);
- return false;
- } else if (response) {
- // It intersects, calculate the overlap.
- response['bInA'] = false;
- overlapN = point.normalize();
- overlap = radius - dist;
- }
- }
- T_VECTORS.push(point2);
- // If it's the right region:
- } else if (region === RIGHT_VORNOI_REGION) {
- // We need to make sure we're in the left region on the next edge
- edge.copy(polygon['edges'][next]);
- // Calculate the center of the circle relative to the starting point of the next edge.
- point.copy(circlePos).sub(points[next]);
- region = vornoiRegion(edge, point);
- if (region === LEFT_VORNOI_REGION) {
- // It's in the region we want. Check if the circle intersects the point.
- var dist = point.len();
- if (dist > radius) {
- // No intersection
- T_VECTORS.push(circlePos);
- T_VECTORS.push(edge);
- T_VECTORS.push(point);
- return false;
- } else if (response) {
- // It intersects, calculate the overlap.
- response['bInA'] = false;
- overlapN = point.normalize();
- overlap = radius - dist;
- }
- }
- // Otherwise, it's the middle region:
- } else {
- // Need to check if the circle is intersecting the edge,
- // Change the edge into its "edge normal".
- var normal = edge.perp().normalize();
- // Find the perpendicular distance between the center of the
- // circle and the edge.
- var dist = point.dot(normal);
- var distAbs = Math.abs(dist);
- // If the circle is on the outside of the edge, there is no intersection.
- if (dist > 0 && distAbs > radius) {
- // No intersection
- T_VECTORS.push(circlePos);
- T_VECTORS.push(normal);
- T_VECTORS.push(point);
- return false;
- } else if (response) {
- // It intersects, calculate the overlap.
- overlapN = normal;
- overlap = radius - dist;
- // If the center of the circle is on the outside of the edge, or part of the
- // circle is on the outside, the circle is not fully inside the polygon.
- if (dist >= 0 || overlap < 2 * radius) {
- response['bInA'] = false;
- }
- }
- }
-
- // If this is the smallest overlap we've seen, keep it.
- // (overlapN may be null if the circle was in the wrong Vornoi region).
- if (overlapN && response && Math.abs(overlap) < Math.abs(response['overlap'])) {
- response['overlap'] = overlap;
- response['overlapN'].copy(overlapN);
- }
- }
-
- // Calculate the final overlap vector - based on the smallest overlap.
- if (response) {
- response['a'] = polygon;
- response['b'] = circle;
- response['overlapV'].copy(response['overlapN']).scale(response['overlap']);
- }
- T_VECTORS.push(circlePos);
- T_VECTORS.push(edge);
- T_VECTORS.push(point);
- return true;
- }
- SAT['testPolygonCircle'] = testPolygonCircle;
-
- // Check if a circle and a polygon collide.
- //
- // **NOTE:** This is slightly less efficient than polygonCircle as it just
- // runs polygonCircle and reverses everything at the end.
- /**
- * @param {Circle} circle The circle.
- * @param {Polygon} polygon The polygon.
- * @param {Response=} response Response object (optional) that will be populated if
- * they interset.
- * @return {boolean} true if they intersect, false if they don't.
- */
- function testCirclePolygon(circle, polygon, response) {
- // Test the polygon against the circle.
- var result = testPolygonCircle(polygon, circle, response);
- if (result && response) {
- // Swap A and B in the response.
- var a = response['a'];
- var aInB = response['aInB'];
- response['overlapN'].reverse();
- response['overlapV'].reverse();
- response['a'] = response['b'];
- response['b'] = a;
- response['aInB'] = response['bInA'];
- response['bInA'] = aInB;
- }
- return result;
- }
- SAT['testCirclePolygon'] = testCirclePolygon;
-
- // Checks whether polygons collide.
- /**
- * @param {Polygon} a The first polygon.
- * @param {Polygon} b The second polygon.
- * @param {Response=} response Response object (optional) that will be populated if
- * they interset.
- * @return {boolean} true if they intersect, false if they don't.
- */
- function testPolygonPolygon(a, b, response) {
- var aPoints = a['points'];
- var aLen = aPoints.length;
- var bPoints = b['points'];
- var bLen = bPoints.length;
- // If any of the edge normals of A is a separating axis, no intersection.
- for (var i = 0; i < aLen; i++) {
- if (isSeparatingAxis(a['pos'], b['pos'], aPoints, bPoints, a['normals'][i], response)) {
- return false;
- }
- }
- // If any of the edge normals of B is a separating axis, no intersection.
- for (var i = 0;i < bLen; i++) {
- if (isSeparatingAxis(a['pos'], b['pos'], aPoints, bPoints, b['normals'][i], response)) {
- return false;
- }
- }
- // Since none of the edge normals of A or B are a separating axis, there is an intersection
- // and we've already calculated the smallest overlap (in isSeparatingAxis). Calculate the
- // final overlap vector.
- if (response) {
- response['a'] = a;
- response['b'] = b;
- response['overlapV'].copy(response['overlapN']).scale(response['overlap']);
- }
- return true;
- }
- SAT['testPolygonPolygon'] = testPolygonPolygon;
-
- return SAT;
-}));
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/Signal.js.html b/docs/Signal.js.html
index 5fe8f083..19ae8888 100644
--- a/docs/Signal.js.html
+++ b/docs/Signal.js.html
@@ -814,7 +814,7 @@ Phaser.Signal.prototype.constructor = Phaser.Signal;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/SignalBinding.html b/docs/SignalBinding.html
index 59511c17..cf65eb7a 100644
--- a/docs/SignalBinding.html
+++ b/docs/SignalBinding.html
@@ -807,7 +807,7 @@ Inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:36 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:48 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/SignalBinding.js.html b/docs/SignalBinding.js.html
index 3172b2b5..fc678376 100644
--- a/docs/SignalBinding.js.html
+++ b/docs/SignalBinding.js.html
@@ -674,7 +674,7 @@ Phaser.SignalBinding.prototype.constructor = Phaser.SignalBinding;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/SinglePad.js.html b/docs/SinglePad.js.html
index 93e93c62..b7ad0cd0 100644
--- a/docs/SinglePad.js.html
+++ b/docs/SinglePad.js.html
@@ -1079,7 +1079,7 @@ Object.defineProperty(Phaser.SinglePad.prototype, "index", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Sound.js.html b/docs/Sound.js.html
index 7d959b39..2118504e 100644
--- a/docs/Sound.js.html
+++ b/docs/Sound.js.html
@@ -832,7 +832,7 @@ Phaser.Sound.prototype = {
if (this.currentTime >= this.durationMS)
{
- //console.log(this.currentMarker, 'has hit duration');
+ console.log(this.currentMarker, 'has hit duration');
if (this.usingWebAudio)
{
if (this.loop)
@@ -891,7 +891,7 @@ Phaser.Sound.prototype = {
position = position || 0;
if (typeof volume === 'undefined') { volume = this._volume; }
- if (typeof loop === 'undefined') { loop = false; }
+ if (typeof loop === 'undefined') { loop = this.loop; }
if (typeof forceRestart === 'undefined') { forceRestart = true; }
// console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop, 'force', forceRestart);
@@ -1335,7 +1335,7 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/SoundManager.js.html b/docs/SoundManager.js.html
index ac447ac6..42a93dd9 100644
--- a/docs/SoundManager.js.html
+++ b/docs/SoundManager.js.html
@@ -843,12 +843,9 @@ Phaser.SoundManager.prototype = {
* @param {string} key - Asset key for the sound.
* @param {number} [volume=1] - Default value for the volume.
* @param {boolean} [loop=false] - Whether or not the sound will loop.
- * @param {boolean} [destroyOnComplete=false] - If true the Sound will destroy itself once it has finished playing, or is stopped.
* @return {Phaser.Sound} The new sound instance.
*/
- play: function (key, volume, loop, destroyOnComplete) {
-
- if (typeof destroyOnComplete == 'undefined') { destroyOnComplete = false; }
+ play: function (key, volume, loop) {
var sound = this.add(key, volume, loop);
@@ -992,7 +989,7 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Spring.js.html b/docs/Spring.js.html
index 512c37b7..61962b7c 100644
--- a/docs/Spring.js.html
+++ b/docs/Spring.js.html
@@ -576,7 +576,7 @@ Phaser.Physics.Spring.prototype.constructor = Phaser.Physics.Spring;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Sprite.js.html b/docs/Sprite.js.html
index a720ae7d..5c9b89e7 100644
--- a/docs/Sprite.js.html
+++ b/docs/Sprite.js.html
@@ -1463,7 +1463,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "fixedToCamera", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/SpriteBatch.js.html b/docs/SpriteBatch.js.html
index acaeb69c..e2890a6c 100644
--- a/docs/SpriteBatch.js.html
+++ b/docs/SpriteBatch.js.html
@@ -545,7 +545,7 @@ Phaser.SpriteBatch.prototype.constructor = Phaser.SpriteBatch;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Stage.js.html b/docs/Stage.js.html
index 26ff3886..9512df79 100644
--- a/docs/Stage.js.html
+++ b/docs/Stage.js.html
@@ -546,6 +546,12 @@ Phaser.Stage = function (game, width, height) {
*/
this.exists = true;
+ /**
+ * @property {string} hiddenVar - The page visibility API event name.
+ * @private
+ */
+ this._hiddenVar = 'hidden';
+
/**
* @property {number} _nextOffsetCheck - The time to run the next offset check.
* @private
@@ -721,10 +727,38 @@ Phaser.Stage.prototype.boot = function () {
Phaser.Canvas.setUserSelect(this.game.canvas, 'none');
Phaser.Canvas.setTouchAction(this.game.canvas, 'none');
- document.addEventListener('visibilitychange', this._onChange, false);
- document.addEventListener('webkitvisibilitychange', this._onChange, false);
- document.addEventListener('pagehide', this._onChange, false);
- document.addEventListener('pageshow', this._onChange, false);
+ this.checkVisibility();
+
+}
+
+/**
+* Starts a page visibility event listener running, or window.blur/focus if not supported by the browser.
+* @method Phaser.Stage#checkVisibility
+*/
+Phaser.Stage.prototype.checkVisibility = function () {
+
+ var supportsVisibilityApi = false;
+ var prefixes = [ "", "moz", "ms", "webkit" ];
+
+ while (prefixes.length)
+ {
+ prefix = prefixes.pop();
+ this._hiddenVar = prefix ? prefix + "Hidden" : "hidden";
+
+ if (this._hiddenVar in document)
+ {
+ supportsVisibilityApi = true;
+ break;
+ }
+ }
+
+ // Does browser support it? If not (like in IE9 or old Android) we need to fall back to blur/focus
+ if (supportsVisibilityApi)
+ {
+ document.addEventListener(this._hiddenVar, this._onChange, false);
+ document.addEventListener('pagehide', this._onChange, false);
+ document.addEventListener('pageshow', this._onChange, false);
+ }
window.onblur = this._onChange;
window.onfocus = this._onChange;
@@ -761,7 +795,7 @@ Phaser.Stage.prototype.visibilityChange = function (event) {
return;
}
- if (this.game.paused === false && (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] === true || document['webkitHidden'] === true))
+ if (this.game.paused === false && (event.type === 'pagehide' || event.type === 'blur' || document[this._hiddenVar] === true))
{
this.game.paused = true;
}
@@ -835,7 +869,7 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/StageScaleMode.js.html b/docs/StageScaleMode.js.html
index c7c64c2b..864ee5f3 100644
--- a/docs/StageScaleMode.js.html
+++ b/docs/StageScaleMode.js.html
@@ -1293,7 +1293,7 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/State.js.html b/docs/State.js.html
index 32e17c26..77d757da 100644
--- a/docs/State.js.html
+++ b/docs/State.js.html
@@ -681,7 +681,7 @@ Phaser.State.prototype.constructor = Phaser.State;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/StateManager.js.html b/docs/StateManager.js.html
index bc2763df..c9df4a40 100644
--- a/docs/StateManager.js.html
+++ b/docs/StateManager.js.html
@@ -584,6 +584,11 @@ Phaser.StateManager = function (game, pendingState) {
*/
this.onPausedCallback = null;
+ /**
+ * @property {function} onResumedCallback - This will be called when the state is resumed from a paused state.
+ */
+ this.onResumedCallback = null;
+
/**
* @property {function} onShutDownCallback - This will be called when the state is shut down (i.e. swapped to another state).
*/
@@ -686,6 +691,7 @@ Phaser.StateManager.prototype = {
this.onUpdateCallback = null;
this.onRenderCallback = null;
this.onPausedCallback = null;
+ this.onResumedCallback = null;
this.onDestroyCallback = null;
}
@@ -861,6 +867,7 @@ Phaser.StateManager.prototype = {
this.onPreRenderCallback = this.states[key]['preRender'] || null;
this.onRenderCallback = this.states[key]['render'] || null;
this.onPausedCallback = this.states[key]['paused'] || null;
+ this.onResumedCallback = this.states[key]['resumed'] || null;
// Used when the state is no longer the current active state
this.onShutDownCallback = this.states[key]['shutdown'] || this.dummy;
@@ -909,7 +916,7 @@ Phaser.StateManager.prototype = {
if (this._created && this.onPausedCallback)
{
- this.onPausedCallback.call(this.callbackContext, this.game, true);
+ this.onPausedCallback.call(this.callbackContext, this.game);
}
},
@@ -920,9 +927,9 @@ Phaser.StateManager.prototype = {
*/
resume: function () {
- if (this._created && this.onre)
+ if (this._created && this.onResumedCallback)
{
- this.onPausedCallback.call(this.callbackContext, this.game, false);
+ this.onResumedCallback.call(this.callbackContext, this.game);
}
},
@@ -1009,6 +1016,7 @@ Phaser.StateManager.prototype = {
this.onUpdateCallback = null;
this.onRenderCallback = null;
this.onPausedCallback = null;
+ this.onResumedCallback = null;
this.onDestroyCallback = null;
this.game = null;
@@ -1041,7 +1049,7 @@ Phaser.StateManager.prototype.constructor = Phaser.StateManager;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Text.js.html b/docs/Text.js.html
index 596c7146..0a741a9d 100644
--- a/docs/Text.js.html
+++ b/docs/Text.js.html
@@ -1328,7 +1328,7 @@ Object.defineProperty(Phaser.Text.prototype, "fixedToCamera", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Tile.js.html b/docs/Tile.js.html
index 15856305..70f71e48 100644
--- a/docs/Tile.js.html
+++ b/docs/Tile.js.html
@@ -803,7 +803,7 @@ Object.defineProperty(Phaser.Tile.prototype, "bottom", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/TileSprite.js.html b/docs/TileSprite.js.html
index 1fb1e9cb..78b1b533 100644
--- a/docs/TileSprite.js.html
+++ b/docs/TileSprite.js.html
@@ -574,6 +574,11 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
this.position.set(x, y);
+ /**
+ * @property {Phaser.InputHandler|null} input - The Input Handler for this object. Needs to be enabled with image.inputEnabled = true before you can use it.
+ */
+ this.input = null;
+
/**
* @property {Phaser.Point} world - The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container.
*/
@@ -908,6 +913,42 @@ Object.defineProperty(Phaser.TileSprite.prototype, "fixedToCamera", {
}
}
+});
+
+/**
+* By default a TileSprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
+* activated for this object and it will then start to process click/touch events and more.
+*
+* @name Phaser.TileSprite#inputEnabled
+* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
+*/
+Object.defineProperty(Phaser.TileSprite.prototype, "inputEnabled", {
+
+ get: function () {
+
+ return (this.input && this.input.enabled);
+
+ },
+
+ set: function (value) {
+
+ if (value)
+ {
+ if (this.input === null)
+ {
+ this.input = new Phaser.InputHandler(this);
+ this.input.start();
+ }
+ }
+ else
+ {
+ if (this.input && this.input.enabled)
+ {
+ this.input.stop();
+ }
+ }
+ }
+
});
@@ -930,7 +971,7 @@ Object.defineProperty(Phaser.TileSprite.prototype, "fixedToCamera", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Tilemap.js.html b/docs/Tilemap.js.html
index f9e77132..5d3a238d 100644
--- a/docs/Tilemap.js.html
+++ b/docs/Tilemap.js.html
@@ -1925,7 +1925,7 @@ Phaser.Tilemap.prototype.constructor = Phaser.Tilemap;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/TilemapLayer.js.html b/docs/TilemapLayer.js.html
index c057bf76..8504855f 100644
--- a/docs/TilemapLayer.js.html
+++ b/docs/TilemapLayer.js.html
@@ -1390,7 +1390,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "collisionHeight", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/TilemapParser.js.html b/docs/TilemapParser.js.html
index 7ca86c26..6144d9a0 100644
--- a/docs/TilemapParser.js.html
+++ b/docs/TilemapParser.js.html
@@ -891,7 +891,14 @@ Phaser.TilemapParser = {
newSet.columns = (set.imagewidth - set.margin) / (set.tilewidth + set.spacing);
newSet.total = newSet.rows * newSet.columns;
- tilesets.push(newSet);
+ if (newSet.rows % 1 !== 0 || newSet.columns % 1 !== 0)
+ {
+ console.warn('TileSet image dimensions do not match expected dimensions. Tileset width/height must be evenly divisible by Tilemap tile width/height.');
+ }
+ else
+ {
+ tilesets.push(newSet);
+ }
}
map.tilesets = tilesets;
@@ -969,7 +976,7 @@ Phaser.TilemapParser = {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Tileset.js.html b/docs/Tileset.js.html
index 52ca0715..abd3864e 100644
--- a/docs/Tileset.js.html
+++ b/docs/Tileset.js.html
@@ -666,7 +666,7 @@ Phaser.Tileset.prototype.constructor = Phaser.Tileset;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Time.js.html b/docs/Time.js.html
index cfb57c5b..7da3ac77 100644
--- a/docs/Time.js.html
+++ b/docs/Time.js.html
@@ -857,7 +857,7 @@ Phaser.Time.prototype.constructor = Phaser.Time;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Timer.js.html b/docs/Timer.js.html
index cabba614..f52d35eb 100644
--- a/docs/Timer.js.html
+++ b/docs/Timer.js.html
@@ -1019,7 +1019,7 @@ Phaser.Timer.prototype.constructor = Phaser.Timer;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/TimerEvent.js.html b/docs/TimerEvent.js.html
index b5b57d71..b9ac2980 100644
--- a/docs/TimerEvent.js.html
+++ b/docs/TimerEvent.js.html
@@ -583,7 +583,7 @@ Phaser.TimerEvent.prototype.constructor = Phaser.TimerEvent;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Touch.js.html b/docs/Touch.js.html
index 8223f21a..87d106d2 100644
--- a/docs/Touch.js.html
+++ b/docs/Touch.js.html
@@ -881,7 +881,7 @@ Phaser.Touch.prototype.constructor = Phaser.Touch;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Tween.js.html b/docs/Tween.js.html
index bbe88916..02820360 100644
--- a/docs/Tween.js.html
+++ b/docs/Tween.js.html
@@ -1089,7 +1089,7 @@ Phaser.Tween.prototype.constructor = Phaser.Tween;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/TweenManager.js.html b/docs/TweenManager.js.html
index c08f1aa9..93dc2618 100644
--- a/docs/TweenManager.js.html
+++ b/docs/TweenManager.js.html
@@ -714,7 +714,7 @@ Phaser.TweenManager.prototype.constructor = Phaser.TweenManager;
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/Utils.js.html b/docs/Utils.js.html
index a2ddcbee..c70406a4 100644
--- a/docs/Utils.js.html
+++ b/docs/Utils.js.html
@@ -815,7 +815,7 @@ if (!Array.isArray) {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:21 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:33 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/World.js.html b/docs/World.js.html
index 2f50bc7a..793f0199 100644
--- a/docs/World.js.html
+++ b/docs/World.js.html
@@ -544,7 +544,7 @@ Phaser.Physics.World = function (game, config) {
/**
* @property {Phaser.InversePointProxy} gravity - The gravity applied to all bodies each step.
*/
- this.gravity = new Phaser.Physics.InversePointProxy(this.world.gravity);
+ this.gravity = new Phaser.Physics.InversePointProxy(game, this.world.gravity);
/**
* @property {p2.Body} bounds - The bounds body contains the 4 walls that border the World. Define or disable with setBounds.
@@ -1574,7 +1574,7 @@ Object.defineProperty(Phaser.Physics.World.prototype, "enableBodySleeping", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/World.js_.html b/docs/World.js_.html
index f2d024f1..7082bfd3 100644
--- a/docs/World.js_.html
+++ b/docs/World.js_.html
@@ -723,7 +723,7 @@ Object.defineProperty(Phaser.World.prototype, "randomY", {
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/classes.list.html b/docs/classes.list.html
index 3860ac29..e9893460 100644
--- a/docs/classes.list.html
+++ b/docs/classes.list.html
@@ -881,7 +881,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/global.html b/docs/global.html
index b5185e31..33e6a813 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -1257,7 +1257,7 @@ this function is taken from Starling Framework as its pretty neat ;)
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/index.html b/docs/index.html
index 2c595f8a..eeb5af88 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -510,9 +510,9 @@
-
Phaser 1.2-dev
+
Phaser 2.0.0-dev
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses Pixi.js internally for fast 2D Canvas and WebGL rendering.
As you may know we had planned to release 1.1.4 at the end of 2013. For various reasons this didn't quite happen, but we're happy to announce it's finally out! There have been some dramatic changes internally, and if you make use of either the physics systems or tilemaps then you are going to need to update your code. Hopefully only a little bit, but there have been a number of core API changes which we detail below. There are also a host of new features, the headliners being:
-
-
New Physics system. Uses SAT.js internally so physics bodies can now be rectangles, circles or polygons and support rotation.
-
New Tilemap system. Brand new collision system for tiles, much more advanced layer handling, tile properties, multiple tilesets of layer and more.
-
New Timer. This handy new class lets you create timed events easily.
-
Your Game can now be configured from an external configuration object.
-
Over 150 new features and updates and over 30 reported bug fixes.
-
-
This release also brings the TypeScript definitions file as bang up to date as possible. There are still a few areas that need looking at, but with your help hopefully we can iron those final few bits out and have a 100% accruate defs file on offer.
-
There is a new Contributors Guide which we'd urge you to follow if you wish to help with Phaser development, and we've updated the doc files and added lots more details into key areas. The Examples have grown too! Now over 220 of them including several great ones from the community.
-
We're going to settle on this build for a short while as we do some quick iteration bug fixing, so expect to see some small point releases very soon that do nothing but address any issues you may find. But in parallel to this we are also now rebuilding our core to bring it in-line with the latest version of Pixi.js, which has had some dramatic changes under the hood, changes will impact a lot of what Phaser does internally. But the changes are all for the better and once we upgrade Pixi you'll have a significantly faster renderer and a smaller codebase too, as we do away with stacks of linked list code :)
-
As always we offer a heart-felt "Thank you!" to everyone who has encouraged us along the way. To those of you who worked with Phaser during its various incarnations. The number of games being released that were made with Phaser is staggering and we really love to see how you use it! You are our heroes. It's your kind words and enthusiasm that has keeps us going.
-
Phaser is everything we ever wanted from an HTML5 game framework. It powers all of our client work in build today and remains our single most important product, and we've still only just scratched the surface of what we have planned for it.
-
+
Phaser 2.0 "welcome" text to go here.
Getting Started Guides
We have a new Getting Started Guide which covers all you need to begin developing games with Phaser. From setting up a web server to picking an IDE. If you're new to HTML5 game development, or are coming from another language like AS3, then we recommend starting there.
There is a comprehensive How to Learn Phaser guide on the GameDevTuts+ site which is a great place to learn where to find tutorials, examples and support.
fixedToCamera now works across all display objects. When enabled it will fix at its current x/y coordinate, but can be changed via cameraOffset.
fixedToCamrea now works for Groups as well :) You can fix a Group to the camera and it will influence its children.
Tilemap.createCollisionObjects will parse Tiled data for objectgroups and convert polyline instances into physics objects you can collide with in the world.
+
Loader can now load JSON files specifically (game.load.json) and they are parsed and stored in the Game.Cache. Retrieve with game.cache.getJSON(key).
+
TileSprites can now receive full Input events, dragging, etc and be positioned in-world and fixed to cameras.
+
The StateManager now looks for a function called 'resumed' which is called when a game un-pauses.
Updates:
@@ -620,6 +610,11 @@
Device, Canvas and GamePad classes all updated for better CocoonJS support (thanks Videlais)
BitmapData.alphaMask will draw the given image onto a BitmapData using an image as an alpha mask.
The new GameObjectCreator (which you access via game.make or State.make) lets you easily create an object but NOT add it to the display list.
+
TilemapParser will now throw a warning if the tileset image isn't the right size for the tile dimensions.
+
We now force IE11 into Canvas mode to avoid a Pixi bug with pre-multiplied alpha. Will remove once that is fixed, sorry, but it's better than no game at all, right? :(
+
Loader.setPreloadSprite() will now set sprite.visible = true once the crop has been applied. Should help avoid issues (#430) on super-slow connections.
+
Updated the way the page visibility is checked, should now be more compatible across more browsers.
+
Phaser.Input.Key.isUp now defaults to 'true', as does GamepadButton.isUp (#474)
Bug Fixes:
@@ -635,6 +630,9 @@
Fixed bug in Math.angleBetween where it was using the coordinates in the wrong order.
Previously using a Pixel Perfect check didn't work if the Sprite was rotated or had a non-zero anchor point, now works under all conditions + atlas frames.
If pixelPerfect Input Sprites overlapped each other the pixel check wasn't taken into consieration in the Pointer move method.
+
Updated Input.Mouse to use event.button not event.which, so the const reference from input.mouse.button is correct (thanks grimor)
+
Text that was fixedToCamera would 'jitter' if the world scrolled. Now works as expected across all fixed objects.
+
Fixed a bug where Sound.play wouldn't pick-up the local loop setting if not specified in the parameter.
TO DO:
@@ -705,31 +703,29 @@ Sprites also have full Input support: click them, touch them, drag them around,
Although Phaser 1.0 is a brand new release it is born from years of experience building some of the biggest mobile HTML5 games out there. We're not saying it is 100% bug free, but we use it for our client work every day, so issues get resolved <em>fast</em> and we stay on-top of the changing browser landscape.
Road Map
-
Here is what's on our road map for the coming months:
-
Version 1.3 ("Tarabon")
+
Beyond version 2.0 here are some of the features planned for the future:
+
Version 2.1 ("Shienar")
Enhance the State Management, so you can perform non-destructive State swaps and persistence.
-
Dedicated CocoonJS packaging features (screencanvas, etc)
A more advanced Particle system, one that can render to a single canvas (rather than spawn hundreds of Sprites), more advanced effects, etc.
Ability to control DOM elements from the core game and layer them into the game.
Touch Gestures.
Support for parallel asset loading.
-
Fixed width bitmap font support, plus enhanced Bitmap font rendering.
-
Version 2.0 ("Aes Sedai")
+
Version 2.2 ("Tarabon")
-
Integrate p2.js physics system completely.
Comprehensive testing across Firefox OS devices, CocoonJS and Ejecta.
Integration with third party services like Google Play Game Services and Amazon JS SDK.
Flash CC HTML5 export integration.
-
Massively enhance the audio side of Phaser. Although it does what it does well, it could do with taking more advantage of Web Audio - echo effects, positional sound, etc.
+
Massively enhance the audio side of Phaser. Take more advantage of Web Audio: echo effects, positional sound, etc.
-
Beyond version 2.0
+
Beyond version 2.2
Test out packaging with Node-webkit.
Game parameters stored in Google Docs.
Look at HiDPI Canvas settings.
Multiple Camera support.
+
DragonBones support.
Nadion
Nadion is a set of powerful enhancements for Phaser that makes level building even easier. It includes features such as Trigger, Area, Alarms and Emitters, debug panels, state machines, parallax layer scrolling, 'developer mode' short-cuts and more.
@@ -773,7 +769,7 @@ Sprites also have full Input support: click them, touch them, drag them around,
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/docs/namespaces.list.html b/docs/namespaces.list.html
index 747eeb6f..81e37a08 100644
--- a/docs/namespaces.list.html
+++ b/docs/namespaces.list.html
@@ -881,7 +881,7 @@
Documentation generated by JSDoc 3.3.0-dev
- on Fri Feb 21 2014 15:36:22 GMT-0000 (GMT) using the DocStrap template.
+ on Mon Feb 24 2014 12:11:34 GMT-0000 (GMT) using the DocStrap template.
diff --git a/resources/wip/01_phaser-arcade.jpg b/resources/wip/01_phaser-arcade.jpg
deleted file mode 100644
index 2fe7c150..00000000
Binary files a/resources/wip/01_phaser-arcade.jpg and /dev/null differ
diff --git a/resources/wip/02_phaser-newsletter.jpg b/resources/wip/02_phaser-newsletter.jpg
deleted file mode 100644
index 5fd49696..00000000
Binary files a/resources/wip/02_phaser-newsletter.jpg and /dev/null differ
diff --git a/resources/wip/32x32_t.png b/resources/wip/32x32_t.png
deleted file mode 100644
index b726a9e1..00000000
Binary files a/resources/wip/32x32_t.png and /dev/null differ
diff --git a/resources/wip/Degree-Radian_Conversion.svg b/resources/wip/Degree-Radian_Conversion.svg
deleted file mode 100644
index 116cc38f..00000000
--- a/resources/wip/Degree-Radian_Conversion.svg
+++ /dev/null
@@ -1,3631 +0,0 @@
-
-
-
diff --git a/resources/wip/Physics Comparison.xlsx b/resources/wip/Physics Comparison.xlsx
deleted file mode 100644
index 77032e13..00000000
Binary files a/resources/wip/Physics Comparison.xlsx and /dev/null differ
diff --git a/resources/wip/phaser-manual_2013-08-27.pdf b/resources/wip/phaser-manual_2013-08-27.pdf
deleted file mode 100644
index 62d8287b..00000000
Binary files a/resources/wip/phaser-manual_2013-08-27.pdf and /dev/null differ
diff --git a/resources/wip/phaser_copy.doc b/resources/wip/phaser_copy.doc
deleted file mode 100644
index 55bc02c4..00000000
Binary files a/resources/wip/phaser_copy.doc and /dev/null differ
diff --git a/resources/wip/phaser_onscreen-controls_1-arcade.png b/resources/wip/phaser_onscreen-controls_1-arcade.png
deleted file mode 100644
index 4da313ce..00000000
Binary files a/resources/wip/phaser_onscreen-controls_1-arcade.png and /dev/null differ
diff --git a/resources/wip/phaser_onscreen-controls_2-dpad.png b/resources/wip/phaser_onscreen-controls_2-dpad.png
deleted file mode 100644
index 4d703593..00000000
Binary files a/resources/wip/phaser_onscreen-controls_2-dpad.png and /dev/null differ
diff --git a/resources/wip/phaser_onscreen-controls_3-generic.png b/resources/wip/phaser_onscreen-controls_3-generic.png
deleted file mode 100644
index 70135276..00000000
Binary files a/resources/wip/phaser_onscreen-controls_3-generic.png and /dev/null differ
diff --git a/resources/wip/rotations.png b/resources/wip/rotations.png
deleted file mode 100644
index 2b2f1402..00000000
Binary files a/resources/wip/rotations.png and /dev/null differ
diff --git a/resources/wip/sprites/avoid-digits.png b/resources/wip/sprites/avoid-digits.png
deleted file mode 100644
index c3bf0af1..00000000
Binary files a/resources/wip/sprites/avoid-digits.png and /dev/null differ
diff --git a/resources/wip/sprites/avoid-panel.png b/resources/wip/sprites/avoid-panel.png
deleted file mode 100644
index 741e4fe5..00000000
Binary files a/resources/wip/sprites/avoid-panel.png and /dev/null differ
diff --git a/resources/wip/sprites/avoid-sheet.png b/resources/wip/sprites/avoid-sheet.png
deleted file mode 100644
index c88ce1ba..00000000
Binary files a/resources/wip/sprites/avoid-sheet.png and /dev/null differ
diff --git a/resources/wip/sprites/avoidmock4x2.png b/resources/wip/sprites/avoidmock4x2.png
deleted file mode 100644
index 4a1a515f..00000000
Binary files a/resources/wip/sprites/avoidmock4x2.png and /dev/null differ
diff --git a/resources/wip/sprites/box-01.png b/resources/wip/sprites/box-01.png
deleted file mode 100644
index 09ae319a..00000000
Binary files a/resources/wip/sprites/box-01.png and /dev/null differ
diff --git a/resources/wip/sprites/box-02.png b/resources/wip/sprites/box-02.png
deleted file mode 100644
index e6dcceb2..00000000
Binary files a/resources/wip/sprites/box-02.png and /dev/null differ
diff --git a/resources/wip/sprites/breakout2c.png b/resources/wip/sprites/breakout2c.png
deleted file mode 100644
index 2dd498cf..00000000
Binary files a/resources/wip/sprites/breakout2c.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/1 logo.png b/resources/wip/sprites/orbit/1 logo.png
deleted file mode 100644
index 879ba4ee..00000000
Binary files a/resources/wip/sprites/orbit/1 logo.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/2 menu.png b/resources/wip/sprites/orbit/2 menu.png
deleted file mode 100644
index 1a44cf15..00000000
Binary files a/resources/wip/sprites/orbit/2 menu.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/3 bg.png b/resources/wip/sprites/orbit/3 bg.png
deleted file mode 100644
index 982fe1ff..00000000
Binary files a/resources/wip/sprites/orbit/3 bg.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/breakout4logo.gif b/resources/wip/sprites/orbit/breakout4logo.gif
deleted file mode 100644
index 4f60f2ea..00000000
Binary files a/resources/wip/sprites/orbit/breakout4logo.gif and /dev/null differ
diff --git a/resources/wip/sprites/orbit/brick-bgtiles.png b/resources/wip/sprites/orbit/brick-bgtiles.png
deleted file mode 100644
index 379be06c..00000000
Binary files a/resources/wip/sprites/orbit/brick-bgtiles.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/brick-bricks.png b/resources/wip/sprites/orbit/brick-bricks.png
deleted file mode 100644
index 28ef3727..00000000
Binary files a/resources/wip/sprites/orbit/brick-bricks.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/brick-frame.png b/resources/wip/sprites/orbit/brick-frame.png
deleted file mode 100644
index ea8ada48..00000000
Binary files a/resources/wip/sprites/orbit/brick-frame.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/brick-score.png b/resources/wip/sprites/orbit/brick-score.png
deleted file mode 100644
index 176c4188..00000000
Binary files a/resources/wip/sprites/orbit/brick-score.png and /dev/null differ
diff --git a/resources/wip/sprites/orbit/brick-sprites.png b/resources/wip/sprites/orbit/brick-sprites.png
deleted file mode 100644
index 68c10c59..00000000
Binary files a/resources/wip/sprites/orbit/brick-sprites.png and /dev/null differ
diff --git a/resources/wip/sprites/phaser checkboxes.gif b/resources/wip/sprites/phaser checkboxes.gif
deleted file mode 100644
index 4151460f..00000000
Binary files a/resources/wip/sprites/phaser checkboxes.gif and /dev/null differ
diff --git a/resources/wip/sprites/phaser power tools.gif b/resources/wip/sprites/phaser power tools.gif
deleted file mode 100644
index 318b5fb0..00000000
Binary files a/resources/wip/sprites/phaser power tools.gif and /dev/null differ
diff --git a/resources/wip/sprites/phaser sprites10.gif b/resources/wip/sprites/phaser sprites10.gif
deleted file mode 100644
index 4d476ca3..00000000
Binary files a/resources/wip/sprites/phaser sprites10.gif and /dev/null differ
diff --git a/resources/wip/sprites/phaser sprites11.gif b/resources/wip/sprites/phaser sprites11.gif
deleted file mode 100644
index 3c63702d..00000000
Binary files a/resources/wip/sprites/phaser sprites11.gif and /dev/null differ
diff --git a/wip/Body-Debug.js b/wip/Body-Debug.js
deleted file mode 100644
index c595cd50..00000000
--- a/wip/Body-Debug.js
+++ /dev/null
@@ -1,1626 +0,0 @@
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* The Physics Body is linked to a single Sprite and defines properties that determine how the physics body is simulated.
-* These properties affect how the body reacts to forces, what forces it generates on itself (to simulate friction), and how it reacts to collisions in the scene. In most cases, the properties are used to simulate physical effects.
-* Each body also has its own property values that determine exactly how it reacts to forces and collisions in the scene.
-*
-* @class Phaser.Physics.Arcade.Body
-* @classdesc Arcade Physics Body Constructor
-* @constructor
-* @param {Phaser.Sprite} sprite - The Sprite object this physics body belongs to.
-*/
-Phaser.Physics.Arcade.Body = function (sprite) {
-
- /**
- * @property {Phaser.Sprite} sprite - Reference to the parent Sprite.
- */
- this.sprite = sprite;
-
- /**
- * @property {Phaser.Game} game - Local reference to game.
- */
- this.game = sprite.game;
-
- /**
- * @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position.
- */
- this.offset = new Phaser.Point();
-
- /**
- * @property {number} preX - The previous x position of the physics body.
- * @readonly
- */
- this.preX = sprite.world.x;
-
- /**
- * @property {number} preY - The previous y position of the physics body.
- * @readonly
- */
- this.preY = sprite.world.y;
-
- /**
- * @property {number} preRotation - The previous rotation of the physics body.
- * @readonly
- */
- this.preRotation = sprite.angle;
-
- /**
- * @property {Phaser.Point} velocity - The velocity of the Body.
- */
- this.velocity = new Phaser.Point();
-
- /**
- * @property {Phaser.Point} acceleration - The acceleration in pixels per second sq. of the Body.
- */
- this.acceleration = new Phaser.Point();
-
- /**
- * @property {number} speed - The speed in pixels per second sq. of the Body.
- */
- this.speed = 0;
-
- /**
- * @property {number} angle - The angle of the Body based on its velocity in radians.
- */
- this.angle = 0;
-
- /**
- * @property {Phaser.Point} gravity - The gravity applied to the motion of the Body. This works in addition to any gravity set on the world.
- */
- this.gravity = new Phaser.Point();
-
- /**
- * @property {Phaser.Point} bounce - The elasticitiy of the Body when colliding. This property determines how much energy a body maintains during a collision, i.e. its bounciness.
- */
- this.bounce = new Phaser.Point();
-
- /**
- * @property {Phaser.Point} minVelocity - When a body rebounds off another body or a wall the minVelocity is checked. If the new velocity is lower than minVelocity the body is stopped.
- * @default
- */
- this.minVelocity = new Phaser.Point();
-
- /**
- * @property {Phaser.Point} maxVelocity - The maximum velocity that the Body can reach.
- * @default
- */
- this.maxVelocity = new Phaser.Point(1000, 1000);
-
- /**
- * @property {number} angularVelocity - The angular velocity of the Body.
- * @default
- */
- this.angularVelocity = 0;
-
- /**
- * @property {number} angularAcceleration - The angular acceleration of the Body.
- * @default
- */
- this.angularAcceleration = 0;
-
- /**
- * @property {number} angularDrag - angularDrag is used to calculate friction on the body as it rotates.
- * @default
- */
- this.angularDrag = 0;
-
- /**
- * @property {number} maxAngular - The maximum angular velocity that the Body can reach.
- * @default
- */
- this.maxAngular = 1000;
-
- /**
- * @property {number} mass - The mass property determines how forces affect the body, as well as how much momentum the body has when it is involved in a collision.
- * @default
- */
- this.mass = 1;
-
- /**
- * @property {number} linearDamping - linearDamping is used to calculate friction on the body as it moves through the world. For example, this might be used to simulate air or water friction.
- * @default
- */
- this.linearDamping = 0.0;
-
- /**
- * Set the checkCollision properties to control which directions collision is processed for this Body.
- * For example checkCollision.up = false means it won't collide when the collision happened while moving up.
- * @property {object} checkCollision - An object containing allowed collision.
- */
- this.checkCollision = { none: false, any: true, up: true, down: true, left: true, right: true };
-
- /**
- * This object is populated with boolean values when the Body collides with another.
- * touching.up = true means the collision happened to the top of this Body for example.
- * @property {object} touching - An object containing touching results.
- */
- this.touching = { none: true, up: false, down: false, left: false, right: false };
-
- /**
- * This object is populated with boolean values when the Body collides with the World bounds or a Tile.
- * For example if blocked.up is true then the Body cannot move up.
- * @property {object} blocked - An object containing on which faces this Body is blocked from moving, if any.
- */
- this.blocked = { x: 0, y: 0, up: false, down: false, left: false, right: false };
-
- /**
- * @property {number} facing - A const reference to the direction the Body is traveling or facing.
- * @default
- */
- this.facing = Phaser.NONE;
-
- /**
- * @property {boolean} rebound - A Body set to rebound will exchange velocity with another Body during collision. Set to false to allow this body to be 'pushed' rather than exchange velocity.
- * @default
- */
- this.rebound = true;
-
- /**
- * @property {boolean} immovable - An immovable Body will not receive any impacts or exchanges of velocity from other bodies.
- * @default
- */
- this.immovable = false;
-
- /**
- * @property {boolean} moves - Set to true to allow the Physics system (such as velocity) to move this Body, or false to move it manually.
- * @default
- */
- this.moves = true;
-
- /**
- * @property {number} rotation - The amount the parent Sprite is rotated.
- * @default
- */
- this.rotation = 0;
-
- /**
- * @property {boolean} allowRotation - Allow angular rotation? This will cause the Sprite to be rotated via angularVelocity, etc.
- * @default
- */
- this.allowRotation = true;
-
- /**
- * @property {boolean} allowGravity - Allow this Body to be influenced by the global Gravity value? Note: It will always be influenced by the local gravity if set.
- * @default
- */
- this.allowGravity = true;
-
- /**
- * @property {function} customSeparateCallback - If set this callback will be used for Body separation instead of the built-in one. Callback should return true if separated, otherwise false.
- * @default
- */
- this.customSeparateCallback = null;
-
- /**
- * @property {object} customSeparateContext - The context in which the customSeparateCallback is called.
- * @default
- */
- this.customSeparateContext = null;
-
- /**
- * @property {function} collideCallback - If set this callback will be fired whenever this Body is hit (on any face). It will send three parameters, the face it hit on, this Body and the Body that hit it.
- * @default
- */
- this.collideCallback = null;
-
- /**
- * @property {object} collideCallbackContext - The context in which the collideCallback is called.
- * @default
- */
- this.collideCallbackContext = null;
-
- /**
- * A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
- * @property {boolean} collideWorldBounds - Should the Body collide with the World bounds?
- */
- this.collideWorldBounds = false;
-
- /**
- * @property {Phaser.Physics.Arcade.RECT|Phaser.Physics.Arcade.CIRCLE} type - The type of SAT Shape.
- */
- this.type = Phaser.Physics.Arcade.RECT;
-
- /**
- * @property {SAT.Box|SAT.Circle|SAT.Polygon} shape - The SAT Collision shape.
- */
- this.shape = null;
-
- /**
- * @property {SAT.Polygon} polygon - The SAT Polygons, as derived from the Shape.
- */
- this.polygon = null;
-
- /**
- * @property {number} left - The left-most point of this Body.
- * @readonly
- */
- this.left = 0;
-
- /**
- * @property {number} right - The right-most point of this Body.
- * @readonly
- */
- this.right = 0;
-
- /**
- * @property {number} top - The top-most point of this Body.
- * @readonly
- */
- this.top = 0;
-
- /**
- * @property {number} bottom - The bottom-most point of this Body.
- * @readonly
- */
- this.bottom = 0;
-
- /**
- * @property {number} width - The current width of the Body, taking into account the point rotation.
- * @readonly
- */
- this.width = 0;
-
- /**
- * @property {number} height - The current height of the Body, taking into account the point rotation.
- * @readonly
- */
- this.height = 0;
-
- /**
- * @property {array} contacts - Used to store references to bodies this Body is in contact with.
- * @protected
- */
- this.contacts = [];
-
- /**
- * @property {number} overlapX - Mostly used internally to store the overlap values from Tile seperation.
- * @protected
- */
- this.overlapX = 0;
-
- /**
- * @property {number} overlapY - Mostly used internally to store the overlap values from Tile seperation.
- * @protected
- */
- this.overlapY = 0;
-
- /**
- * @property {Phaser.Point} _temp - Internal cache var.
- * @private
- */
- this._temp = null;
-
- /**
- * @property {number} _dx - Internal cache var.
- * @private
- */
- this._dx = 0;
-
- /**
- * @property {number} _dy - Internal cache var.
- * @private
- */
- this._dy = 0;
-
- /**
- * @property {number} _sx - Internal cache var.
- * @private
- */
- this._sx = sprite.scale.x;
-
- /**
- * @property {number} _sy - Internal cache var.
- * @private
- */
- this._sy = sprite.scale.y;
-
- /**
- * @property {array} _distances - Internal cache var.
- * @private
- */
- this._distances = [0, 0, 0, 0];
-
- /**
- * @property {number} _vx - Internal cache var.
- * @private
- */
- this._vx = 0;
-
- /**
- * @property {number} _vy - Internal cache var.
- * @private
- */
- this._vy = 0;
-
- // Set-up the default shape
- this.setRectangle(sprite.width, sprite.height, 0, 0);
-
- // Set-up contact events
- this.sprite.events.onBeginContact = new Phaser.Signal();
- this.sprite.events.onEndContact = new Phaser.Signal();
-
-};
-
-Phaser.Physics.Arcade.Body.prototype = {
-
- /**
- * Internal method that updates the Body scale in relation to the parent Sprite.
- *
- * @method Phaser.Physics.Arcade#updateScale
- * @protected
- */
- updateScale: function () {
-
- if (this.polygon)
- {
- this.polygon.scale(this.sprite.scale.x / this._sx, this.sprite.scale.y / this._sy);
- }
- else
- {
- this.shape.r *= Math.max(this.sprite.scale.x, this.sprite.scale.y);
- }
-
- this._sx = this.sprite.scale.x;
- this._sy = this.sprite.scale.y;
-
- },
-
- /**
- * Internal method that updates the Body position in relation to the parent Sprite.
- *
- * @method Phaser.Physics.Arcade#preUpdate
- * @protected
- */
- preUpdate: function () {
-
- this.x = (this.sprite.world.x - (this.sprite.anchor.x * this.sprite.width)) + this.offset.x;
- this.y = (this.sprite.world.y - (this.sprite.anchor.y * this.sprite.height)) + this.offset.y;
-
- // This covers any motion that happens during this frame, not since the last frame
- this.preX = this.x;
- this.preY = this.y;
- this.preRotation = this.sprite.angle;
-
- this.rotation = this.preRotation;
-
- if (this.sprite.scale.x !== this._sx || this.sprite.scale.y !== this._sy)
- {
- this.updateScale();
- }
-
-if (this.sprite.debug)
-{
- console.log('Body preUpdate x:', this.x, 'y:', this.y);
- // console.log('Body preUpdate Sprite x:', this.sprite.x, 'y:', this.sprite.y);
- // console.log('Body preUpdate Sprite world:', this.sprite.world.x, 'y:', this.sprite.world.y);
- // console.log('Body preUpdate Sprite position:', this.sprite.position.x, 'y:', this.sprite.position.y);
- // console.log('Body preUpdate Sprite localTransform:', this.sprite.localTransform[2], 'y:', this.sprite.localTransform[5]);
- // console.log('Body preUpdate Sprite worldTransform:', this.sprite.worldTransform[2], 'y:', this.sprite.worldTransform[5]);
- // console.log('Body preUpdate x:', this.x, 'y:', this.y, 'left:', this.left, 'right:', this.right, 'WAS', this.preX, this.preY);
- console.log('Body preUpdate blocked:', this.blocked, this.blockFlags);
- console.log('Body preUpdate velocity:', this.velocity.x, this.velocity.y);
- // console.log('Body preUpdate rotation:', this.rotation, this.preRotation);
-}
-
- this.checkBlocked();
-
- this.touching.none = true;
- this.touching.up = false;
- this.touching.down = false;
- this.touching.left = false;
- this.touching.right = false;
-
- if (this.moves)
- {
- if (this._vx !== this.velocity.x || this._vy !== this.velocity.y)
- {
- // No need to re-calc these if they haven't changed
- this._vx = this.velocity.x;
- this._vy = this.velocity.y;
- this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
- this.angle = Math.atan2(this.velocity.y, this.velocity.x);
- }
-
- if (this.game.physics.checkBounds(this))
- {
- this.reboundCheck(true, true, true);
- }
-
- this.applyDamping();
-
- this.integrateVelocity();
-
- this.updateBounds();
-
- this.checkBlocked();
- }
- else
- {
- this.updateBounds();
- }
-
-if (this.sprite.debug)
-{
- console.log('Body preUpdate AFTER integration x:', this.x, 'y:', this.y, 'left:', this.left, 'right:', this.right);
- console.log('Body preUpdate velocity:', this.velocity.x, this.velocity.y);
-}
-
- },
-
- /**
- * Internal method that checks and potentially resets the blocked status flags.
- *
- * @method Phaser.Physics.Arcade#checkBlocked
- * @protected
- */
- checkBlocked: function () {
-
- if ((this.blocked.left || this.blocked.right) && (Math.floor(this.x) !== this.blocked.x || Math.floor(this.y) !== this.blocked.y))
- {
- // console.log('resetBlocked unlocked left + right', Math.floor(this.x), this.blocked.x);
- this.blocked.left = false;
- this.blocked.right = false;
- }
-
- if ((this.blocked.up || this.blocked.down) && (Math.floor(this.x) !== this.blocked.x || Math.floor(this.y) !== this.blocked.y))
- {
- // console.log('resetBlocked unlocked up + down', Math.floor(this.y), this.blocked.y, 'x', Math.floor(this.x), this.blocked.x);
- this.blocked.up = false;
- this.blocked.down = false;
- }
-
- },
-
- /**
- * Internal method that updates the left, right, top, bottom, width and height properties.
- *
- * @method Phaser.Physics.Arcade#updateBounds
- * @protected
- */
- updateBounds: function () {
-
- if (this.type === Phaser.Physics.Arcade.CIRCLE)
- {
- this.left = this.shape.pos.x - this.shape.r;
- this.right = this.shape.pos.x + this.shape.r;
- this.top = this.shape.pos.y - this.shape.r;
- this.bottom = this.shape.pos.y + this.shape.r;
- }
- else
- {
- this.left = Phaser.Math.minProperty('x', this.polygon.points) + this.polygon.pos.x;
- this.right = Phaser.Math.maxProperty('x', this.polygon.points) + this.polygon.pos.x;
- this.top = Phaser.Math.minProperty('y', this.polygon.points) + this.polygon.pos.y;
- this.bottom = Phaser.Math.maxProperty('y', this.polygon.points) + this.polygon.pos.y;
- }
-
- this.width = this.right - this.left;
- this.height = this.bottom - this.top;
-
- },
-
- /**
- * Internal method that checks the acceleration and applies damping if not set.
- *
- * @method Phaser.Physics.Arcade#applyDamping
- * @protected
- */
- applyDamping: function () {
-
- if (this.linearDamping > 0 && this.acceleration.isZero())
- {
- if (this.speed > this.linearDamping)
- {
- this.speed -= this.linearDamping;
- }
- else
- {
- this.speed = 0;
- }
-
- // Don't bother if speed 0
- if (this.speed > 0)
- {
- this.velocity.x = Math.cos(this.angle) * this.speed;
- this.velocity.y = Math.sin(this.angle) * this.speed;
-
- this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
- this.angle = Math.atan2(this.velocity.y, this.velocity.x);
- }
- }
-
- },
-
- /**
- * Check if we're below minVelocity and gravity isn't trying to drag us in the opposite direction.
- *
- * @method Phaser.Physics.Arcade#reboundCheck
- * @protected
- * @param {boolean} x - Check the X axis?
- * @param {boolean} y - Check the Y axis?
- * @param {boolean} rebound - If true it will reverse the velocity on the given axis
- */
- reboundCheck: function (x, y, rebound) {
-
- if (this.sprite.debug)
- {
- console.log('reboundCheck start', this.velocity.x, this.velocity.y);
- console.log('reBound blocked state', this.blocked);
- }
-
- if (x)
- {
- if (rebound && this.bounce.x !== 0 && (this.blocked.left || this.blocked.right || this.touching.left || this.touching.right))
- {
- // Don't rebound if they've already rebounded in this frame
- if (!(this._vx <= 0 && this.velocity.x > 0) && !(this._vx >= 0 && this.velocity.x < 0))
- {
- this.velocity.x *= -this.bounce.x;
- this.angle = Math.atan2(this.velocity.y, this.velocity.x);
-
- if (this.sprite.debug)
- {
- console.log('X rebound applied', this._vx, 'to', this.velocity.x);
- }
- }
- }
-
- if (this.bounce.x === 0 || Math.abs(this.velocity.x) < this.minVelocity.x)
- {
- var gx = this.getUpwardForce();
-
- if (((this.blocked.left || this.touching.left) && (gx < 0 || this.velocity.x < 0)) || ((this.blocked.right || this.touching.right) && (gx > 0 || this.velocity.x > 0)))
- {
- this.velocity.x = 0;
-
- if (this.sprite.debug)
- {
- console.log('reboundCheck X zeroed');
- }
- }
-
- if (this.sprite.debug)
- {
- console.log('reboundCheck X', this.velocity.x, 'gravity', gx);
- }
- }
- }
-
- if (y)
- {
- if (rebound && this.bounce.y !== 0 && (this.blocked.up || this.blocked.down || this.touching.up || this.touching.down))
- {
- // Don't rebound if they've already rebounded in this frame
- if (!(this._vy <= 0 && this.velocity.y > 0) && !(this._vy >= 0 && this.velocity.y < 0))
- {
- this.velocity.y *= -this.bounce.y;
- this.angle = Math.atan2(this.velocity.y, this.velocity.x);
-
- if (this.sprite.debug)
- {
- console.log('Y rebound applied', this._vy, 'to', this.velocity.y);
- console.log('Y rebound check 1', !(this._vy <= 0 && this.velocity.y > 0));
- console.log('Y rebound check 2', !(this._vy >= 0 && this.velocity.y < 0));
- }
- }
- }
-
- if (this.bounce.y === 0 || Math.abs(this.velocity.y) < this.minVelocity.y)
- {
- var gy = this.getDownwardForce();
-
- if (((this.blocked.up || this.touching.up) && (gy < 0 || this.velocity.y < 0)) || ((this.blocked.down || this.touching.down) && (gy > 0 || this.velocity.y > 0)))
- {
- this.velocity.y = 0;
-
- if (this.sprite.debug)
- {
- console.log('reboundCheck Y zeroed');
- }
- }
-
- if (this.sprite.debug)
- {
- console.log('reboundCheck Y', this.velocity.y, 'gravity', gy);
- }
- }
- }
-
- },
-
- /**
- * Gets the total force being applied on the X axis, including gravity and velocity.
- *
- * @method Phaser.Physics.Arcade#getUpwardForce
- * @return {number} The total force being applied on the X axis.
- */
- getUpwardForce: function () {
-
- if (this.allowGravity)
- {
- return this.gravity.x + this.game.physics.gravity.x + this.velocity.x;
- }
- else
- {
- return this.gravity.x + this.velocity.x;
- }
-
- },
-
- /**
- * Gets the total force being applied on the X axis, including gravity and velocity.
- *
- * @method Phaser.Physics.Arcade#getDownwardForce
- * @return {number} The total force being applied on the Y axis.
- */
- getDownwardForce: function () {
-
- if (this.allowGravity)
- {
- return this.gravity.y + this.game.physics.gravity.y + this.velocity.y;
- }
- else
- {
- return this.gravity.y + this.velocity.y;
- }
-
- },
-
- /**
- * Subtracts the given Vector from this Body.
- *
- * @method Phaser.Physics.Arcade#sub
- * @protected
- * @param {SAT.Vector} v - The vector to substract from this Body.
- */
- sub: function (v) {
-
- this.x -= v.x;
- this.y -= v.y;
-
- },
-
- /**
- * Adds the given Vector to this Body.
- *
- * @method Phaser.Physics.Arcade#add
- * @protected
- * @param {SAT.Vector} v - The vector to add to this Body.
- */
- add: function (v) {
-
- this.x += v.x;
- this.y += v.y;
-
- },
-
- /**
- * Separation response handler.
- *
- * @method Phaser.Physics.Arcade#give
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- * @param {SAT.Response} response - The SAT Response object containing the collision data.
- */
- give: function (body, response) {
-
- this.add(response.overlapV);
-
- if (this.rebound)
- {
- this.processRebound(body);
- this.reboundCheck(true, true, false);
- body.reboundCheck(true, true, false);
- }
-
- },
-
- /**
- * Separation response handler.
- *
- * @method Phaser.Physics.Arcade#take
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- * @param {SAT.Response} response - The SAT Response object containing the collision data.
- */
- take: function (body, response) {
-
- this.sub(response.overlapV);
-
- if (this.rebound)
- {
- this.processRebound(body);
- this.reboundCheck(true, true, false);
- body.reboundCheck(true, true, false);
- }
-
- },
-
- /**
- * Split the collision response evenly between the two bodies.
- *
- * @method Phaser.Physics.Arcade#split
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- * @param {SAT.Response} response - The SAT Response object containing the collision data.
- */
- split: function (body, response) {
-
- response.overlapV.scale(0.5);
- this.sub(response.overlapV);
- body.add(response.overlapV);
-
- if (this.rebound)
- {
- this.exchange(body);
- this.reboundCheck(true, true, false);
- body.reboundCheck(true, true, false);
- }
-
- },
-
- /**
- * Exchange velocity with the given Body.
- *
- * @method Phaser.Physics.Arcade#exchange
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- */
- exchange: function (body) {
-
- if (this.mass === body.mass && this.speed > 0 && body.speed > 0)
- {
- // A direct velocity exchange (as they are both moving and have the same mass)
- this._dx = body.velocity.x;
- this._dy = body.velocity.y;
-
- body.velocity.x = this.velocity.x * body.bounce.x;
- body.velocity.y = this.velocity.y * body.bounce.x;
-
- this.velocity.x = this._dx * this.bounce.x;
- this.velocity.y = this._dy * this.bounce.y;
- }
- else
- {
- var nv1 = Math.sqrt((body.velocity.x * body.velocity.x * body.mass) / this.mass) * ((body.velocity.x > 0) ? 1 : -1);
- var nv2 = Math.sqrt((this.velocity.x * this.velocity.x * this.mass) / body.mass) * ((this.velocity.x > 0) ? 1 : -1);
- var average = (nv1 + nv2) * 0.5;
- nv1 -= average;
- nv2 -= average;
-
- this.velocity.x = nv1;
- body.velocity.x = nv2;
-
- nv1 = Math.sqrt((body.velocity.y * body.velocity.y * body.mass) / this.mass) * ((body.velocity.y > 0) ? 1 : -1);
- nv2 = Math.sqrt((this.velocity.y * this.velocity.y * this.mass) / body.mass) * ((this.velocity.y > 0) ? 1 : -1);
- average = (nv1 + nv2) * 0.5;
- nv1 -= average;
- nv2 -= average;
-
- this.velocity.y = nv1;
- body.velocity.y = nv2;
- }
-
- // update speed / angle?
-
- },
-
- /**
- * Rebound the velocity of this Body.
- *
- * @method Phaser.Physics.Arcade#processRebound
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- */
- processRebound: function (body) {
-
- // Don't rebound again if they've already rebounded in this frame
- if (!(this._vx <= 0 && this.velocity.x > 0) && !(this._vx >= 0 && this.velocity.x < 0))
- {
- this.velocity.x = body.velocity.x - this.velocity.x * this.bounce.x;
- }
-
- if (!(this._vy <= 0 && this.velocity.y > 0) && !(this._vy >= 0 && this.velocity.y < 0))
- {
- this.velocity.y = body.velocity.y - this.velocity.y * this.bounce.y;
- }
-
- this.angle = Math.atan2(this.velocity.y, this.velocity.x);
-
- this.reboundCheck(true, true, false);
-
- },
-
- /**
- * Checks for an overlap between this Body and the given Body.
- *
- * @method Phaser.Physics.Arcade#overlap
- * @param {Phaser.Physics.Arcade.Body} body - The Body that is being checked against this Body.
- * @param {SAT.Response} response - SAT Response handler.
- * @return {boolean} True if the two bodies overlap, otherwise false.
- */
- overlap: function (body, response) {
-
- var result = false;
-
- if ((this.type === Phaser.Physics.Arcade.RECT || this.type === Phaser.Physics.Arcade.POLYGON) && (body.type === Phaser.Physics.Arcade.RECT || body.type === Phaser.Physics.Arcade.POLYGON))
- {
- result = SAT.testPolygonPolygon(this.polygon, body.polygon, response);
- }
- else if (this.type === Phaser.Physics.Arcade.CIRCLE && body.type === Phaser.Physics.Arcade.CIRCLE)
- {
- result = SAT.testCircleCircle(this.shape, body.shape, response);
- }
- else if ((this.type === Phaser.Physics.Arcade.RECT || this.type === Phaser.Physics.Arcade.POLYGON) && body.type === Phaser.Physics.Arcade.CIRCLE)
- {
- result = SAT.testPolygonCircle(this.polygon, body.shape, response);
- }
- else if (this.type === Phaser.Physics.Arcade.CIRCLE && (body.type === Phaser.Physics.Arcade.RECT || body.type === Phaser.Physics.Arcade.POLYGON))
- {
- result = SAT.testCirclePolygon(this.shape, body.polygon, response);
- }
-
- if (!result)
- {
- this.removeContact(body);
- }
-
- return result;
-
- },
-
- /**
- * Checks if this Body is already in contact with the given Body.
- *
- * @method Phaser.Physics.Arcade#inContact
- * @param {Phaser.Physics.Arcade.Body} body - The Body to be checked.
- * @return {boolean} True if the given Body is already in contact with this Body.
- */
- inContact: function (body) {
-
- return (this.contacts.indexOf(body) != -1);
-
- },
-
- /**
- * Adds the given Body to the contact list of this Body. Also adds this Body to the contact list of the given Body.
- *
- * @method Phaser.Physics.Arcade#addContact
- * @param {Phaser.Physics.Arcade.Body} body - The Body to be added.
- * @return {boolean} True if the given Body was added to this contact list, false if already on it.
- */
- addContact: function (body) {
-
- if (this.inContact(body))
- {
- return false;
- }
-
- this.contacts.push(body);
-
- this.sprite.events.onBeginContact.dispatch(this.sprite, body.sprite, this, body);
-
- body.addContact(this);
-
- return true;
-
- },
-
- /**
- * Removes the given Body from the contact list of this Body. Also removes this Body from the contact list of the given Body.
- *
- * @method Phaser.Physics.Arcade#removeContact
- * @param {Phaser.Physics.Arcade.Body} body - The Body to be removed.
- * @return {boolean} True if the given Body was removed from this contact list, false if wasn't on it.
- */
- removeContact: function (body) {
-
- if (!this.inContact(body))
- {
- return false;
- }
-
- this.contacts.splice(this.contacts.indexOf(body), 1);
-
- this.sprite.events.onEndContact.dispatch(this.sprite, body.sprite, this, body);
-
- body.removeContact(this);
-
- return true;
-
- },
-
- /**
- * This separates this Body from the given Body unless a customSeparateCallback is set.
- * It assumes they have already been overlap checked and the resulting overlap is stored in the SAT response.
- *
- * @method Phaser.Physics.Arcade#separate
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body to be separated from this one.
- * @param {SAT.Response} response - SAT Response handler.
- * @return {boolean} True if the bodies were separated, false if not (for example checkCollide allows them to pass through)
- */
- separate: function (body, response) {
-
- if (this.inContact(body))
- {
- return false;
- }
-
- this._distances[0] = body.right - this.x; // Distance of B to face on left side of A
- this._distances[1] = this.right - body.x; // Distance of B to face on right side of A
- this._distances[2] = body.bottom - this.y; // Distance of B to face on bottom side of A
- this._distances[3] = this.bottom - body.y; // Distance of B to face on top side of A
-
- // If we've zero distance then check for side-slicing
- if (response.overlapN.x && (this._distances[0] === 0 || this._distances[1] === 0))
- {
- response.overlapN.x = false;
- response.overlapN.y = true;
- }
- else if (response.overlapN.y && (this._distances[2] === 0 || this._distances[3] === 0))
- {
- response.overlapN.x = true;
- response.overlapN.y = false;
- }
-
- if (this.customSeparateCallback)
- {
- return this.customSeparateCallback.call(this.customSeparateContext, this, response, this._distances);
- }
-
- var hasSeparated = false;
-
- if (response.overlapN.x)
- {
- // Which is smaller? Left or Right?
- if (this._distances[0] < this._distances[1] && (body.checkCollision.right || this.checkCollision.left))
- {
- // console.log(this.sprite.name, 'collided on the LEFT with', body.sprite.name, response);
- hasSeparated = this.hitLeft(body, response);
- }
- else if (this._distances[1] < this._distances[0] && (body.checkCollision.left || this.checkCollision.right))
- {
- // console.log(this.sprite.name, 'collided on the RIGHT with', body.sprite.name, response);
- hasSeparated = this.hitRight(body, response);
- }
- }
- else if (response.overlapN.y)
- {
- // Which is smaller? Top or Bottom?
- if (this._distances[2] < this._distances[3] && (body.checkCollision.down || this.checkCollision.up))
- {
- // console.log(this.sprite.name, 'collided on the TOP with', body.sprite.name, response);
- hasSeparated = this.hitTop(body, response);
- }
- else if (this._distances[3] < this._distances[2] && (body.checkCollision.up || this.checkCollision.down))
- {
- // console.log(this.sprite.name, 'collided on the BOTTOM with', body.sprite.name, response);
- hasSeparated = this.hitBottom(body, response);
- }
- }
-
- if (hasSeparated)
- {
- console.log('Body hasSeparated');
- this.game.physics.checkBounds(this);
- this.game.physics.checkBounds(body);
- }
- else
- {
- // They can only contact like this if at least one of their sides is open, otherwise it's a separation
- if (!this.checkCollision.up || !this.checkCollision.down || !this.checkCollision.left || !this.checkCollision.right || !body.checkCollision.up || !body.checkCollision.down || !body.checkCollision.left || !body.checkCollision.right)
- {
- this.addContact(body);
- }
- }
-
- return hasSeparated;
-
- },
-
- /**
- * Process a collision with the left face of this Body.
- * Collision and separation can be further checked by setting a collideCallback.
- * This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
- * If the callback returns true then separation, rebounds and the touching flags will all be set.
- * If it returns false this will be skipped and must be handled manually.
- *
- * @method Phaser.Physics.Arcade#hitLeft
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- * @param {SAT.Response} response - The SAT Response object containing the collision data.
- */
- hitLeft: function (body, response) {
-
- if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.LEFT, this, body, response))
- {
- return;
- }
-
- if (!this.moves || this.immovable || this.blocked.right || this.touching.right)
- {
- body.give(this, response);
- }
- else
- {
- if (body.immovable || body.blocked.left || body.touching.left)
- {
- // We take the full separation
- this.take(body, response);
- }
- else
- {
- // Share out the separation
- this.split(body, response);
- }
- }
-
- this.touching.left = true;
- body.touching.right = true;
-
- },
-
- /**
- * Process a collision with the right face of this Body.
- * Collision and separation can be further checked by setting a collideCallback.
- * This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
- * If the callback returns true then separation, rebounds and the touching flags will all be set.
- * If it returns false this will be skipped and must be handled manually.
- *
- * @method Phaser.Physics.Arcade#hitRight
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- * @param {SAT.Response} response - The SAT Response object containing the collision data.
- */
- hitRight: function (body, response) {
-
- if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.RIGHT, this, body))
- {
- return;
- }
-
- if (!this.moves || this.immovable || this.blocked.left || this.touching.left)
- {
- body.give(this, response);
- }
- else
- {
- if (body.immovable || body.blocked.right || body.touching.right)
- {
- // We take the full separation
- this.take(body, response);
- }
- else
- {
- // Share out the separation
- this.split(body, response);
- }
- }
-
- this.touching.right = true;
- body.touching.left = true;
-
- },
-
- /**
- * Process a collision with the top face of this Body.
- * Collision and separation can be further checked by setting a collideCallback.
- * This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
- * If the callback returns true then separation, rebounds and the touching flags will all be set.
- * If it returns false this will be skipped and must be handled manually.
- *
- * @method Phaser.Physics.Arcade#hitTop
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- * @param {SAT.Response} response - The SAT Response object containing the collision data.
- */
- hitTop: function (body, response) {
-
- if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.UP, this, body))
- {
- return false;
- }
-
- if (!this.moves || this.immovable || this.blocked.down || this.touching.down)
- {
- body.give(this, response);
- }
- else
- {
- if (body.immovable || body.blocked.up || body.touching.up)
- {
- // We take the full separation
- this.take(body, response);
- }
- else
- {
- // Share out the separation
- this.split(body, response);
- }
- }
-
- this.touching.up = true;
- body.touching.down = true;
-
- return true;
-
- },
-
- /**
- * Process a collision with the bottom face of this Body.
- * Collision and separation can be further checked by setting a collideCallback.
- * This callback will be sent 4 parameters: The face of collision, this Body, the colliding Body and the SAT Response.
- * If the callback returns true then separation, rebounds and the touching flags will all be set.
- * If it returns false this will be skipped and must be handled manually.
- *
- * @method Phaser.Physics.Arcade#hitBottom
- * @protected
- * @param {Phaser.Physics.Arcade.Body} body - The Body that collided.
- * @param {SAT.Response} response - The SAT Response object containing the collision data.
- */
- hitBottom: function (body, response) {
-
- if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.DOWN, this, body))
- {
- return false;
- }
-
- if (!this.moves || this.immovable || this.blocked.up || this.touching.up)
- {
- body.give(this, response);
- }
- else
- {
- if (body.immovable || body.blocked.down || body.touching.down)
- {
- // We take the full separation
- this.take(body, response);
- }
- else
- {
- // Share out the separation
- this.split(body, response);
- }
- }
-
- this.touching.down = true;
- body.touching.up = true;
-
- return true;
-
- },
-
- /**
- * Internal method. Integrates velocity, global gravity and the delta timer.
- *
- * @method Phaser.Physics.Arcade#integrateVelocity
- * @protected
- */
- integrateVelocity: function () {
-
- this._temp = this.game.physics.updateMotion(this);
- this._dx = this.game.time.physicsElapsed * (this.velocity.x + this._temp.x / 2);
- this._dy = this.game.time.physicsElapsed * (this.velocity.y + this._temp.y / 2);
-
- if (this.sprite.debug)
- {
- // console.log('integrateVelocity TEMP:', this._temp.x, this._temp.y);
- }
-
- // positive = RIGHT / DOWN
- // negative = LEFT / UP
-
- if ((this._dx < 0 && !this.blocked.left && !this.touching.left) || (this._dx > 0 && !this.blocked.right && !this.touching.right))
- {
- this.x += this._dx;
- this.velocity.x += this._temp.x;
- if (this.sprite.debug)
- {
- // console.log('integrateVelocity x added', this._dx, this.x);
- }
- }
- else
- {
- if (this.sprite.debug)
- {
- // console.log('integrateVelocity x failed or zero, blocked left/right', this._dx);
- }
- }
-
- if ((this._dy < 0 && !this.blocked.up && !this.touching.up) || (this._dy > 0 && !this.blocked.down && !this.touching.down))
- {
- this.y += this._dy;
- this.velocity.y += this._temp.y;
- if (this.sprite.debug)
- {
- // console.log('integrateVelocity y added', this._dy, this.y);
- }
- }
- else
- {
- if (this.sprite.debug)
- {
- // console.log('integrateVelocity y failed or zero, blocked up/down', this._dy);
- }
- }
-
- if (this.velocity.x > this.maxVelocity.x)
- {
- this.velocity.x = this.maxVelocity.x;
- }
- else if (this.velocity.x < -this.maxVelocity.x)
- {
- this.velocity.x = -this.maxVelocity.x;
- }
-
- if (this.velocity.y > this.maxVelocity.y)
- {
- this.velocity.y = this.maxVelocity.y;
- }
- else if (this.velocity.y < -this.maxVelocity.y)
- {
- this.velocity.y = -this.maxVelocity.y;
- }
-
- },
-
- /**
- * Internal method. This is called directly before the sprites are sent to the renderer and after the update function has finished.
- *
- * @method Phaser.Physics.Arcade#postUpdate
- * @protected
- */
- postUpdate: function () {
-
- if (this.moves)
- {
- this.reboundCheck(true, true, true);
-
- this.game.physics.checkBounds(this);
-
- this._dx = this.deltaX();
- this._dy = this.deltaY();
-
- if (this._dx < 0)
- {
- this.facing = Phaser.LEFT;
- }
- else if (this._dx > 0)
- {
- this.facing = Phaser.RIGHT;
- }
-
- if (this._dy < 0)
- {
- this.facing = Phaser.UP;
- }
- else if (this._dy > 0)
- {
- this.facing = Phaser.DOWN;
- }
-
- if (this._dx !== 0 || this._dy !== 0)
- {
- this.sprite.x += this._dx;
- this.sprite.y += this._dy;
- }
-
- if (this.allowRotation && this.deltaZ() !== 0)
- {
- this.sprite.angle += this.deltaZ();
- }
-
- if (this.sprite.scale.x !== this._sx || this.sprite.scale.y !== this._sy)
- {
- this.updateScale();
- }
-
- }
-
- },
-
- /**
- * Resets the Body motion values: velocity, acceleration, angularVelocity and angularAcceleration.
- * Also resets the forces to defaults: gravity, bounce, minVelocity,maxVelocity, angularDrag, maxAngular, mass, friction and checkCollision if 'full' specified.
- *
- * @method Phaser.Physics.Arcade#reset
- * @param {boolean} [full=false] - A full reset clears down settings you may have set, such as gravity, bounce and drag. A non-full reset just clears motion values.
- */
- reset: function (full) {
-
- if (typeof full === 'undefined') { full = false; }
-
- if (full)
- {
- this.gravity.setTo(0, 0);
- this.bounce.setTo(0, 0);
- this.minVelocity.setTo(5, 5);
- this.maxVelocity.setTo(1000, 1000);
- this.angularDrag = 0;
- this.maxAngular = 1000;
- this.mass = 1;
- this.friction = 0.0;
- this.checkCollision = { none: false, any: true, up: true, down: true, left: true, right: true };
- }
-
- this.velocity.setTo(0, 0);
- this.acceleration.setTo(0, 0);
- this.angularVelocity = 0;
- this.angularAcceleration = 0;
- this.blocked = { x: 0, y: 0, up: false, down: false, left: false, right: false };
- this.x = (this.sprite.world.x - (this.sprite.anchor.x * this.sprite.width)) + this.offset.x;
- this.y = (this.sprite.world.y - (this.sprite.anchor.y * this.sprite.height)) + this.offset.y;
- this.preX = this.x;
- this.preY = this.y;
- this.updateBounds();
-
- this.contacts.length = 0;
-
- },
-
- /**
- * Destroys this Body and all references it holds to other objects.
- *
- * @method Phaser.Physics.Arcade#destroy
- */
- destroy: function () {
-
- this.sprite = null;
-
- this.collideCallback = null;
- this.collideCallbackContext = null;
-
- this.customSeparateCallback = null;
- this.customSeparateContext = null;
-
- this.contacts.length = 0;
-
- },
-
- /**
- * Sets this Body to use a circle of the given radius for all collision.
- * The Circle will be centered on the center of the Sprite by default, but can be adjusted via the Body.offset property and the setCircle x/y parameters.
- *
- * @method Phaser.Physics.Arcade#setCircle
- * @param {number} radius - The radius of this circle (in pixels)
- * @param {number} [offsetX=0] - The x amount the circle will be offset from the Sprites center.
- * @param {number} [offsetY=0] - The y amount the circle will be offset from the Sprites center.
- */
- setCircle: function (radius, offsetX, offsetY) {
-
- if (typeof offsetX === 'undefined') { offsetX = this.sprite._cache.halfWidth; }
- if (typeof offsetY === 'undefined') { offsetY = this.sprite._cache.halfHeight; }
-
- this.type = Phaser.Physics.Arcade.CIRCLE;
- this.shape = new SAT.Circle(new SAT.Vector(this.sprite.x, this.sprite.y), radius);
- this.polygon = null;
-
- this.offset.setTo(offsetX, offsetY);
-
- },
-
- /**
- * Sets this Body to use a rectangle for all collision.
- * If you don't specify any parameters it will be sized to match the parent Sprites current width and height (including scale factor) and centered on the sprite.
- *
- * @method Phaser.Physics.Arcade#setRectangle
- * @param {number} [width] - The width of the rectangle. If not specified it will default to the width of the parent Sprite.
- * @param {number} [height] - The height of the rectangle. If not specified it will default to the height of the parent Sprite.
- * @param {number} [translateX] - The x amount the rectangle will be translated from the Sprites center.
- * @param {number} [translateY] - The y amount the rectangle will be translated from the Sprites center.
- */
- setRectangle: function (width, height, translateX, translateY) {
-
- if (typeof width === 'undefined') { width = this.sprite.width; }
- if (typeof height === 'undefined') { height = this.sprite.height; }
- if (typeof translateX === 'undefined') { translateX = -this.sprite._cache.halfWidth; }
- if (typeof translateY === 'undefined') { translateY = -this.sprite._cache.halfHeight; }
-
- this.type = Phaser.Physics.Arcade.RECT;
- this.shape = new SAT.Box(new SAT.Vector(this.sprite.world.x, this.sprite.world.y), width, height);
- this.polygon = this.shape.toPolygon();
- this.polygon.translate(translateX, translateY);
-
- this.offset.setTo(0, 0);
-
- },
-
- /**
- * Sets this Body to use a convex polygon for collision.
- * The points are specified in a counter-clockwise direction and must create a convex polygon.
- * Use Body.translate and/or Body.offset to re-position the polygon from the Sprite origin.
- *
- * @method Phaser.Physics.Arcade#setPolygon
- * @param {array|Array|SAT.Vector...|Number...} points - This can be an array of Vectors that form the polygon,
- * a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be
- * all the points of the polygon e.g. `setPolygon(new SAT.Vector(), new SAT.Vector(), ...)`, or the
- * arguments passed can be flat x,y values e.g. `setPolygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.
- */
- setPolygon: function (points) {
-
- this.type = Phaser.Physics.Arcade.POLYGON;
- this.shape = null;
-
- if (!Array.isArray(points))
- {
- points = Array.prototype.slice.call(arguments);
- }
-
- if (typeof points[0] === 'number')
- {
- var p = [];
-
- for (var i = 0, len = points.length; i < len; i += 2)
- {
- p.push(new SAT.Vector(points[i], points[i + 1]));
- }
-
- points = p;
- }
-
- this.polygon = new SAT.Polygon(new SAT.Vector(this.sprite.center.x, this.sprite.center.y), points);
-
- this.offset.setTo(0, 0);
-
- },
-
- /**
- * Used for translating rectangle and polygon bodies from the Sprite parent. Doesn't apply to Circles.
- * See also the Body.offset property.
- *
- * @method Phaser.Physics.Arcade#translate
- * @param {number} x - The x amount the polygon or rectangle will be translated by from the Sprite.
- * @param {number} y - The y amount the polygon or rectangle will be translated by from the Sprite.
- */
- translate: function (x, y) {
-
- if (this.polygon)
- {
- this.polygon.translate(x, y);
- }
-
- },
-
- /**
- * Determines if this Body is 'on the floor', which means in contact with a Tile or World bounds, or other object that has set 'down' as blocked.
- *
- * @method Phaser.Physics.Arcade.Body#onFloor
- * @return {boolean} True if this Body is 'on the floor', which means in contact with a Tile or World bounds, or object that has set 'down' as blocked.
- */
- onFloor: function () {
- return this.blocked.down;
- },
-
- /**
- * Determins if this Body is 'on a wall', which means horizontally in contact with a Tile or World bounds, or other object but not the ground.
- *
- * @method Phaser.Physics.Arcade.Body#onWall
- * @return {boolean} True if this Body is 'on a wall', which means horizontally in contact with a Tile or World bounds, or other object but not the ground.
- */
- onWall: function () {
- return (!this.blocked.down && (this.blocked.left || this.blocked.right));
- },
-
- /**
- * Returns the delta x value. The amount the Body has moved horizontally in the current step.
- *
- * @method Phaser.Physics.Arcade.Body#deltaX
- * @return {number} The delta value. Positive if the motion was to the right, negative if to the left.
- */
- deltaX: function () {
- return this.x - this.preX;
- },
-
- /**
- * Returns the delta y value. The amount the Body has moved vertically in the current step.
- *
- * @method Phaser.Physics.Arcade.Body#deltaY
- * @return {number} The delta value. Positive if the motion was downwards, negative if upwards.
- */
- deltaY: function () {
- return this.y - this.preY;
- },
-
- /**
- * Returns the delta z value. The amount the Body has rotated in the current step.
- *
- * @method Phaser.Physics.Arcade.Body#deltaZ
- * @return {number} The delta value.
- */
- deltaZ: function () {
- return this.rotation - this.preRotation;
- }
-
-};
-
-Phaser.Physics.Arcade.Body.prototype.constructor = Phaser.Physics.Arcade.Body;
-
-/**
-* @name Phaser.Physics.Arcade.Body#x
-* @property {number} x
-*/
-Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "x", {
-
- /**
- * @method x
- * @return {number}
- */
- get: function () {
-
- if (this.type === Phaser.Physics.Arcade.CIRCLE)
- {
- return this.shape.pos.x;
- }
- else
- {
- return this.polygon.pos.x;
- }
-
- },
-
- /**
- * @method x
- * @param {number} value
- */
- set: function (value) {
-
- if (this.type === Phaser.Physics.Arcade.CIRCLE)
- {
- this.shape.pos.x = value;
- }
- else
- {
- this.polygon.pos.x = value;
- }
-
- }
-
-});
-
-/**
-* @name Phaser.Physics.Arcade.Body#y
-* @property {number} y
-*/
-Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "y", {
-
- /**
- * @method y
- * @return {number}
- */
- get: function () {
-
- if (this.type === Phaser.Physics.Arcade.CIRCLE)
- {
- return this.shape.pos.y;
- }
- else
- {
- return this.polygon.pos.y;
- }
-
- },
-
- /**
- * @method y
- * @param {number} value
- */
- set: function (value) {
-
- if (this.type === Phaser.Physics.Arcade.CIRCLE)
- {
- this.shape.pos.y = value;
- }
- else
- {
- this.polygon.pos.y = value;
- }
-
- }
-
-});
diff --git a/wip/CameraFX/Border.ts b/wip/CameraFX/Border.ts
deleted file mode 100644
index 6f964210..00000000
--- a/wip/CameraFX/Border.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-///
-///
-
-/**
-* Phaser - Plugins - Camera FX - Border
-*
-* Creates a border around a camera.
-*/
-
-module Phaser.Plugins.CameraFX {
-
- export class Border extends Phaser.Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- super(game, parent);
- this.camera = parent;
-
- }
-
- public camera: Phaser.Camera;
-
- /**
- * Whether render border of this camera or not. (default is true)
- * @type {bool}
- */
- public showBorder: bool = true;
-
- /**
- * Color of border of this camera. (in css color string)
- * @type {string}
- */
- public borderColor: string = 'rgb(255,255,255)';
-
- public postRender() {
-
- if (this.showBorder == true)
- {
- this.game.stage.context.strokeStyle = this.borderColor;
- this.game.stage.context.lineWidth = 1;
- this.game.stage.context.rect(this.camera.x, this.camera.y, this.camera.width, this.camera.height);
- this.game.stage.context.stroke();
- }
-
- }
-
- }
-
-}
diff --git a/wip/CameraFX/Fade.ts b/wip/CameraFX/Fade.ts
deleted file mode 100644
index 07398795..00000000
--- a/wip/CameraFX/Fade.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-///
-///
-
-/**
-* Phaser - Plugins - Camera FX - Fade
-*
-* The camera is filled with the given color and returns to normal at the given duration.
-*/
-
-module Phaser.Plugins.CameraFX {
-
- export class Fade extends Phaser.Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- super(game, parent);
- this.camera = parent;
-
- }
-
- public camera: Phaser.Camera;
-
- private _fxFadeColor: string;
- private _fxFadeComplete = null;
- private _fxFadeDuration: number = 0;
- private _fxFadeAlpha: number = 0;
-
- /**
- * The camera is gradually filled with this color.
- *
- * @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
- * @param Duration How long it takes for the flash to fade.
- * @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
- * @param Force Force an already running flash effect to reset.
- */
- public start(color: number = 0x000000, duration: number = 1, onComplete = null, force: bool = false) {
-
- if (force === false && this._fxFadeAlpha > 0)
- {
- // You can't fade again unless you force it
- return;
- }
-
- if (duration <= 0)
- {
- duration = 1;
- }
-
- var red = color >> 16 & 0xFF;
- var green = color >> 8 & 0xFF;
- var blue = color & 0xFF;
-
- this._fxFadeColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
- this._fxFadeDuration = duration;
- this._fxFadeAlpha = 0.01;
- this._fxFadeComplete = onComplete;
-
- }
-
- public postUpdate() {
-
- // Update the Fade effect
- if (this._fxFadeAlpha > 0)
- {
- this._fxFadeAlpha += this.game.time.elapsed / this._fxFadeDuration;
-
- if (this.game.math.roundTo(this._fxFadeAlpha, -2) >= 1)
- {
- this._fxFadeAlpha = 1;
-
- if (this._fxFadeComplete !== null)
- {
- this._fxFadeComplete();
- }
- }
- }
-
- }
-
- public postRender() {
-
- // "Fade" FX
- if (this._fxFadeAlpha > 0)
- {
- this.game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
- this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
- }
-
- }
-
- }
-
-}
diff --git a/wip/CameraFX/Flash.ts b/wip/CameraFX/Flash.ts
deleted file mode 100644
index 7429e86f..00000000
--- a/wip/CameraFX/Flash.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-///
-///
-
-/**
-* Phaser - Plugins - Camera FX - Flash
-*
-* The camera is filled with the given color and returns to normal at the given duration.
-*/
-
-module Phaser.Plugins.CameraFX {
-
- export class Flash extends Phaser.Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- super(game, parent);
- this.camera = parent;
-
- }
-
- public camera: Phaser.Camera;
-
- private _fxFlashColor: string;
- private _fxFlashComplete = null;
- private _fxFlashDuration: number = 0;
- private _fxFlashAlpha: number = 0;
-
- /**
- * The camera is filled with this color and returns to normal at the given duration.
- *
- * @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
- * @param Duration How long it takes for the flash to fade.
- * @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
- * @param Force Force an already running flash effect to reset.
- */
- public start(color: number = 0xffffff, duration: number = 1, onComplete = null, force: bool = false) {
-
- if (force === false && this._fxFlashAlpha > 0)
- {
- // You can't flash again unless you force it
- return;
- }
-
- if (duration <= 0)
- {
- duration = 1;
- }
-
- var red = color >> 16 & 0xFF;
- var green = color >> 8 & 0xFF;
- var blue = color & 0xFF;
-
- this._fxFlashColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
- this._fxFlashDuration = duration;
- this._fxFlashAlpha = 1;
- this._fxFlashComplete = onComplete;
-
- }
-
- public postUpdate() {
-
- // Update the Flash effect
- if (this._fxFlashAlpha > 0)
- {
- this._fxFlashAlpha -= this.game.time.elapsed / this._fxFlashDuration;
-
- if (this.game.math.roundTo(this._fxFlashAlpha, -2) <= 0)
- {
- this._fxFlashAlpha = 0;
-
- if (this._fxFlashComplete !== null)
- {
- this._fxFlashComplete();
- }
- }
- }
-
- }
-
- public postRender() {
-
- if (this._fxFlashAlpha > 0)
- {
- this.game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
- this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
- }
-
- }
-
- }
-
-}
diff --git a/wip/CameraFX/Mirror.ts b/wip/CameraFX/Mirror.ts
deleted file mode 100644
index a3a97c17..00000000
--- a/wip/CameraFX/Mirror.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-///
-///
-
-/**
-* Phaser - Plugins - Camera FX - Mirrir
-*
-* Give your game that classic retro feel!
-*/
-
-module Phaser.Plugins.CameraFX {
-
- export class Mirror extends Phaser.Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- super(game, parent);
- this.camera = parent;
-
- this._canvas = document.createElement('canvas');
- this._canvas.width = parent.width;
- this._canvas.height = parent.height;
- this._context = this._canvas.getContext('2d');
-
- }
-
- private _canvas: HTMLCanvasElement;
- private _context: CanvasRenderingContext2D;
-
- private _sx: number;
- private _sy: number;
- private _mirrorX: number;
- private _mirrorY: number;
- private _mirrorWidth: number;
- private _mirrorHeight: number;
- private _mirrorColor: string = null;
-
- public camera: Phaser.Camera;
-
- public flipX: bool = false;
- public flipY: bool = true;
-
- public x: number;
- public y: number;
- public cls: bool = false;
-
- /**
- * This is the rectangular region to grab from the Camera used in the Mirror effect
- * It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
- */
- public start(x: number, y: number, region: Phaser.Rectangle, fillColor: string = 'rgba(0, 0, 100, 0.5)') {
-
- this.x = x;
- this.y = y;
-
- this._mirrorX = region.x;
- this._mirrorY = region.y;
- this._mirrorWidth = region.width;
- this._mirrorHeight = region.height;
-
- if (fillColor)
- {
- this._mirrorColor = fillColor;
- this._context.fillStyle = this._mirrorColor;
- }
-
- }
-
- public postRender() {
-
- this._sx = this.camera.screenView.x + this._mirrorX;
- this._sy = this.camera.screenView.y + this._mirrorY;
-
- if (this.flipX == true && this.flipY == false)
- {
- this._sx = 0;
- }
- else if (this.flipY == true && this.flipX == false)
- {
- this._sy = 0;
- }
-
- this._context.drawImage(
- this.game.stage.canvas,
- this._sx,
- this._sy,
- this._mirrorWidth,
- this._mirrorHeight,
- 0,
- 0,
- this._mirrorWidth,
- this._mirrorHeight
- );
-
- if (this._mirrorColor)
- {
- this._context.fillRect(0, 0, this._mirrorWidth, this._mirrorHeight);
- }
-
- if (this.flipX || this.flipY)
- {
- this.game.stage.context.save();
- }
-
- if (this.flipX && this.flipY)
- {
- this.game.stage.context.transform(-1, 0, 0, -1, this._mirrorWidth, this._mirrorHeight);
- this.game.stage.context.drawImage(this._canvas, -this.x, -this.y);
- }
- else if (this.flipX)
- {
- this.game.stage.context.transform(-1, 0, 0, 1, this._mirrorWidth, 0);
- this.game.stage.context.drawImage(this._canvas, -this.x, this.y);
- }
- else if (this.flipY)
- {
- this.game.stage.context.transform(1, 0, 0, -1, 0, this._mirrorHeight);
- this.game.stage.context.drawImage(this._canvas, this.x, -this.y);
- }
-
- if (this.flipX || this.flipY)
- {
- this.game.stage.context.restore();
- }
-
- }
-
- }
-
-}
diff --git a/wip/CameraFX/Scanlines.ts b/wip/CameraFX/Scanlines.ts
deleted file mode 100644
index 7d386720..00000000
--- a/wip/CameraFX/Scanlines.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-///
-///
-
-/**
-* Phaser - Plugins - Camera FX - Scanlines
-*
-* Give your game that classic retro feel!
-*/
-
-module Phaser.Plugins.CameraFX {
-
- export class Scanlines extends Phaser.Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- super(game, parent);
- this.camera = parent;
-
- }
-
- public camera: Phaser.Camera;
-
- public spacing: number = 4;
- public color: string = 'rgba(0, 0, 0, 0.3)';
-
- public postRender() {
-
- this.game.stage.context.fillStyle = this.color;
-
- for (var y = this.camera.screenView.y; y < this.camera.screenView.height; y += this.spacing)
- {
- this.game.stage.context.fillRect(this.camera.screenView.x, y, this.camera.screenView.width, 1);
- }
- }
-
- }
-
-}
diff --git a/wip/CameraFX/Shadow.ts b/wip/CameraFX/Shadow.ts
deleted file mode 100644
index b44436c8..00000000
--- a/wip/CameraFX/Shadow.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-///
-///
-
-/**
-* Phaser - Plugins - Camera FX - Shadow
-*
-* Creates a drop shadow effect on the camera window.
-*/
-
-module Phaser.Plugins.CameraFX {
-
- export class Shadow extends Phaser.Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- super(game, parent);
- this.camera = parent;
-
- }
-
- public camera: Phaser.Camera;
-
- /**
- * Render camera shadow or not. (default is false)
- * @type {bool}
- */
- public showShadow: bool = false;
-
- /**
- * Color of shadow, in css color string.
- * @type {string}
- */
- public shadowColor: string = 'rgb(0,0,0)';
-
- /**
- * Blur factor of shadow.
- * @type {number}
- */
- public shadowBlur: number = 10;
-
- /**
- * Offset of the shadow from camera's position.
- * @type {Point}
- */
- public shadowOffset: Point = new Point(4, 4);
-
- /**
- * Pre-render is called at the start of the object render cycle, before any transforms have taken place.
- * It happens directly AFTER a canvas context.save has happened if added to a Camera.
- */
- public preRender() {
-
- // Shadow
- if (this.showShadow == true)
- {
- this.game.stage.context.shadowColor = this.shadowColor;
- this.game.stage.context.shadowBlur = this.shadowBlur;
- this.game.stage.context.shadowOffsetX = this.shadowOffset.x;
- this.game.stage.context.shadowOffsetY = this.shadowOffset.y;
- }
-
- }
-
- /**
- * render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
- */
- public render() {
-
- // Shadow off
- if (this.showShadow == true)
- {
- this.game.stage.context.shadowBlur = 0;
- this.game.stage.context.shadowOffsetX = 0;
- this.game.stage.context.shadowOffsetY = 0;
- }
-
- }
-
- }
-
-}
diff --git a/wip/CameraFX/Shake.ts b/wip/CameraFX/Shake.ts
deleted file mode 100644
index 983695ce..00000000
--- a/wip/CameraFX/Shake.ts
+++ /dev/null
@@ -1,114 +0,0 @@
-///
-///
-
-/**
-* Phaser - Plugins - Camera FX - Shake
-*
-* A simple camera shake effect.
-*/
-
-module Phaser.Plugins.CameraFX {
-
- export class Shake extends Phaser.Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- super(game, parent);
- this.camera = parent;
-
- }
-
- public camera: Phaser.Camera;
-
- private _fxShakeIntensity: number = 0;
- private _fxShakeDuration: number = 0;
- private _fxShakeComplete = null;
- private _fxShakeOffset: Point = new Point(0, 0);
- private _fxShakeDirection: number = 0;
- private _fxShakePrevX: number = 0;
- private _fxShakePrevY: number = 0;
-
- public static SHAKE_BOTH_AXES: number = 0;
- public static SHAKE_HORIZONTAL_ONLY: number = 1;
- public static SHAKE_VERTICAL_ONLY: number = 2;
-
- /**
- * A simple camera shake effect.
- *
- * @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
- * @param Duration The length in seconds that the shaking effect should last.
- * @param OnComplete A function you want to run when the shake effect finishes.
- * @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
- * @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
- */
- public start(intensity: number = 0.05, duration: number = 0.5, onComplete = null, force: bool = true, direction: number = Shake.SHAKE_BOTH_AXES) {
-
- if (!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)))
- {
- return;
- }
-
- // If a shake is not already running we need to store the offsets here
- if (this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0)
- {
- this._fxShakePrevX = this.camera.x;
- this._fxShakePrevY = this.camera.y;
- }
-
- this._fxShakeIntensity = intensity;
- this._fxShakeDuration = duration;
- this._fxShakeComplete = onComplete;
- this._fxShakeDirection = direction;
- this._fxShakeOffset.setTo(0, 0);
-
- }
-
- public postUpdate() {
-
- // Update the "shake" special effect
- if (this._fxShakeDuration > 0)
- {
- this._fxShakeDuration -= this.game.time.elapsed;
-
- if (this.game.math.roundTo(this._fxShakeDuration, -2) <= 0)
- {
- this._fxShakeDuration = 0;
- this._fxShakeOffset.setTo(0, 0);
- this.camera.x = this._fxShakePrevX;
- this.camera.y = this._fxShakePrevY;
-
- if (this._fxShakeComplete != null)
- {
- this._fxShakeComplete();
- }
- }
- else
- {
- if ((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_HORIZONTAL_ONLY))
- {
- this._fxShakeOffset.x = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.width * 2 - this._fxShakeIntensity * this.camera.worldView.width);
- }
-
- if ((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_VERTICAL_ONLY))
- {
- this._fxShakeOffset.y = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.height * 2 - this._fxShakeIntensity * this.camera.worldView.height);
- }
- }
-
- }
-
- }
-
- public preRender() {
-
- if ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))
- {
- this.camera.x = this._fxShakePrevX + this._fxShakeOffset.x;
- this.camera.y = this._fxShakePrevY + this._fxShakeOffset.y;
- }
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/Game.ts b/wip/TS Source/Game.ts
deleted file mode 100644
index 7b1d54be..00000000
--- a/wip/TS Source/Game.ts
+++ /dev/null
@@ -1,703 +0,0 @@
-///
-
-/**
- * Game
- *
- * This is where the magic happens. The Game object is the heart of your game,
- * providing quick access to common functions and handling the boot process.
- *
- * "Hell, there are no rules here - we're trying to accomplish something."
- * Thomas A. Edison
- *
- * @package Phaser.Game
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class Game {
-
- /**
- * Game constructor
- *
- * Instantiate a new Phaser.Game object.
- *
- * @constructor
- * @param callbackContext Which context will the callbacks be called with.
- * @param parent {string} ID of its parent DOM element.
- * @param width {number} The width of your game in game pixels.
- * @param height {number} The height of your game in game pixels.
- * @param preloadCallback {function} Preload callback invoked when init default screen.
- * @param createCallback {function} Create callback invoked when create default screen.
- * @param updateCallback {function} Update callback invoked when update default screen.
- * @param renderCallback {function} Render callback invoked when render default screen.
- * @param destroyCallback {function} Destroy callback invoked when state is destroyed.
- */
- constructor(callbackContext, parent: string = '', width: number = 800, height: number = 600, preloadCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) {
-
- // Single instance check
- if (window['PhaserGlobal'] && window['PhaserGlobal'].singleInstance)
- {
- if (Phaser.GAMES.length > 0)
- {
- console.log('Phaser detected an instance of this game already running, aborting');
- return;
- }
- }
-
- this.id = Phaser.GAMES.push(this) - 1;
-
- this.callbackContext = callbackContext;
- this.onPreloadCallback = preloadCallback;
- this.onCreateCallback = createCallback;
- this.onUpdateCallback = updateCallback;
- this.onRenderCallback = renderCallback;
- this.onDestroyCallback = destroyCallback;
-
- if (document.readyState === 'complete' || document.readyState === 'interactive')
- {
- setTimeout(() => Phaser.GAMES[this.id].boot(parent, width, height));
- }
- else
- {
- document.addEventListener('DOMContentLoaded', Phaser.GAMES[this.id].boot(parent, width, height), false);
- window.addEventListener('load', Phaser.GAMES[this.id].boot(parent, width, height), false);
- }
-
- }
-
- public id: number;
-
- /**
- * Game loop trigger wrapper.
- */
- public _raf: Phaser.RequestAnimationFrame;
-
- /**
- * Whether load complete loading or not.
- * @type {bool}
- */
- private _loadComplete: bool = false;
-
- /**
- * Game is paused?
- * @type {bool}
- */
- private _paused: bool = false;
-
- /**
- * The state to be switched to in the next frame.
- * @type {State}
- */
- private _pendingState = null;
-
- /**
- * The PluginManager for the Game
- * @type {PluginManager}
- */
- public plugins: Phaser.PluginManager;
-
- /**
- * The current State object (defaults to null)
- * @type {State}
- */
- public state = null;
-
- /**
- * Context for calling the callbacks.
- */
- public callbackContext;
-
- /**
- * This will be called when init states. (loading assets...)
- * @type {function}
- */
- public onPreloadCallback = null;
-
- /**
- * This will be called when create states. (setup states...)
- * @type {function}
- */
- public onCreateCallback = null;
-
- /**
- * This will be called when State is updated, this doesn't happen during load (see onLoadUpdateCallback)
- * @type {function}
- */
- public onUpdateCallback = null;
-
- /**
- * This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback)
- * @type {function}
- */
- public onRenderCallback = null;
-
- /**
- * This will be called before the State is rendered and before the stage is cleared
- * @type {function}
- */
- public onPreRenderCallback = null;
-
- /**
- * This will be called when the State is updated but only during the load process
- * @type {function}
- */
- public onLoadUpdateCallback = null;
-
- /**
- * This will be called when the State is rendered but only during the load process
- * @type {function}
- */
- public onLoadRenderCallback = null;
-
- /**
- * This will be called when states paused.
- * @type {function}
- */
- public onPausedCallback = null;
-
- /**
- * This will be called when the state is destroyed (i.e. swapping to a new state)
- * @type {function}
- */
- public onDestroyCallback = null;
-
- /**
- * This Signal is dispatched whenever the game pauses.
- * @type {Phaser.Signal}
- */
- public onPause: Phaser.Signal;
-
- /**
- * This Signal is dispatched whenever the game resumes from a paused state.
- * @type {Phaser.Signal}
- */
- public onResume: Phaser.Signal;
-
- /**
- * Reference to the GameObject Factory.
- * @type {Phaser.GameObjectFactory}
- */
- public add: Phaser.GameObjectFactory;
-
- /**
- * Reference to the assets cache.
- * @type {Phaser.Cache}
- */
- public cache: Phaser.Cache;
-
- /**
- * Reference to the input manager
- * @type {Phaser.InputManager}
- */
- public input: Phaser.InputManager;
-
- /**
- * Reference to the assets loader.
- * @type {Phaser.Loader}
- */
- public load: Phaser.Loader;
-
- /**
- * Reference to the math helper.
- * @type {Phaser.GameMath}
- */
- public math: Phaser.GameMath;
-
- /**
- * Reference to the network class.
- * @type {Phaser.Net}
- */
- public net: Phaser.Net;
-
- /**
- * Reference to the sound manager.
- * @type {Phaser.SoundManager}
- */
- public sound: Phaser.SoundManager;
-
- /**
- * Reference to the stage.
- * @type {Phaser.Stage}
- */
- public stage: Phaser.Stage;
-
- /**
- * Reference to game clock.
- * @type {Phaser.TimeManager}
- */
- public time: Phaser.TimeManager;
-
- /**
- * Reference to the tween manager.
- * @type {Phaser.TweenManager}
- */
- public tweens: Phaser.TweenManager;
-
- /**
- * Reference to the world.
- * @type {Phaser.World}
- */
- public world: Phaser.World;
-
- /**
- * Reference to the physics manager.
- * @type {Phaser.Physics.PhysicsManager}
- */
- public physics: Phaser.Physics.PhysicsManager;
-
- /**
- * Instance of repeatable random data generator helper.
- * @type {Phaser.RandomDataGenerator}
- */
- public rnd: Phaser.RandomDataGenerator;
-
- /**
- * Contains device information and capabilities.
- * @type {Phaser.Device}
- */
- public device: Phaser.Device;
-
- /**
- * Reference to the render manager
- * @type {Phaser.IRenderer}
- */
- public renderer: Phaser.IRenderer;
-
- /**
- * Whether the game engine is booted, aka available.
- * @type {bool}
- */
- public isBooted: bool = false;
-
- /**
- * Is game running or paused?
- * @type {bool}
- */
- public isRunning: bool = false;
-
- /**
- * Initialize engine sub modules and start the game.
- * @param parent {string} ID of parent Dom element.
- * @param width {number} Width of the game screen.
- * @param height {number} Height of the game screen.
- */
- private boot(parent: string, width: number, height: number) {
-
- if (this.isBooted == true)
- {
- return;
- }
-
- if (!document.body)
- {
- setTimeout(() => Phaser.GAMES[this.id].boot(parent, width, height), 13);
- }
- else
- {
- document.removeEventListener('DOMContentLoaded', Phaser.GAMES[this.id].boot);
- window.removeEventListener('load', Phaser.GAMES[this.id].boot);
-
- this.onPause = new Phaser.Signal;
- this.onResume = new Phaser.Signal;
-
- this.device = new Phaser.Device();
- this.net = new Phaser.Net(this);
- this.math = new Phaser.GameMath(this);
- this.stage = new Phaser.Stage(this, parent, width, height);
- this.world = new Phaser.World(this, width, height);
- this.add = new Phaser.GameObjectFactory(this);
- this.cache = new Phaser.Cache(this);
- this.load = new Phaser.Loader(this);
- this.time = new Phaser.TimeManager(this);
- this.tweens = new Phaser.TweenManager(this);
- this.input = new Phaser.InputManager(this);
- this.sound = new Phaser.SoundManager(this);
- this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]);
- this.physics = new Phaser.Physics.PhysicsManager(this);
- this.plugins = new Phaser.PluginManager(this, this);
-
- this.load.onLoadComplete.add(this.loadComplete, this);
-
- this.setRenderer(Phaser.Types.RENDERER_CANVAS);
-
- this.world.boot();
- this.stage.boot();
- this.input.boot();
-
- this.isBooted = true;
-
- // Set-up some static helper references
- Phaser.DebugUtils.game = this;
- Phaser.ColorUtils.game = this;
- Phaser.DebugUtils.context = this.stage.context;
-
- // Display the default game screen?
- if (this.onPreloadCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null)
- {
- this._raf = new RequestAnimationFrame(this, this.bootLoop);
- }
- else
- {
- this.isRunning = true;
- this._loadComplete = false;
-
- this._raf = new RequestAnimationFrame(this, this.loop);
-
- if (this._pendingState)
- {
- this.switchState(this._pendingState, false, false);
- }
- else
- {
- this.startState();
- }
-
- }
-
- }
-
- }
-
- /**
- * Called when the load has finished after preload was run.
- */
- private loadComplete() {
- this._loadComplete = true;
- this.onCreateCallback.call(this.callbackContext);
- }
-
- /**
- * The bootLoop is called while the game is still booting (waiting for the DOM and resources to be available)
- */
- private bootLoop() {
-
- this.tweens.update();
- this.input.update();
- this.stage.update();
-
- }
-
- /**
- * The pausedLoop is called when the game is paused.
- */
- private pausedLoop() {
-
- this.tweens.update();
- this.input.update();
- this.stage.update();
- this.sound.update();
-
- if (this.onPausedCallback !== null)
- {
- this.onPausedCallback.call(this.callbackContext);
- }
-
- }
-
- /**
- * Game loop method will be called when it's running.
- */
- private loop() {
-
- this.plugins.preUpdate();
-
- this.tweens.update();
- this.input.update();
- this.stage.update();
- this.sound.update();
- this.physics.update();
- this.world.update();
- this.plugins.update();
-
- if (this._loadComplete && this.onUpdateCallback)
- {
- this.onUpdateCallback.call(this.callbackContext);
- }
- else if (this._loadComplete == false && this.onLoadUpdateCallback)
- {
- this.onLoadUpdateCallback.call(this.callbackContext);
- }
-
- this.world.postUpdate();
-
- this.plugins.postUpdate();
- this.plugins.preRender();
-
- if (this._loadComplete && this.onPreRenderCallback)
- {
- this.onPreRenderCallback.call(this.callbackContext);
- }
-
- this.renderer.render();
- this.plugins.render();
-
- if (this._loadComplete && this.onRenderCallback)
- {
- this.onRenderCallback.call(this.callbackContext);
- }
- else if (this._loadComplete == false && this.onLoadRenderCallback)
- {
- this.onLoadRenderCallback.call(this.callbackContext);
- }
-
- this.plugins.postRender();
- }
-
- /**
- * Start current state.
- */
- private startState() {
-
- if (this.onPreloadCallback !== null)
- {
- this.load.reset();
-
- this.onPreloadCallback.call(this.callbackContext);
-
- // Is the loader empty?
- if (this.load.queueSize == 0)
- {
- if (this.onCreateCallback !== null)
- {
- this.onCreateCallback.call(this.callbackContext);
- }
-
- this._loadComplete = true;
- }
- else
- {
- // Start the loader going as we have something in the queue
- this.load.onLoadComplete.add(this.loadComplete, this);
- this.load.start();
- }
- }
- else
- {
- // No init? Then there was nothing to load either
- if (this.onCreateCallback !== null)
- {
- this.onCreateCallback.call(this.callbackContext);
- }
-
- this._loadComplete = true;
- }
-
- }
-
- public setRenderer(renderer: number) {
-
- switch (renderer)
- {
- case Phaser.Types.RENDERER_AUTO_DETECT:
- this.renderer = new Phaser.Renderer.Headless.HeadlessRenderer(this);
- break;
-
- case Phaser.Types.RENDERER_AUTO_DETECT:
- case Phaser.Types.RENDERER_CANVAS:
- this.renderer = new Phaser.Renderer.Canvas.CanvasRenderer(this);
- break;
-
- // WebGL coming soon :)
- }
-
- }
-
- /**
- * Set the most common state callbacks (init, create, update, render).
- * @param preloadCallback {function} Init callback invoked when init state.
- * @param createCallback {function} Create callback invoked when create state.
- * @param updateCallback {function} Update callback invoked when update state.
- * @param renderCallback {function} Render callback invoked when render state.
- * @param destroyCallback {function} Destroy callback invoked when state is destroyed.
- */
- public setCallbacks(preloadCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) {
-
- this.onPreloadCallback = preloadCallback;
- this.onCreateCallback = createCallback;
- this.onUpdateCallback = updateCallback;
- this.onRenderCallback = renderCallback;
- this.onDestroyCallback = destroyCallback;
-
- }
-
- /**
- * Switch to a new State.
- * @param state {State} The state you want to switch to.
- * @param [clearWorld] {bool} clear everything in the world? (Default to true)
- * @param [clearCache] {bool} clear asset cache? (Default to false and ONLY available when clearWorld=true)
- */
- public switchState(state, clearWorld: bool = true, clearCache: bool = false) {
-
- if (this.isBooted == false)
- {
- this._pendingState = state;
- return;
- }
-
- // Destroy current state?
- if (this.onDestroyCallback !== null)
- {
- this.onDestroyCallback.call(this.callbackContext);
- }
-
- this.input.reset(true);
-
- // Prototype?
- if (typeof state === 'function')
- {
- this.state = new state(this);
- }
- else
- {
- this.state = state;
- }
-
- // Ok, have we got the right functions?
- if (this.state['create'] || this.state['update'])
- {
- this.callbackContext = this.state;
-
- this.onPreloadCallback = null;
- this.onLoadRenderCallback = null;
- this.onLoadUpdateCallback = null;
- this.onCreateCallback = null;
- this.onUpdateCallback = null;
- this.onRenderCallback = null;
- this.onPreRenderCallback = null;
- this.onPausedCallback = null;
- this.onDestroyCallback = null;
-
- // Bingo, let's set them up
- if (this.state['preload'])
- {
- this.onPreloadCallback = this.state['preload'];
- }
-
- if (this.state['loadRender'])
- {
- this.onLoadRenderCallback = this.state['loadRender'];
- }
-
- if (this.state['loadUpdate'])
- {
- this.onLoadUpdateCallback = this.state['loadUpdate'];
- }
-
- if (this.state['create'])
- {
- this.onCreateCallback = this.state['create'];
- }
-
- if (this.state['update'])
- {
- this.onUpdateCallback = this.state['update'];
- }
-
- if (this.state['preRender'])
- {
- this.onPreRenderCallback = this.state['preRender'];
- }
-
- if (this.state['render'])
- {
- this.onRenderCallback = this.state['render'];
- }
-
- if (this.state['paused'])
- {
- this.onPausedCallback = this.state['paused'];
- }
-
- if (this.state['destroy'])
- {
- this.onDestroyCallback = this.state['destroy'];
- }
-
- if (clearWorld)
- {
- this.world.destroy();
-
- if (clearCache == true)
- {
- this.cache.destroy();
- }
- }
-
- this._loadComplete = false;
-
- this.startState();
- }
- else
- {
- throw new Error("Invalid State object given. Must contain at least a create or update function.");
- }
-
- }
-
- /**
- * Nuke the entire game from orbit
- */
- public destroy() {
-
- this.callbackContext = null;
- this.onPreloadCallback = null;
- this.onLoadRenderCallback = null;
- this.onLoadUpdateCallback = null;
- this.onCreateCallback = null;
- this.onUpdateCallback = null;
- this.onRenderCallback = null;
- this.onPausedCallback = null;
- this.onDestroyCallback = null;
- this.cache = null;
- this.input = null;
- this.load = null;
- this.sound = null;
- this.stage = null;
- this.time = null;
- this.world = null;
- this.isBooted = false;
-
- }
-
- public get paused(): bool {
- return this._paused;
- }
-
- public set paused(value: bool) {
-
- if (value == true && this._paused == false)
- {
- this._paused = true;
- this.onPause.dispatch();
- this.sound.pauseAll();
- this._raf.callback = this.pausedLoop;
- }
- else if (value == false && this._paused == true)
- {
- this._paused = false;
- this.onResume.dispatch();
- this.input.reset();
- this.sound.resumeAll();
-
- if (this.isRunning == false)
- {
- this._raf.callback = this.bootLoop;
- }
- else
- {
- this._raf.callback = this.loop;
- }
- }
-
- }
-
- public get camera(): Phaser.Camera {
- return this.world.cameras.current;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/Phaser.ts b/wip/TS Source/Phaser.ts
deleted file mode 100644
index be60e38c..00000000
--- a/wip/TS Source/Phaser.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-///
-
-/**
-* Phaser - http://www.phaser.io
-*
-* v1.0.0 - August 12th 2013
-*
-* A feature-packed 2D canvas game framework born from the firey pits of Flixel and
-* constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm).
-*
-* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser
-* and my love of game development originate.
-*
-* Follow Phaser progress at http://www.photonstorm.com
-*
-* "If you want your children to be intelligent, read them fairy tales."
-* "If you want them to be more intelligent, read them more fairy tales."
-* -- Albert Einstein
-*/
-
-module Phaser {
-
- export var VERSION: string = 'Phaser version 1.0.0';
-
- export var GAMES = [];
-
-}
diff --git a/wip/TS Source/Stage.ts b/wip/TS Source/Stage.ts
deleted file mode 100644
index 6c55ceec..00000000
--- a/wip/TS Source/Stage.ts
+++ /dev/null
@@ -1,415 +0,0 @@
-///
-
-/**
- * Stage
- *
- * The Stage controls the canvas on which everything is displayed. It handles display within the browser,
- * focus handling, game resizing, scaling and the pause, boot and orientation screens.
- *
- * @package Phaser.Stage
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class Stage {
-
- /**
- * Stage constructor
- *
- * Create a new Stage with specific width and height.
- *
- * @param parent {number} ID of parent DOM element.
- * @param width {number} Width of the stage.
- * @param height {number} Height of the stage.
- */
- constructor(game: Game, parent: string, width: number, height: number) {
-
- this.game = game;
-
- this.canvas = document.createElement('canvas');
- this.canvas.width = width;
- this.canvas.height = height;
- this.context = this.canvas.getContext('2d');
-
- Phaser.CanvasUtils.addToDOM(this.canvas, parent, true);
- Phaser.CanvasUtils.setTouchAction(this.canvas);
-
- this.canvas.oncontextmenu = function(event) { event.preventDefault(); };
-
- this.css3 = new Phaser.Display.CSS3Filters(this.canvas);
-
- this.scaleMode = StageScaleMode.NO_SCALE;
- this.scale = new StageScaleMode(this.game, width, height);
-
- this.getOffset(this.canvas);
- this.bounds = new Rectangle(this.offset.x, this.offset.y, width, height);
- this.aspectRatio = width / height;
-
- document.addEventListener('visibilitychange', (event) => this.visibilityChange(event), false);
- document.addEventListener('webkitvisibilitychange', (event) => this.visibilityChange(event), false);
- document.addEventListener('pagehide', (event) => this.visibilityChange(event), false);
- document.addEventListener('pageshow', (event) => this.visibilityChange(event), false);
- window.onblur = (event) => this.visibilityChange(event);
- window.onfocus = (event) => this.visibilityChange(event);
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Background color of the stage (defaults to black). Set via the public backgroundColor property.
- * @type {string}
- */
- private _backgroundColor: string = 'rgb(0,0,0)';
-
- /**
- * This will be displayed when Phaser is started without any default functions or State
- * @type {BootScreen}
- */
- public bootScreen;
-
- /**
- * This will be displayed whenever the game loses focus or the player switches to another browser tab.
- * @type {PauseScreen}
- */
- public pauseScreen;
-
- /**
- * This will be displayed whenever the device is turned to an unsupported orientation.
- * @type {OrientationScreen}
- */
- public orientationScreen;
-
- /**
- * Controls the CSS3 Filters applied to the Stages canvas object.
- * @type {Phaser.Display.CSS3Filters}
- */
- public css3: Phaser.Display.CSS3Filters;
-
- /**
- * Bound of this stage.
- * @type {Rectangle}
- */
- public bounds: Rectangle;
-
- /**
- * Asperct ratio, thus: width / height.
- * @type {number}
- */
- public aspectRatio: number;
-
- /**
- * Clear the whole stage every frame? (Default to true)
- * @type {bool}
- */
- public clear: bool = true;
-
- /**
- * Canvas element used by engine.
- * @type {HTMLCanvasElement}
- */
- public canvas: HTMLCanvasElement;
-
- /**
- * Render context of stage's canvas.
- * @type {CanvasRenderingContext2D}
- */
- public context: CanvasRenderingContext2D;
-
- /**
- * Do not use pause screen when game is paused?
- * (Default to false, aka always use PauseScreen)
- * @type {bool}
- */
- public disablePauseScreen: bool = false;
-
- /**
- * Do not use boot screen when engine starts?
- * (Default to false, aka always use BootScreen)
- * @type {bool}
- */
- public disableBootScreen: bool = false;
-
- /**
- * Offset from this stage to the canvas element.
- * @type {MicroPoint}
- */
- public offset: Point;
-
- /**
- * This object manages scaling of the game, see(StageScaleMode).
- * @type {StageScaleMode}
- */
- public scale: StageScaleMode;
-
- /**
- * Which mode will the game be scaled.
- * Available: StageScaleMode.EXACT_FIT, StageScaleMode.NO_SCALE, StageScaleMode.SHOW_ALL.
- * @type {number}
- */
- public scaleMode: number;
-
- /**
- * If set to true the game will never pause when the browser or browser tab loses focuses
- * @type {bool}
- */
- public disableVisibilityChange: bool = false;
-
- /**
- * Stage boot
- */
- public boot() {
-
- this.bootScreen = new BootScreen(this.game);
- this.pauseScreen = new PauseScreen(this.game, this.width, this.height);
- this.orientationScreen = new OrientationScreen(this.game);
-
- this.scale.setScreenSize(true);
-
- }
-
- /**
- * Update stage for rendering. This will handle scaling, clearing
- * and PauseScreen/BootScreen updating and rendering.
- */
- public update() {
-
- this.scale.update();
-
- this.context.setTransform(1, 0, 0, 1, 0, 0);
-
- if (this.clear || (this.game.paused && this.disablePauseScreen == false))
- {
- if (this.game.device.patchAndroidClearRectBug)
- {
- this.context.fillStyle = this._backgroundColor;
- this.context.fillRect(0, 0, this.width, this.height);
- }
- else
- {
- this.context.clearRect(0, 0, this.width, this.height);
- }
- }
-
- if (this.game.paused && this.scale.incorrectOrientation)
- {
- this.orientationScreen.update();
- this.orientationScreen.render();
- return;
- }
-
- if (this.game.isRunning == false && this.disableBootScreen == false)
- {
- this.bootScreen.update();
- this.bootScreen.render();
- }
-
- if (this.game.paused && this.disablePauseScreen == false)
- {
- this.pauseScreen.update();
- this.pauseScreen.render();
- }
-
- }
-
- /**
- * This method is called when the canvas elements visibility is changed.
- */
- private visibilityChange(event) {
-
- if (this.disableVisibilityChange)
- {
- return;
- }
-
- if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true)
- {
- if (this.game.paused == false)
- {
- this.pauseGame();
- }
- }
- else
- {
- if (this.game.paused == true)
- {
- this.resumeGame();
- }
- }
-
- }
-
- public enableOrientationCheck(forceLandscape: bool, forcePortrait: bool, imageKey: string = '') {
-
- this.scale.forceLandscape = forceLandscape;
- this.scale.forcePortrait = forcePortrait;
- this.orientationScreen.enable(imageKey);
-
- if (forceLandscape || forcePortrait)
- {
- if ((this.scale.isLandscape && forcePortrait) || (this.scale.isPortrait && forceLandscape))
- {
- // They are in the wrong orientation right now
- this.game.paused = true;
- this.scale.incorrectOrientation = true;
- }
- else
- {
- this.scale.incorrectOrientation = false;
- }
- }
-
- }
-
- public pauseGame() {
-
- this.game.paused = true;
-
- if (this.disablePauseScreen == false && this.pauseScreen)
- {
- this.pauseScreen.onPaused();
- }
-
- this.saveCanvasValues();
-
- }
-
- public resumeGame() {
-
- if (this.disablePauseScreen == false && this.pauseScreen)
- {
- this.pauseScreen.onResume();
- }
-
- this.restoreCanvasValues();
-
- this.game.paused = false;
-
- }
-
- /**
- * Get the DOM offset values of the given element
- */
- public getOffset(element, populateOffset: bool = true): Point {
-
- var box = element.getBoundingClientRect();
-
- var clientTop = element.clientTop || document.body.clientTop || 0;
- var clientLeft = element.clientLeft || document.body.clientLeft || 0;
- var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
- var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
-
- if (populateOffset)
- {
- this.offset = new Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop);
- return this.offset;
- }
- else
- {
- return new Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop);
- }
-
- }
-
- /**
- * Canvas strokeStyle.
- * @type {string}
- */
- public strokeStyle: string;
-
- /**
- * Canvas lineWidth.
- * @type {number}
- */
- public lineWidth: number;
-
- /**
- * Canvas fillStyle.
- * @type {string}
- */
- public fillStyle: string;
-
- /**
- * Save current canvas properties (strokeStyle, lineWidth and fillStyle) for later using.
- */
- public saveCanvasValues() {
-
- this.strokeStyle = this.context.strokeStyle;
- this.lineWidth = this.context.lineWidth;
- this.fillStyle = this.context.fillStyle;
-
- }
-
- /**
- * Restore current canvas values (strokeStyle, lineWidth and fillStyle) with saved values.
- */
- public restoreCanvasValues() {
-
- this.context.strokeStyle = this.strokeStyle;
- this.context.lineWidth = this.lineWidth;
- this.context.fillStyle = this.fillStyle;
-
- if (this.game.device.patchAndroidClearRectBug)
- {
- this.context.fillStyle = this._backgroundColor;
- this.context.fillRect(0, 0, this.width, this.height);
- }
- else
- {
- this.context.clearRect(0, 0, this.width, this.height);
- }
-
- }
-
- public set backgroundColor(color: string) {
-
- this.canvas.style.backgroundColor = color;
- this._backgroundColor = color;
-
- }
-
- public get backgroundColor(): string {
- return this._backgroundColor;
- }
-
- public get x(): number {
- return this.bounds.x;
- }
-
- public get y(): number {
- return this.bounds.y;
- }
-
- public get width(): number {
- return this.bounds.width;
- }
-
- public get height(): number {
- return this.bounds.height;
- }
-
- public get centerX(): number {
- return this.bounds.halfWidth;
- }
-
- public get centerY(): number {
- return this.bounds.halfHeight;
- }
-
- public get randomX(): number {
- return Math.round(Math.random() * this.bounds.width);
- }
-
- public get randomY(): number {
- return Math.round(Math.random() * this.bounds.height);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/State.ts b/wip/TS Source/State.ts
deleted file mode 100644
index 577e121b..00000000
--- a/wip/TS Source/State.ts
+++ /dev/null
@@ -1,162 +0,0 @@
-///
-
-/**
- * State
- *
- * This is a base State class which can be extended if you are creating your game with TypeScript.
- * It provides quick access to common functions such as the camera, cache, input, match, sound and more.
- *
- * @package Phaser.State
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class State {
-
- /**
- * State constructor
- * Create a new State.
- */
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- this.add = game.add;
- this.camera = game.camera;
- this.cache = game.cache;
- this.input = game.input;
- this.load = game.load;
- this.math = game.math;
- this.sound = game.sound;
- this.stage = game.stage;
- this.time = game.time;
- this.tweens = game.tweens;
- this.world = game.world;
-
- }
-
- /**
- * Reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Currently used camera.
- * @type {Camera}
- */
- public camera: Phaser.Camera;
-
- /**
- * Reference to the assets cache.
- * @type {Cache}
- */
- public cache: Phaser.Cache;
-
- /**
- * Reference to the GameObject Factory.
- * @type {GameObjectFactory}
- */
- public add: Phaser.GameObjectFactory;
-
- /**
- * Reference to the input manager
- * @type {Input}
- */
- public input: Phaser.InputManager;
-
- /**
- * Reference to the assets loader.
- * @type {Loader}
- */
- public load: Phaser.Loader;
-
- /**
- * Reference to the math helper.
- * @type {GameMath}
- */
- public math: Phaser.GameMath;
-
- /**
- * Reference to the sound manager.
- * @type {SoundManager}
- */
- public sound: Phaser.SoundManager;
-
- /**
- * Reference to the stage.
- * @type {Stage}
- */
- public stage: Phaser.Stage;
-
- /**
- * Reference to game clock.
- * @type {Time}
- */
- public time: Phaser.TimeManager;
-
- /**
- * Reference to the tween manager.
- * @type {TweenManager}
- */
- public tweens: Phaser.TweenManager;
-
- /**
- * Reference to the world.
- * @type {World}
- */
- public world: Phaser.World;
-
- // Override these in your own States
-
- /**
- * Override this method to add some load operations.
- * If you need to use the loader, you may need to use them here.
- */
- public init() { }
-
- /**
- * This method is called after the game engine successfully switches states.
- * Feel free to add any setup code here.(Do not load anything here, override init() instead)
- */
- public create() { }
-
- /**
- * Put update logic here.
- */
- public update() { }
-
- /**
- * Put render operations here.
- */
- public render() { }
-
- /**
- * This method will be called when game paused.
- */
- public paused() { }
-
- /**
- * This method will be called when the state is destroyed
- */
- public destroy() { }
-
- /**
- * Checks for overlaps between two objects using the world QuadTree. Can be GameObject vs. GameObject, GameObject vs. Group or Group vs. Group.
- * Note: Does not take the objects scrollFactor into account. All overlaps are check in world space.
- * @param object1 The first GameObject or Group to check. If null the world.group is used.
- * @param object2 The second GameObject or Group to check.
- * @param notifyCallback A callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you passed them to Collision.overlap.
- * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then notifyCallback will only be called if processCallback returns true.
- * @param context The context in which the callbacks will be called
- * @returns {bool} true if the objects overlap, otherwise false.
- */
- //public collide(objectOrGroup1 = null, objectOrGroup2 = null, notifyCallback = null, context? = this.game.callbackContext): bool {
- // return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate, context);
- //}
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/Statics.ts b/wip/TS Source/Statics.ts
deleted file mode 100644
index ca6368bc..00000000
--- a/wip/TS Source/Statics.ts
+++ /dev/null
@@ -1,141 +0,0 @@
-///
-
-/**
- * Types
- *
- * This file contains all constants used through-out Phaser.
- *
- * @package Phaser.Types
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class Types {
-
- static RENDERER_AUTO_DETECT: number = 0;
- static RENDERER_HEADLESS: number = 1;
- static RENDERER_CANVAS: number = 2;
- static RENDERER_WEBGL: number = 3;
-
- static CAMERA_TYPE_ORTHOGRAPHIC: number = 0;
- static CAMERA_TYPE_ISOMETRIC: number = 1;
-
- /**
- * Camera "follow" style preset: camera has no deadzone, just tracks the focus object directly.
- * @type {number}
- */
- public static CAMERA_FOLLOW_LOCKON: number = 0;
-
- /**
- * Camera "follow" style preset: camera deadzone is narrow but tall.
- * @type {number}
- */
- public static CAMERA_FOLLOW_PLATFORMER: number = 1;
-
- /**
- * Camera "follow" style preset: camera deadzone is a medium-size square around the focus object.
- * @type {number}
- */
- public static CAMERA_FOLLOW_TOPDOWN: number = 2;
-
- /**
- * Camera "follow" style preset: camera deadzone is a small square around the focus object.
- * @type {number}
- */
- public static CAMERA_FOLLOW_TOPDOWN_TIGHT: number = 3;
-
- static GROUP: number = 0;
- static SPRITE: number = 1;
- static GEOMSPRITE: number = 2;
- static PARTICLE: number = 3;
- static EMITTER: number = 4;
- static TILEMAP: number = 5;
- static SCROLLZONE: number = 6;
- static BUTTON: number = 7;
- static DYNAMICTEXTURE: number = 8;
-
- static GEOM_POINT: number = 0;
- static GEOM_CIRCLE: number = 1;
- static GEOM_RECTANGLE: number = 2;
- static GEOM_LINE: number = 3;
- static GEOM_POLYGON: number = 4;
-
- static BODY_DISABLED: number = 0;
- static BODY_STATIC: number = 1;
- static BODY_KINETIC: number = 2;
- static BODY_DYNAMIC: number = 3;
-
- static OUT_OF_BOUNDS_KILL: number = 0;
- static OUT_OF_BOUNDS_DESTROY: number = 1;
- static OUT_OF_BOUNDS_PERSIST: number = 2;
-
- /**
- * Use with sort() to sort in ascending order.
- */
- static SORT_ASCENDING: number = -1;
-
- /**
- * Use with sort() to sort in descending order.
- */
- static SORT_DESCENDING: number = 1;
-
- /**
- * Flag used to allow GameObjects to collide on their left side
- * @type {number}
- */
- static LEFT: number = 0x0001;
-
- /**
- * Flag used to allow GameObjects to collide on their right side
- * @type {number}
- */
- static RIGHT: number = 0x0010;
-
- /**
- * Flag used to allow GameObjects to collide on their top side
- * @type {number}
- */
- static UP: number = 0x0100;
-
- /**
- * Flag used to allow GameObjects to collide on their bottom side
- * @type {number}
- */
- static DOWN: number = 0x1000;
-
- /**
- * Flag used with GameObjects to disable collision
- * @type {number}
- */
- static NONE: number = 0;
-
- /**
- * Flag used to allow GameObjects to collide with a ceiling
- * @type {number}
- */
- static CEILING: number = 0x0100;
-
- /**
- * Flag used to allow GameObjects to collide with a floor
- * @type {number}
- */
- static FLOOR: number = 0x1000;
-
- /**
- * Flag used to allow GameObjects to collide with a wall (same as LEFT+RIGHT)
- * @type {number}
- */
- static WALL: number = 0x0001 | 0x0010;
-
- /**
- * Flag used to allow GameObjects to collide on any face
- * @type {number}
- */
- static ANY: number = 0x0001 | 0x0010 | 0x0100 | 0x1000;
-
- }
-
-}
diff --git a/wip/TS Source/World.ts b/wip/TS Source/World.ts
deleted file mode 100644
index 8f4336b0..00000000
--- a/wip/TS Source/World.ts
+++ /dev/null
@@ -1,181 +0,0 @@
-///
-
-/**
- * World
- *
- * "This world is but a canvas to our imagination." - Henry David Thoreau
- *
- * A game has only one world. The world is an abstract place in which all game objects live. It is not bound
- * by stage limits and can be any size. You look into the world via cameras. All game objects live within
- * the world at world-based coordinates. By default a world is created the same size as your Stage.
- *
- * @package Phaser.World
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class World {
-
- /**
- * World constructor
- * Create a new World with specific width and height.
- *
- * @param width {number} Width of the world bound.
- * @param height {number} Height of the world bound.
- */
- constructor(game: Phaser.Game, width: number, height: number) {
-
- this.game = game;
-
- this.cameras = new Phaser.CameraManager(this.game, 0, 0, width, height);
-
- this.bounds = new Phaser.Rectangle(0, 0, width, height);
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Camera manager of this world.
- * @type {CameraManager}
- */
- public cameras: Phaser.CameraManager;
-
- /**
- * Object container stores every object created with `create*` methods.
- * @type {Group}
- */
- public group: Phaser.Group;
-
- /**
- * Bound of this world that objects can not escape from.
- * @type {Rectangle}
- */
- public bounds: Phaser.Rectangle;
-
- /**
- * The Gravity of the World (defaults to 0,0, or no gravity at all)
- * @type {Vec2}
- */
- public gravity: Phaser.Vec2;
-
- /**
- * Object container stores every object created with `create*` methods.
- * @type {Group}
- */
- private _groupCounter: number = 0;
-
- public getNextGroupID(): number {
- return this._groupCounter++;
- }
-
- /**
- * Called once by Game during the boot process.
- */
- public boot() {
-
- this.group = new Phaser.Group(this.game, 0);
-
- }
-
- /**
- * This is called automatically every frame, and is where main logic happens.
- */
- public update() {
-
- this.group.update();
- this.cameras.update();
-
- }
-
- /**
- * This is called automatically every frame, and is where main logic happens.
- */
- public postUpdate() {
-
- this.group.postUpdate();
- this.cameras.postUpdate();
-
- }
-
- /**
- * Clean up memory.
- */
- public destroy() {
-
- this.group.destroy();
- this.cameras.destroy();
-
- }
-
- /**
- * Updates the size of this world.
- *
- * @param width {number} New width of the world.
- * @param height {number} New height of the world.
- * @param [updateCameraBounds] {bool} Update camera bounds automatically or not. Default to true.
- */
- public setSize(width: number, height: number, updateCameraBounds: bool = true) {
-
- this.bounds.width = width;
- this.bounds.height = height;
-
- if (updateCameraBounds == true)
- {
- this.game.camera.setBounds(0, 0, width, height);
- }
-
- // dispatch world resize event
-
- }
-
- public get width(): number {
- return this.bounds.width;
- }
-
- public set width(value: number) {
- this.bounds.width = value;
- }
-
- public get height(): number {
- return this.bounds.height;
- }
-
- public set height(value: number) {
- this.bounds.height = value;
- }
-
- public get centerX(): number {
- return this.bounds.halfWidth;
- }
-
- public get centerY(): number {
- return this.bounds.halfHeight;
- }
-
- public get randomX(): number {
- return Math.round(Math.random() * this.bounds.width);
- }
-
- public get randomY(): number {
- return Math.round(Math.random() * this.bounds.height);
- }
-
- /**
- * Get all the cameras.
- *
- * @returns {array} An array contains all the cameras.
- */
- public getAllCameras(): Phaser.Camera[] {
- return this.cameras.getAll();
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/_definitions.ts b/wip/TS Source/_definitions.ts
deleted file mode 100644
index 6f08547b..00000000
--- a/wip/TS Source/_definitions.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-///
-///
-
-///
-///
-///
-///
-
-///
-///
-///
-///
-///
-///
-///
-///
-
-///
-///
-///
-///
-///
-
-///
-///
-
-///
-///
-///
-
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-
-///
-
-///
-
-///
-///
-///
-///
-///
-///
-///
-
-///
-///
-///
-
-///
-///
-///
-
-///
-///
-
-///
-///
-///
-///
-
-///
-///
-///
-
-///
-///
-///
-
-///
-///
-///
-///
-///
-
-///
-///
-///
-///
-///
-///
-///
-
-///
-///
-///
-///
-///
-///
-///
-
-///
-///
-///
-///
-///
-///
-///
-
-///
-
-///
-///
-///
-///
-///
-///
-///
-
-///
-///
-///
-///
-///
-///
-///
-///
-///
-
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-
-///
-///
-///
-///
diff --git a/wip/TS Source/animation/Animation.ts b/wip/TS Source/animation/Animation.ts
deleted file mode 100644
index 93c3d452..00000000
--- a/wip/TS Source/animation/Animation.ts
+++ /dev/null
@@ -1,278 +0,0 @@
-///
-
-/**
- * Animation
- *
- * An Animation instance contains a single animation and the controls to play it.
- * It is created by the AnimationManager and belongs to Game Objects such as Sprite.
- *
- * @package Phaser.Animation
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class Animation {
-
- /**
- * Animation constructor
- * Create a new Animation.
- *
- * @param parent {Sprite} Owner sprite of this animation.
- * @param frameData {FrameData} The FrameData object contains animation data.
- * @param name {string} Unique name of this animation.
- * @param frames {number[]/string[]} An array of numbers or strings indicating what frames to play in what order.
- * @param delay {number} Time between frames in ms.
- * @param looped {bool} Whether or not the animation is looped or just plays once.
- */
- constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool) {
-
- this.game = game;
- this._parent = parent;
- this._frames = frames;
- this._frameData = frameData;
-
- this.name = name;
- this.delay = 1000 / delay;
- this.looped = looped;
-
- this.isFinished = false;
- this.isPlaying = false;
-
- this._frameIndex = 0;
- this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
-
- }
-
- public game: Phaser.Game;
-
- /**
- * Local private reference to its owner sprite.
- * @type {Sprite}
- */
- private _parent: Sprite;
-
- /**
- * Animation frame container.
- * @type {number[]}
- */
- private _frames: number[];
-
- /**
- * Frame data of this animation.(parsed from sprite sheet)
- * @type {FrameData}
- */
- private _frameData: FrameData;
-
- /**
- * Index of current frame.
- * @type {number}
- */
- private _frameIndex: number;
-
- /**
- * Time when switched to last frame (in ms).
- * @type number
- */
- private _timeLastFrame: number;
-
- /**
- * Time when this will switch to next frame (in ms).
- * @type number
- */
- private _timeNextFrame: number;
-
- /**
- * Name of this animation.
- * @type {string}
- */
- public name: string;
-
- /**
- * Currently played frame instance.
- * @type {Frame}
- */
- public currentFrame: Frame;
-
- /**
- * Whether or not this animation finished playing.
- * @type {bool}
- */
- public isFinished: bool;
-
- /**
- * Whethor or not this animation is currently playing.
- * @type {bool}
- */
- public isPlaying: bool;
-
- /**
- * Whether or not the animation is looped.
- * @type {bool}
- */
- public looped: bool;
-
- /**
- * Time between frames in ms.
- * @type {number}
- */
- public delay: number;
-
- public get frameTotal(): number {
- return this._frames.length;
- }
-
- public get frame(): number {
-
- if (this.currentFrame !== null)
- {
- return this.currentFrame.index;
- }
- else
- {
- return this._frameIndex;
- }
-
- }
-
- public set frame(value: number) {
-
- this.currentFrame = this._frameData.getFrame(value);
-
- if (this.currentFrame !== null)
- {
- this._parent.texture.width = this.currentFrame.width;
- this._parent.texture.height = this.currentFrame.height;
- this._frameIndex = value;
- }
-
- }
-
- /**
- * Play this animation.
- * @param frameRate {number} FrameRate you want to specify instead of using default.
- * @param loop {bool} Whether or not the animation is looped or just plays once.
- */
- public play(frameRate: number = null, loop: bool = null) {
-
- if (frameRate !== null)
- {
- this.delay = 1000 / frameRate;
- }
-
- if (loop !== null)
- {
- // If they set a new loop value then use it, otherwise use the default set on creation
- this.looped = loop;
- }
-
- this.isPlaying = true;
- this.isFinished = false;
-
- this._timeLastFrame = this.game.time.now;
- this._timeNextFrame = this.game.time.now + this.delay;
-
- this._frameIndex = 0;
-
- this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
-
- this._parent.events.onAnimationStart.dispatch(this._parent, this);
-
- return this;
-
- }
-
- /**
- * Play this animation from the first frame.
- */
- public restart() {
-
- this.isPlaying = true;
- this.isFinished = false;
-
- this._timeLastFrame = this.game.time.now;
- this._timeNextFrame = this.game.time.now + this.delay;
-
- this._frameIndex = 0;
- this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
-
- }
-
- /**
- * Stop playing animation and set it finished.
- */
- public stop() {
-
- this.isPlaying = false;
- this.isFinished = true;
-
- }
-
- /**
- * Update animation frames.
- */
- public update(): bool {
-
- if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame)
- {
- this._frameIndex++;
-
- if (this._frameIndex == this._frames.length)
- {
- if (this.looped)
- {
- this._frameIndex = 0;
- this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
- this._parent.events.onAnimationLoop.dispatch(this._parent, this);
- }
- else
- {
- this.onComplete();
- }
- }
- else
- {
- this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
- }
-
- this._timeLastFrame = this.game.time.now;
- this._timeNextFrame = this.game.time.now + this.delay;
-
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Clean up animation memory.
- */
- public destroy() {
-
- this.game = null;
- this._parent = null;
- this._frames = null;
- this._frameData = null;
- this.currentFrame = null;
- this.isPlaying = false;
-
- }
-
- /**
- * Animation complete callback method.
- */
- private onComplete() {
-
- this.isPlaying = false;
- this.isFinished = true;
-
- this._parent.events.onAnimationComplete.dispatch(this._parent, this);
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/animation/AnimationManager.ts b/wip/TS Source/animation/AnimationManager.ts
deleted file mode 100644
index 878af536..00000000
--- a/wip/TS Source/animation/AnimationManager.ts
+++ /dev/null
@@ -1,306 +0,0 @@
-///
-
-/**
- * AnimationManager
- *
- * Any Game Object that supports animation contains a single AnimationManager instance. It is used to add,
- * play and update Phaser.Animation objects.
- *
- * @package Phaser.Components.AnimationManager
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser.Components {
-
- export class AnimationManager {
-
- /**
- * AnimationManager constructor
- * Create a new AnimationManager.
- *
- * @param parent {Sprite} Owner sprite of this manager.
- */
- constructor(parent: Phaser.Sprite) {
-
- this._parent = parent;
- this.game = parent.game;
- this._anims = {};
-
- }
-
- /**
- * Reference to Phaser.Game
- */
- public game: Phaser.Game;
-
- /**
- * Local private reference to its parent game object.
- */
- private _parent: Phaser.Sprite;
-
- /**
- * Animation key-value container.
- */
- private _anims: {};
-
- /**
- * Index of current frame.
- * @type {number}
- */
- private _frameIndex: number;
-
- /**
- * Data contains animation frames.
- * @type {FrameData}
- */
- private _frameData: FrameData = null;
-
- /**
- * When an animation frame changes you can choose to automatically update the physics bounds of the parent Sprite
- * to the width and height of the new frame. If you've set a specific physics bounds that you don't want changed during
- * animation then set this to false, otherwise leave it set to true.
- * @type {bool}
- */
- public autoUpdateBounds: bool = true;
-
- /**
- * Keeps track of the current animation being played.
- */
- public currentAnim: Phaser.Animation;
-
- /**
- * Keeps track of the current frame of animation.
- */
- public currentFrame: Phaser.Frame = null;
-
- /**
- * Load animation frame data.
- * @param frameData Data to be loaded.
- */
- public loadFrameData(frameData: Phaser.FrameData) {
-
- this._frameData = frameData;
-
- this.frame = 0;
-
- }
-
- /**
- * Add a new animation.
- * @param name {string} What this animation should be called (e.g. "run").
- * @param frames {any[]} An array of numbers/strings indicating what frames to play in what order (e.g. [1, 2, 3] or ['run0', 'run1', run2]).
- * @param frameRate {number} The speed in frames per second that the animation should play at (e.g. 60 fps).
- * @param loop {bool} Whether or not the animation is looped or just plays once.
- * @param useNumericIndex {bool} Use number indexes instead of string indexes?
- * @return {Animation} The Animation that was created
- */
- public add(name: string, frames: any[] = null, frameRate: number = 60, loop: bool = false, useNumericIndex: bool = true): Phaser.Animation {
-
- if (this._frameData == null)
- {
- return;
- }
-
- // Create the signals the AnimationManager will emit
- if (this._parent.events.onAnimationStart == null)
- {
- this._parent.events.onAnimationStart = new Phaser.Signal;
- this._parent.events.onAnimationComplete = new Phaser.Signal;
- this._parent.events.onAnimationLoop = new Phaser.Signal;
- }
-
- if (frames == null)
- {
- frames = this._frameData.getFrameIndexes();
- }
- else
- {
- if (this.validateFrames(frames, useNumericIndex) == false)
- {
- throw Error('Invalid frames given to Animation ' + name);
- return;
- }
- }
-
- if (useNumericIndex == false)
- {
- frames = this._frameData.getFrameIndexesByName(frames);
- }
-
- this._anims[name] = new Animation(this.game, this._parent, this._frameData, name, frames, frameRate, loop);
-
- this.currentAnim = this._anims[name];
- this.currentFrame = this.currentAnim.currentFrame;
-
- return this._anims[name];
-
- }
-
- /**
- * Check whether the frames is valid.
- * @param frames {any[]} Frames to be validated.
- * @param useNumericIndex {bool} Does these frames use number indexes or string indexes?
- * @return {bool} True if they're valid, otherwise return false.
- */
- private validateFrames(frames: any[], useNumericIndex: bool): bool {
-
- for (var i = 0; i < frames.length; i++)
- {
- if (useNumericIndex == true)
- {
- if (frames[i] > this._frameData.total)
- {
- return false;
- }
- }
- else
- {
- if (this._frameData.checkFrameName(frames[i]) == false)
- {
- return false;
- }
- }
- }
-
- return true;
-
- }
-
- /**
- * Play animation with specific name.
- * @param name {string} The string name of the animation you want to play.
- * @param frameRate {number} FrameRate you want to specify instead of using default.
- * @param loop {bool} Whether or not the animation is looped or just plays once.
- */
- public play(name: string, frameRate: number = null, loop: bool = null): Phaser.Animation {
-
- if (this._anims[name])
- {
- if (this.currentAnim == this._anims[name])
- {
- if (this.currentAnim.isPlaying == false)
- {
- return this.currentAnim.play(frameRate, loop);
- }
- }
- else
- {
- this.currentAnim = this._anims[name];
- return this.currentAnim.play(frameRate, loop);
- }
- }
-
- }
-
- /**
- * Stop animation by name.
- * Current animation will be automatically set to the stopped one.
- */
- public stop(name: string) {
-
- if (this._anims[name])
- {
- this.currentAnim = this._anims[name];
- this.currentAnim.stop();
- }
-
- }
-
- /**
- * Update animation and parent sprite's bounds.
- */
- public update() {
-
- if (this.currentAnim && this.currentAnim.update() == true)
- {
- this.currentFrame = this.currentAnim.currentFrame;
- this._parent.texture.width = this.currentFrame.width;
- this._parent.texture.height = this.currentFrame.height;
- }
-
- }
-
- public get frameData(): FrameData {
- return this._frameData;
- }
-
- public get frameTotal(): number {
-
- if (this._frameData)
- {
- return this._frameData.total;
- }
- else
- {
- return -1;
- }
- }
-
- public get frame(): number {
- return this._frameIndex;
- }
-
- /**
- *
- * @param value
- */
- public set frame(value: number) {
-
- if (this._frameData && this._frameData.getFrame(value) !== null)
- {
- this.currentFrame = this._frameData.getFrame(value);
-
- this._parent.texture.width = this.currentFrame.width;
- this._parent.texture.height = this.currentFrame.height;
-
- if (this.autoUpdateBounds && this._parent['body'])
- {
- this._parent.body.bounds.width = this.currentFrame.width;
- this._parent.body.bounds.height = this.currentFrame.height;
- }
-
- this._frameIndex = value;
- }
-
- }
-
- public get frameName(): string {
- return this.currentFrame.name;
- }
-
- public set frameName(value: string) {
-
- if (this._frameData && this._frameData.getFrameByName(value))
- {
- this.currentFrame = this._frameData.getFrameByName(value);
-
- this._parent.texture.width = this.currentFrame.width;
- this._parent.texture.height = this.currentFrame.height;
-
- this._frameIndex = this.currentFrame.index;
- }
- else
- {
- throw new Error("Cannot set frameName: " + value);
- }
-
- }
-
- /**
- * Removes all related references
- */
- public destroy() {
-
- this._anims = {};
- this._frameData = null;
- this._frameIndex = 0;
- this.currentAnim = null;
- this.currentFrame = null;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/animation/Frame.ts b/wip/TS Source/animation/Frame.ts
deleted file mode 100644
index d00f47fd..00000000
--- a/wip/TS Source/animation/Frame.ts
+++ /dev/null
@@ -1,171 +0,0 @@
-///
-
-/**
- * Frame
- *
- * A Frame is a single frame of an animation and is part of a FrameData collection.
- *
- * @package Phaser.Frame
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class Frame {
-
- /**
- * Frame constructor
- * Create a new Frame with specific position, size and name.
- *
- * @param x {number} X position within the image to cut from.
- * @param y {number} Y position within the image to cut from.
- * @param width {number} Width of the frame.
- * @param height {number} Height of the frame.
- * @param name {string} Name of this frame.
- */
- constructor(x: number, y: number, width: number, height: number, name: string) {
-
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- this.name = name;
-
- this.rotated = false;
- this.trimmed = false;
-
- }
-
- public game: Phaser.Game;
-
- /**
- * X position within the image to cut from.
- * @type {number}
- */
- public x: number;
-
- /**
- * Y position within the image to cut from.
- * @type {number}
- */
- public y: number;
-
- /**
- * Width of the frame.
- * @type {number}
- */
- public width: number;
-
- /**
- * Height of the frame.
- * @type {number}
- */
- public height: number;
-
- /**
- * Useful for Sprite Sheets.
- * @type {number}
- */
- public index: number;
-
- /**
- * Useful for Texture Atlas files. (is set to the filename value)
- */
- public name: string = '';
-
- /**
- * Rotated? (not yet implemented)
- */
- public rotated: bool = false;
-
- /**
- * Either cw or ccw, rotation is always 90 degrees.
- */
- public rotationDirection: string = 'cw';
-
- /**
- * Was it trimmed when packed?
- * @type {bool}
- */
- public trimmed: bool;
-
- // The coordinates of the trimmed sprite inside the original sprite
-
- /**
- * Width of the original sprite.
- * @type {number}
- */
- public sourceSizeW: number;
-
- /**
- * Height of the original sprite.
- * @type {number}
- */
- public sourceSizeH: number;
-
- /**
- * X position of the trimmed sprite inside original sprite.
- * @type {number}
- */
- public spriteSourceSizeX: number;
-
- /**
- * Y position of the trimmed sprite inside original sprite.
- * @type {number}
- */
- public spriteSourceSizeY: number;
-
- /**
- * Width of the trimmed sprite.
- * @type {number}
- */
- public spriteSourceSizeW: number;
-
- /**
- * Height of the trimmed sprite.
- * @type {number}
- */
- public spriteSourceSizeH: number;
-
- /**
- * Set rotation of this frame. (Not yet supported!)
- */
- public setRotation(rotated: bool, rotationDirection: string) {
- // Not yet supported
- }
-
- /**
- * Set trim of the frame.
- * @param trimmed {bool} Whether this frame trimmed or not.
- * @param actualWidth {number} Actual width of this frame.
- * @param actualHeight {number} Actual height of this frame.
- * @param destX {number} Destination x position.
- * @param destY {number} Destination y position.
- * @param destWidth {number} Destination draw width.
- * @param destHeight {number} Destination draw height.
- */
- public setTrim(trimmed: bool, actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number) {
-
- //console.log('setTrim', trimmed, 'aw', actualWidth, 'ah', actualHeight, 'dx', destX, 'dy', destY, 'dw', destWidth, 'dh', destHeight);
-
- this.trimmed = trimmed;
-
- if (trimmed)
- {
- this.width = actualWidth;
- this.height = actualHeight;
- this.sourceSizeW = actualWidth;
- this.sourceSizeH = actualHeight;
- this.spriteSourceSizeX = destX;
- this.spriteSourceSizeY = destY;
- this.spriteSourceSizeW = destWidth;
- this.spriteSourceSizeH = destHeight;
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/animation/FrameData.ts b/wip/TS Source/animation/FrameData.ts
deleted file mode 100644
index bd076850..00000000
--- a/wip/TS Source/animation/FrameData.ts
+++ /dev/null
@@ -1,195 +0,0 @@
-///
-
-/**
- * FrameData
- *
- * FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser.
- *
- * @package Phaser.FrameData
- * @author Richard Davey
- * @copyright 2013 Photon Storm Ltd.
- * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
- */
-
-module Phaser {
-
- export class FrameData {
-
- /**
- * FrameData constructor
- */
- constructor() {
-
- this._frames = [];
- this._frameNames = [];
-
- }
-
- /**
- * Local frame container.
- */
- private _frames: Phaser.Frame[];
-
- /**
- * Local frameName<->index container.
- */
- private _frameNames;
-
- public get total(): number {
- return this._frames.length;
- }
-
- /**
- * Add a new frame.
- * @param frame {Frame} The frame you want to add.
- * @return {Frame} The frame you just added.
- */
- public addFrame(frame: Phaser.Frame): Phaser.Frame {
-
- frame.index = this._frames.length;
-
- this._frames.push(frame);
-
- if (frame.name !== '')
- {
- this._frameNames[frame.name] = frame.index;
- }
-
- return frame;
-
- }
-
- /**
- * Get a frame by its index.
- * @param index {number} Index of the frame you want to get.
- * @return {Frame} The frame you want.
- */
- public getFrame(index: number): Frame {
-
- if (this._frames[index])
- {
- return this._frames[index];
- }
-
- return null;
-
- }
-
- /**
- * Get a frame by its name.
- * @param name {string} Name of the frame you want to get.
- * @return {Frame} The frame you want.
- */
- public getFrameByName(name: string): Phaser.Frame {
-
- if (this._frameNames[name] !== '')
- {
- return this._frames[this._frameNames[name]];
- }
-
- return null;
-
- }
-
- /**
- * Check whether there's a frame with given name.
- * @param name {string} Name of the frame you want to check.
- * @return {bool} True if frame with given name found, otherwise return false.
- */
- public checkFrameName(name: string): bool {
-
- if (this._frameNames[name] == null)
- {
- return false;
- }
-
- return true;
-
- }
-
- /**
- * Get ranges of frames in an array.
- * @param start {number} Start index of frames you want.
- * @param end {number} End index of frames you want.
- * @param [output] {Frame[]} result will be added into this array.
- * @return {Frame[]} Ranges of specific frames in an array.
- */
- public getFrameRange(start: number, end: number, output: Phaser.Frame[]= []): Phaser.Frame[] {
-
- for (var i = start; i <= end; i++)
- {
- output.push(this._frames[i]);
- }
-
- return output;
-
- }
-
- /**
- * Get all indexes of frames by giving their name.
- * @param [output] {number[]} result will be added into this array.
- * @return {number[]} Indexes of specific frames in an array.
- */
- public getFrameIndexes(output: number[] = []): number[] {
-
- output.length = 0;
-
- for (var i = 0; i < this._frames.length; i++)
- {
- output.push(i);
- }
-
- return output;
-
- }
-
- /**
- * Get the frame indexes by giving the frame names.
- * @param [output] {number[]} result will be added into this array.
- * @return {number[]} Names of specific frames in an array.
- */
- public getFrameIndexesByName(input: string[]): number[] {
-
- var output: number[] = [];
-
- for (var i = 0; i < input.length; i++)
- {
- if (this.getFrameByName(input[i]))
- {
- output.push(this.getFrameByName(input[i]).index);
- }
- }
-
- return output;
-
- }
-
- /**
- * Get all frames in this frame data.
- * @return {Frame[]} All the frames in an array.
- */
- public getAllFrames(): Phaser.Frame[] {
- return this._frames;
- }
-
- /**
- * Get All frames with specific ranges.
- * @param range {number[]} Ranges in an array.
- * @return {Frame[]} All frames in an array.
- */
- public getFrames(range: number[]) {
-
- var output: Phaser.Frame[] = [];
-
- for (var i = 0; i < range.length; i++)
- {
- output.push(this._frames[i]);
- }
-
- return output;
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/cameras/Camera.ts b/wip/TS Source/cameras/Camera.ts
deleted file mode 100644
index 58bf613c..00000000
--- a/wip/TS Source/cameras/Camera.ts
+++ /dev/null
@@ -1,531 +0,0 @@
-///
-
-/**
-* Phaser - Camera
-*
-* A Camera is your view into the game world. It has a position, size, scale and rotation and renders only those objects
-* within its field of view. The game automatically creates a single Stage sized camera on boot, but it can be changed and
-* additional cameras created via the CameraManager.
-*/
-
-module Phaser {
-
- export class Camera {
-
- /**
- * Instantiates a new camera at the specified location, with the specified size and zoom level.
- *
- * @param game {Phaser.Game} Current game instance.
- * @param id {number} Unique identity.
- * @param x {number} X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
- * @param y {number} Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
- * @param width {number} The width of the camera display in pixels.
- * @param height {number} The height of the camera display in pixels.
- */
- constructor(game: Game, id: number, x: number, y: number, width: number, height: number) {
-
- this.game = game;
-
- this.ID = id;
- this.z = id;
-
- width = this.game.math.clamp(width, this.game.stage.width, 1);
- height = this.game.math.clamp(height, this.game.stage.height, 1);
-
- // The view into the world we wish to render (by default the full game world size)
- // The size of this Rect is the same as screenView, but the values are all in world coordinates instead of screen coordinates
- this.worldView = new Rectangle(0, 0, width, height);
-
- // The rect of the area being rendered in stage/screen coordinates
- this.screenView = new Rectangle(x, y, width, height);
-
- this.plugins = new PluginManager(this.game, this);
-
- this.transform = new Phaser.Components.TransformManager(this);
- this.texture = new Phaser.Display.Texture(this);
-
- // We create a hidden canvas for our camera the size of the game (we use the screenView to clip the render to the camera size)
- this._canvas = document.createElement('canvas');
- this._canvas.width = width;
- this._canvas.height = height;
- this._renderLocal = true;
- this.texture.canvas = this._canvas;
- this.texture.context = this.texture.canvas.getContext('2d');
- this.texture.backgroundColor = this.game.stage.backgroundColor;
-
- // Handy proxies
- this.scale = this.transform.scale;
- this.alpha = this.texture.alpha;
- this.origin = this.transform.origin;
- this.crop = this.texture.crop;
-
- }
-
- private _renderLocal: bool;
- private _canvas: HTMLCanvasElement;
- private _target: Sprite = null;
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * The PluginManager for the Game
- * @type {PluginManager}
- */
- public plugins: PluginManager;
-
- /**
- * Optional texture used in the background of the Camera.
- */
- public texture: Phaser.Display.Texture;
-
- /**
- * The transform component.
- */
- public transform: Phaser.Components.TransformManager;
-
- /**
- * The scale of the Sprite. A value of 1 is original scale. 0.5 is half size. 2 is double the size.
- * This is a reference to Sprite.transform.scale
- */
- public scale: Phaser.Vec2;
-
- /**
- * The crop rectangle allows you to control which part of the sprite texture is rendered without distorting it.
- * Set to null to disable, set to a Phaser.Rectangle object to control the region that will be rendered, anything outside the rectangle is ignored.
- * This is a reference to Sprite.texture.crop
- * @type {Phaser.Rectangle}
- */
- public crop: Phaser.Rectangle;
-
- /**
- * The origin of the Sprite around which rotation and positioning takes place.
- * This is a reference to Sprite.transform.origin
- */
- public origin: Phaser.Vec2;
-
- /**
- * The alpha of the Sprite between 0 and 1, a value of 1 being fully opaque.
- */
- public set alpha(value: number) {
- this.texture.alpha = value;
- }
-
- /**
- * The alpha of the Sprite between 0 and 1, a value of 1 being fully opaque.
- */
- public get alpha(): number {
- return this.texture.alpha;
- }
-
- /**
- * Identity of this camera.
- */
- public ID: number;
-
- /**
- * Camera view Rectangle in world coordinate.
- * @type {Rectangle}
- */
- public worldView: Rectangle;
-
- /**
- * Visible / renderable area (changes if the camera resizes/moves around the stage)
- * @type {Rectangle}
- */
- public screenView: Rectangle;
-
- /**
- * Camera worldBounds.
- * @type {Rectangle}
- */
- public worldBounds: Rectangle = null;
-
- /**
- * A bool representing if the Camera has been modified in any way via a scale, rotate, flip or skew.
- */
- public modified: bool = false;
-
- /**
- * Sprite moving inside this Rectangle will not cause camera moving.
- * @type {Rectangle}
- */
- public deadzone: Rectangle = null;
-
- /**
- * Whether this camera is visible or not. (default is true)
- * @type {bool}
- */
- public visible: bool = true;
-
- /**
- * The z value of this Camera. Cameras are rendered in z-index order by the Renderer.
- */
- public z: number = -1;
-
- public set directToStage(value: bool) {
-
- if (value)
- {
- this._renderLocal = false;
- this.texture.canvas = this.game.stage.canvas;
- Phaser.CanvasUtils.setBackgroundColor(this.texture.canvas, this.game.stage.backgroundColor);
- }
- else
- {
- this._renderLocal = true;
- this.texture.canvas = this._canvas;
- Phaser.CanvasUtils.setBackgroundColor(this.texture.canvas, this.texture.backgroundColor);
- }
-
- this.texture.context = this.texture.canvas.getContext('2d');
-
- }
-
- /**
- * Hides an object from this Camera. Hidden objects are not rendered.
- * The object must implement a public cameraBlacklist property.
- *
- * @param object {Sprite/Group} The object this camera should ignore.
- */
- public hide(object) {
-
- object.texture.hideFromCamera(this);
-
- }
-
- /**
- * Returns true if the object is hidden from this Camera.
- *
- * @param object {Sprite/Group} The object to check.
- */
- public isHidden(object): bool {
- return object.texture.isHidden(this);
- }
-
- /**
- * Un-hides an object previously hidden to this Camera.
- * The object must implement a public cameraBlacklist property.
- *
- * @param object {Sprite/Group} The object this camera should display.
- */
- public show(object) {
-
- object.texture.showToCamera(this);
-
- }
-
- /**
- * Tells this camera object what sprite to track.
- * @param target {Sprite} The object you want the camera to track. Set to null to not follow anything.
- * @param [style] {number} Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
- */
- public follow(target: Sprite, style: number = Phaser.Types.CAMERA_FOLLOW_LOCKON) {
-
- this._target = target;
-
- var helper: number;
-
- switch (style)
- {
- case Phaser.Types.CAMERA_FOLLOW_PLATFORMER:
- var w: number = this.width / 8;
- var h: number = this.height / 3;
- this.deadzone = new Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h);
- break;
- case Phaser.Types.CAMERA_FOLLOW_TOPDOWN:
- helper = Math.max(this.width, this.height) / 4;
- this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
- break;
- case Phaser.Types.CAMERA_FOLLOW_TOPDOWN_TIGHT:
- helper = Math.max(this.width, this.height) / 8;
- this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
- break;
- case Phaser.Types.CAMERA_FOLLOW_LOCKON:
- default:
- this.deadzone = null;
- break;
- }
-
- }
-
- /**
- * Move the camera focus to this location instantly.
- * @param x {number} X position.
- * @param y {number} Y position.
- */
- public focusOnXY(x: number, y: number) {
-
- x += (x > 0) ? 0.0000001 : -0.0000001;
- y += (y > 0) ? 0.0000001 : -0.0000001;
-
- this.worldView.x = Math.round(x - this.worldView.halfWidth);
- this.worldView.y = Math.round(y - this.worldView.halfHeight);
-
- }
-
- /**
- * Move the camera focus to this location instantly.
- * @param point {any} Point you want to focus.
- */
- public focusOn(point) {
-
- point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
- point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
-
- this.worldView.x = Math.round(point.x - this.worldView.halfWidth);
- this.worldView.y = Math.round(point.y - this.worldView.halfHeight);
-
- }
-
- /**
- * Specify the boundaries of the world or where the camera is allowed to move.
- *
- * @param x {number} The smallest X value of your world (usually 0).
- * @param y {number} The smallest Y value of your world (usually 0).
- * @param width {number} The largest X value of your world (usually the world width).
- * @param height {number} The largest Y value of your world (usually the world height).
- */
- public setBounds(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
-
- if (this.worldBounds == null)
- {
- this.worldBounds = new Rectangle;
- }
-
- this.worldBounds.setTo(x, y, width, height);
-
- this.worldView.x = x;
- this.worldView.y = y;
-
- this.update();
- }
-
- /**
- * Update focusing and scrolling.
- */
- public update() {
-
- if (this.modified == false && (!this.transform.scale.equals(1) || !this.transform.skew.equals(0) || this.transform.rotation != 0 || this.transform.rotationOffset != 0 || this.texture.flippedX || this.texture.flippedY))
- {
- this.modified = true;
- }
-
- this.plugins.preUpdate();
-
- if (this._target !== null)
- {
- if (this.deadzone == null)
- {
- this.focusOnXY(this._target.x, this._target.y);
- }
- else
- {
- var edge: number;
- var targetX: number = this._target.x + ((this._target.x > 0) ? 0.0000001 : -0.0000001);
- var targetY: number = this._target.y + ((this._target.y > 0) ? 0.0000001 : -0.0000001);
-
- edge = targetX - this.deadzone.x;
-
- if (this.worldView.x > edge)
- {
- this.worldView.x = edge;
- }
-
- edge = targetX + this._target.width - this.deadzone.x - this.deadzone.width;
-
- if (this.worldView.x < edge)
- {
- this.worldView.x = edge;
- }
-
- edge = targetY - this.deadzone.y;
-
- if (this.worldView.y > edge)
- {
- this.worldView.y = edge;
- }
-
- edge = targetY + this._target.height - this.deadzone.y - this.deadzone.height;
-
- if (this.worldView.y < edge)
- {
- this.worldView.y = edge;
- }
- }
-
- }
-
- // Make sure we didn't go outside the cameras worldBounds
- if (this.worldBounds !== null)
- {
- if (this.worldView.x < this.worldBounds.left)
- {
- this.worldView.x = this.worldBounds.left;
- }
-
- if (this.worldView.x > this.worldBounds.right - this.width)
- {
- this.worldView.x = (this.worldBounds.right - this.width) + 1;
- }
-
- if (this.worldView.y < this.worldBounds.top)
- {
- this.worldView.y = this.worldBounds.top;
- }
-
- if (this.worldView.y > this.worldBounds.bottom - this.height)
- {
- this.worldView.y = (this.worldBounds.bottom - this.height) + 1;
- }
- }
-
- this.worldView.floor();
-
- this.plugins.update();
-
- }
-
- /**
- * Update focusing and scrolling.
- */
- public postUpdate() {
-
- if (this.modified == true && this.transform.scale.equals(1) && this.transform.skew.equals(0) && this.transform.rotation == 0 && this.transform.rotationOffset == 0 && this.texture.flippedX == false && this.texture.flippedY == false)
- {
- this.modified = false;
- }
-
- // Make sure we didn't go outside the cameras worldBounds
- if (this.worldBounds !== null)
- {
- if (this.worldView.x < this.worldBounds.left)
- {
- this.worldView.x = this.worldBounds.left;
- }
-
- if (this.worldView.x > this.worldBounds.right - this.width)
- {
- this.worldView.x = this.worldBounds.right - this.width;
- }
-
- if (this.worldView.y < this.worldBounds.top)
- {
- this.worldView.y = this.worldBounds.top;
- }
-
- if (this.worldView.y > this.worldBounds.bottom - this.height)
- {
- this.worldView.y = this.worldBounds.bottom - this.height;
- }
- }
-
- this.worldView.floor();
-
- this.plugins.postUpdate();
-
- }
-
- /**
- * Destroys this camera, associated FX and removes itself from the CameraManager.
- */
- public destroy() {
-
- this.game.world.cameras.removeCamera(this.ID);
- this.plugins.destroy();
- }
-
- public get x(): number {
- return this.worldView.x;
- }
-
- public get y(): number {
- return this.worldView.y;
- }
-
- public set x(value: number) {
- this.worldView.x = value;
- }
-
- public set y(value: number) {
- this.worldView.y = value;
- }
-
- public get width(): number {
- return this.screenView.width;
- }
-
- public get height(): number {
- return this.screenView.height;
- }
-
- public set width(value: number) {
-
- this.screenView.width = value;
- this.worldView.width = value;
-
- if (value !== this.texture.canvas.width)
- {
- this.texture.canvas.width = value;
- }
-
- }
-
- public set height(value: number) {
-
- this.screenView.height = value;
- this.worldView.height = value;
-
- if (value !== this.texture.canvas.height)
- {
- this.texture.canvas.height = value;
- }
-
- }
-
- public setPosition(x: number, y: number) {
-
- this.screenView.x = x;
- this.screenView.y = y;
-
- }
-
- public setSize(width: number, height: number) {
-
- this.screenView.width = width * this.transform.scale.x;
- this.screenView.height = height * this.transform.scale.y;
- this.worldView.width = width;
- this.worldView.height = height;
-
- if (width !== this.texture.canvas.width)
- {
- this.texture.canvas.width = width;
- }
-
- if (height !== this.texture.canvas.height)
- {
- this.texture.canvas.height = height;
- }
-
- }
-
- /**
- * The angle of the Camera in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
- */
- public get rotation(): number {
- return this.transform.rotation;
- }
-
- /**
- * Set the angle of the Camera in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
- * The value is automatically wrapped to be between 0 and 360.
- */
- public set rotation(value: number) {
- this.transform.rotation = this.game.math.wrap(value, 360, 0);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/cameras/CameraManager.ts b/wip/TS Source/cameras/CameraManager.ts
deleted file mode 100644
index b28037ea..00000000
--- a/wip/TS Source/cameras/CameraManager.ts
+++ /dev/null
@@ -1,240 +0,0 @@
-///
-
-/**
-* Phaser - CameraManager
-*
-* Your game only has one CameraManager instance and it's responsible for looking after, creating and destroying
-* all of the cameras in the world.
-*/
-
-module Phaser {
-
- export class CameraManager {
-
- /**
- * CameraManager constructor
- * This will create a new Camera with position and size.
- *
- * @param x {number} X Position of the created camera.
- * @param y {number} y Position of the created camera.
- * @param width {number} Width of the created camera.
- * @param height {number} Height of the created camera.
- */
- constructor(game: Phaser.Game, x: number, y: number, width: number, height: number) {
-
- this.game = game;
-
- this._cameras = [];
- this._cameraLength = 0;
-
- this.defaultCamera = this.addCamera(x, y, width, height);
-
- this.defaultCamera.directToStage = true;
-
- this.current = this.defaultCamera;
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Local container for storing cameras.
- */
- private _cameras: Phaser.Camera[];
-
- /**
- * Local container for storing cameras array length.
- */
- private _cameraLength: number;
-
- /**
- * Helper for sort.
- */
- private _sortIndex: string = '';
-
- /**
- * Helper for sort.
- */
- private _sortOrder: number;
-
- /**
- * Currently used camera.
- */
- public current: Phaser.Camera;
-
- /**
- * The default created camera.
- */
- public defaultCamera: Phaser.Camera;
-
- /**
- * Get all the cameras.
- *
- * @returns {Camera[]} An array contains all the cameras.
- */
- public getAll(): Phaser.Camera[] {
- return this._cameras;
- }
-
- /**
- * Update cameras.
- */
- public update() {
-
- for (var i = 0; i < this._cameras.length; i++)
- {
- this._cameras[i].update();
- }
-
- }
-
- /**
- * postUpdate cameras.
- */
- public postUpdate() {
-
- for (var i = 0; i < this._cameras.length; i++)
- {
- this._cameras[i].postUpdate();
- }
-
- }
-
- /**
- * Create a new camera with specific position and size.
- *
- * @param x {number} X position of the new camera.
- * @param y {number} Y position of the new camera.
- * @param width {number} Width of the new camera.
- * @param height {number} Height of the new camera.
- * @returns {Camera} The newly created camera object.
- */
- public addCamera(x: number, y: number, width: number, height: number): Phaser.Camera {
-
- var newCam: Phaser.Camera = new Phaser.Camera(this.game, this._cameraLength, x, y, width, height);
-
- this._cameraLength = this._cameras.push(newCam);
-
- return newCam;
-
- }
-
- /**
- * Remove a new camera with its id.
- *
- * @param id {number} ID of the camera you want to remove.
- * @returns {bool} True if successfully removed the camera, otherwise return false.
- */
- public removeCamera(id: number): bool {
-
- for (var c = 0; c < this._cameras.length; c++)
- {
- if (this._cameras[c].ID == id)
- {
- if (this.current.ID === this._cameras[c].ID)
- {
- this.current = null;
- }
-
- this._cameras.splice(c, 1);
-
- return true;
- }
- }
-
- return false;
-
- }
-
- public swap(camera1: Phaser.Camera, camera2: Phaser.Camera, sort: bool = true): bool {
-
- if (camera1.ID == camera2.ID)
- {
- return false;
- }
-
- var tempZ: number = camera1.z;
-
- camera1.z = camera2.z;
- camera2.z = tempZ;
-
- if (sort)
- {
- this.sort();
- }
-
- return true;
-
- }
-
- public getCameraUnderPoint(x: number, y: number): Phaser.Camera {
-
- // Work through the cameras in reverse as they are rendered in array order
- // Return the first camera we find matching the criteria
- for (var c = this._cameraLength - 1; c >= 0; c--)
- {
- if (this._cameras[c].visible && Phaser.RectangleUtils.contains(this._cameras[c].screenView, x, y))
- {
- return this._cameras[c];
- }
- }
-
- return null;
-
- }
-
- /**
- * Call this function to sort the Cameras according to a particular value and order (default is their Z value).
- * The order in which they are sorted determines the render order. If sorted on z then Cameras with a lower z-index value render first.
- *
- * @param {string} index The string name of the Camera variable you want to sort on. Default value is "z".
- * @param {number} order A Group constant that defines the sort order. Possible values are Group.ASCENDING and Group.DESCENDING. Default value is Group.ASCENDING.
- */
- public sort(index: string = 'z', order: number = Phaser.Types.SORT_ASCENDING) {
-
- this._sortIndex = index;
- this._sortOrder = order;
- this._cameras.sort((a, b) => this.sortHandler(a, b));
-
- }
-
- /**
- * Helper function for the sort process.
- *
- * @param {Basic} Obj1 The first object being sorted.
- * @param {Basic} Obj2 The second object being sorted.
- *
- * @return {number} An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
- */
- public sortHandler(obj1, obj2): number {
-
- if (obj1[this._sortIndex] < obj2[this._sortIndex])
- {
- return this._sortOrder;
- }
- else if (obj1[this._sortIndex] > obj2[this._sortIndex])
- {
- return -this._sortOrder;
- }
-
- return 0;
-
- }
-
- /**
- * Clean up memory.
- */
- public destroy() {
-
- this._cameras.length = 0;
-
- this.current = this.addCamera(0, 0, this.game.stage.width, this.game.stage.height);
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/core/Group.ts b/wip/TS Source/core/Group.ts
deleted file mode 100644
index 480cb270..00000000
--- a/wip/TS Source/core/Group.ts
+++ /dev/null
@@ -1,1096 +0,0 @@
-///
-
-/**
-* Phaser - Group
-*
-* This class is used for organising, updating and sorting game objects.
-*/
-
-module Phaser {
-
- export class Group {
-
- constructor(game: Phaser.Game, maxSize: number = 0) {
-
- this.game = game;
- this.type = Phaser.Types.GROUP;
- this.active = true;
- this.exists = true;
- this.visible = true;
-
- this.members = [];
- this.length = 0;
-
- this._maxSize = maxSize;
- this._marker = 0;
- this._sortIndex = null;
-
- this.ID = this.game.world.getNextGroupID();
-
- this.transform = new Phaser.Components.TransformManager(this);
- this.texture = new Phaser.Display.Texture(this);
- this.texture.opaque = false;
-
- }
-
- /**
- * Internal tracker for the maximum capacity of the group.
- * Default is 0, or no max capacity.
- */
- private _maxSize: number;
-
- /**
- * Internal helper variable for recycling objects a la Emitter.
- */
- private _marker: number;
-
- /**
- * Helper for sort.
- */
- private _sortIndex: string = '';
-
- /**
- * Helper for sort.
- */
- private _sortOrder: number;
-
- /**
- * Temp vars to help avoid gc spikes
- */
- private _member;
- private _length: number;
- private _i: number;
- private _prevAlpha: number;
- private _count: number;
-
- /**
- * This keeps track of the z value of any game object added to this Group
- */
- private _zCounter: number = 0;
-
- /**
- * Reference to the main game object
- */
- public game: Phaser.Game;
-
- /**
- * The type of game object.
- */
- public type: number;
-
- /**
- * The unique Group ID
- */
- public ID: number = -1;
-
- /**
- * The z value of this Group (within its parent Group, if any)
- */
- public z: number = -1;
-
- /**
- * The Group this Group is a child of (if any).
- */
- public group: Phaser.Group = null;
-
- /**
- * Optional texture used in the background of the Camera.
- */
- public texture: Phaser.Display.Texture;
-
- /**
- * The transform component.
- * WTF TypeScript, thank you very much for wasting a day of my time debugging just to find out setting the type barfs
- */
- //public transform: Phaser.Components.TransformManager;
- public transform;
-
- /**
- * A bool representing if the Group has been modified in any way via a scale, rotate, flip or skew.
- */
- public modified: bool = false;
-
- /**
- * If this Group exists or not. Can be set to false to skip certain loop checks.
- */
- public exists: bool;
-
- /**
- * If this Group exists or not. Can be set to false to skip certain loop checks.
- */
- public active: bool;
-
- /**
- * Controls if this Group (and all of its contents) are rendered or skipped during the core game loop.
- */
- public visible: bool;
-
- /**
- * Array of all the objects that exist in this group.
- */
- public members;
-
- /**
- * The number of entries in the members array.
- * For performance and safety you should check this variable
- * instead of members.length unless you really know what you're doing!
- */
- public length: number;
-
- /**
- * Gets the next z index value for children of this Group
- */
- public getNextZIndex(): number {
- return this._zCounter++;
- }
-
- /**
- * Override this function to handle any deleting or "shutdown" type operations you might need,
- * such as removing traditional children like Basic objects.
- */
- public destroy() {
-
- if (this.members != null)
- {
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null)
- {
- this._member.destroy();
- }
- }
-
- this.members.length = 0;
- }
-
- this._sortIndex = null;
-
- }
-
- /**
- * Calls update on all members of this Group who have a status of active=true and exists=true
- * You can also call Object.update directly, which will bypass the active/exists check.
- */
- public update() {
-
- if (this.modified == false && (!this.transform.scale.equals(1) || !this.transform.skew.equals(0) || this.transform.rotation != 0 || this.transform.rotationOffset != 0 || this.texture.flippedX || this.texture.flippedY))
- {
- this.modified = true;
- }
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null && this._member.exists && this._member.active)
- {
- if (this._member.type != Phaser.Types.GROUP)
- {
- this._member.preUpdate();
- }
- this._member.update();
- }
- }
- }
-
- /**
- * Calls update on all members of this Group who have a status of active=true and exists=true
- * You can also call Object.postUpdate directly, which will bypass the active/exists check.
- */
- public postUpdate() {
-
- if (this.modified == true && this.transform.scale.equals(1) && this.transform.skew.equals(0) && this.transform.rotation == 0 && this.transform.rotationOffset == 0 && this.texture.flippedX == false && this.texture.flippedY == false)
- {
- this.modified = false;
- }
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null && this._member.exists && this._member.active)
- {
- this._member.postUpdate();
- }
- }
- }
-
- /**
- * Calls render on all members of this Group who have a status of visible=true and exists=true
- * You can also call Object.render directly, which will bypass the visible/exists check.
- */
- public render(camera: Phaser.Camera) {
-
- if (camera.isHidden(this) == true)
- {
- return;
- }
-
- this.game.renderer.groupRenderer.preRender(camera, this);
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null && this._member.exists && this._member.visible && camera.isHidden(this._member) == false)
- {
- if (this._member.type == Types.GROUP)
- {
- this._member.render(camera);
- }
- else
- {
- this.game.renderer.renderGameObject(camera, this._member);
- }
- }
- }
-
- this.game.renderer.groupRenderer.postRender(camera, this);
-
- }
-
- /**
- * Calls render on all members of this Group regardless of their visible status and also ignores the camera blacklist.
- * Use this when the Group objects render to hidden canvases for example.
- */
- public directRender(camera: Phaser.Camera) {
-
- this.game.renderer.groupRenderer.preRender(camera, this);
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null && this._member.exists)
- {
- if (this._member.type == Types.GROUP)
- {
- this._member.directRender(camera);
- }
- else
- {
- this.game.renderer.renderGameObject(this._member);
- }
- }
- }
-
- this.game.renderer.groupRenderer.postRender(camera, this);
-
- }
-
- /**
- * The maximum capacity of this group. Default is 0, meaning no max capacity, and the group can just grow.
- */
- public get maxSize(): number {
- return this._maxSize;
- }
-
- /**
- * @private
- */
- public set maxSize(size: number) {
-
- this._maxSize = size;
-
- if (this._marker >= this._maxSize)
- {
- this._marker = 0;
- }
-
- if (this._maxSize == 0 || this.members == null || (this._maxSize >= this.members.length))
- {
- return;
- }
-
- //If the max size has shrunk, we need to get rid of some objects
- this._i = this._maxSize;
- this._length = this.members.length;
-
- while (this._i < this._length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null)
- {
- this._member.destroy();
- }
- }
-
- this.length = this.members.length = this._maxSize;
- }
-
- /**
- * Adds a new Game Object to the group.
- * Group will try to replace a null member of the array first.
- * Failing that, Group will add it to the end of the member array,
- * assuming there is room for it, and doubling the size of the array if necessary.
- *
- *
WARNING: If the group has a maxSize that has already been met,
- * the object will NOT be added to the group!
- *
- * @param {Basic} Object The object you want to add to the group.
- * @return {Basic} The same object that was passed in.
- */
- public add(object): any {
-
- // Is this object already in another Group?
-
- // You can't add a Group to itself or an object to the same Group twice
- if (object.group && (object.group.ID == this.ID || (object.type == Types.GROUP && object.ID == this.ID)))
- {
- return object;
- }
-
- // First, look for a null entry where we can add the object.
- this._i = 0;
- this._length = this.members.length;
-
- while (this._i < this._length)
- {
- if (this.members[this._i] == null)
- {
- this.members[this._i] = object;
-
- this.setObjectIDs(object);
-
- if (this._i >= this.length)
- {
- this.length = this._i + 1;
- }
-
- return object;
- }
-
- this._i++;
- }
-
- // Failing that, expand the array (if we can) and add the object.
- if (this._maxSize > 0)
- {
- if (this.members.length >= this._maxSize)
- {
- return object;
- }
- else if (this.members.length * 2 <= this._maxSize)
- {
- this.members.length *= 2;
- }
- else
- {
- this.members.length = this._maxSize;
- }
- }
- else
- {
- this.members.length *= 2;
- }
-
- // If we made it this far, then we successfully grew the group,
- // and we can go ahead and add the object at the first open slot.
- this.members[this._i] = object;
- this.length = this._i + 1;
-
- this.setObjectIDs(object);
-
- return object;
-
- }
-
- /**
- * Create a new Sprite within this Group at the specified position.
- *
- * @param x {number} X position of the new sprite.
- * @param y {number} Y position of the new sprite.
- * @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this sprite
- * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
- * @returns {Sprite} The newly created sprite object.
- */
- public addNewSprite(x: number, y: number, key: string = '', frame = null): Phaser.Sprite {
- return this.add(new Phaser.Sprite(this.game, x, y, key, frame));
- }
-
- /**
- * Sets all of the game object properties needed to exist within this Group.
- */
- private setObjectIDs(object, zIndex: number = -1) {
-
- // If the object is already in another Group, inform that Group it has left
- if (object.group !== null)
- {
- object.group.remove(object);
- }
-
- object.group = this;
-
- if (zIndex == -1)
- {
- zIndex = this.getNextZIndex();
- }
-
- object.z = zIndex;
-
- if (object['events'])
- {
- object['events'].onAddedToGroup.dispatch(object, this, object.z);
- }
-
- }
-
- /**
- * Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
- *
- *
If you specified a maximum size for this group (like in Emitter),
- * then recycle will employ what we're calling "rotating" recycling.
- * Recycle() will first check to see if the group is at capacity yet.
- * If group is not yet at capacity, recycle() returns a new object.
- * If the group IS at capacity, then recycle() just returns the next object in line.
- *
- *
If you did NOT specify a maximum size for this group,
- * then recycle() will employ what we're calling "grow-style" recycling.
- * Recycle() will return either the first object with exists == false,
- * or, finding none, add a new object to the array,
- * doubling the size of the array if necessary.
- *
- *
WARNING: If this function needs to create a new object,
- * and no object class was provided, it will return null
- * instead of a valid object!
- *
- * @param {class} ObjectClass The class type you want to recycle (e.g. Basic, EvilRobot, etc). Do NOT "new" the class in the parameter!
- *
- * @return {any} A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).
- */
- public recycle(objectClass = null): any {
-
- if (this._maxSize > 0)
- {
- if (this.length < this._maxSize)
- {
- if (objectClass == null)
- {
- return null;
- }
-
- return this.add(new objectClass(this.game));
- }
- else
- {
- this._member = this.members[this._marker++];
-
- if (this._marker >= this._maxSize)
- {
- this._marker = 0;
- }
-
- return this._member;
- }
- }
- else
- {
- this._member = this.getFirstAvailable(objectClass);
-
- if (this._member != null)
- {
- return this._member;
- }
-
- if (objectClass == null)
- {
- return null;
- }
-
- return this.add(new objectClass(this.game));
- }
- }
-
- /**
- * Removes an object from the group.
- *
- * @param {Basic} object The Game Object you want to remove.
- * @param {bool} splice Whether the object should be cut from the array entirely or not.
- *
- * @return {Basic} The removed object.
- */
- public remove(object, splice: bool = false): any {
-
- //console.log('removing from group: ', object.name);
-
- this._i = this.members.indexOf(object);
-
- if (this._i < 0 || (this._i >= this.members.length))
- {
- return null;
- }
-
- if (splice)
- {
- this.members.splice(this._i, 1);
- this.length--;
- }
- else
- {
- this.members[this._i] = null;
- }
-
- //console.log('nulled');
-
- if (object['events'])
- {
- object['events'].onRemovedFromGroup.dispatch(object, this);
- }
-
- object.group = null;
- object.z = -1;
- return object;
-
- }
-
- /**
- * Replaces an existing game object in this Group with a new one.
- *
- * @param {Basic} oldObject The object you want to replace.
- * @param {Basic} newObject The new object you want to use instead.
- *
- * @return {Basic} The new object.
- */
- public replace(oldObject, newObject): any {
-
- this._i = this.members.indexOf(oldObject);
-
- if (this._i < 0 || (this._i >= this.members.length))
- {
- return null;
- }
-
- this.setObjectIDs(newObject, this.members[this._i].z);
-
- // Null the old object
- this.remove(this.members[this._i]);
-
- this.members[this._i] = newObject;
-
- return newObject;
-
- }
-
- /**
- * Swaps two existing game object in this Group with each other.
- *
- * @param {Basic} child1 The first object to swap.
- * @param {Basic} child2 The second object to swap.
- *
- * @return {Basic} True if the two objects successfully swapped position.
- */
- public swap(child1, child2, sort: bool = true): bool {
-
- if (child1.group.ID != this.ID || child2.group.ID != this.ID || child1 === child2)
- {
- return false;
- }
-
- var tempZ: number = child1.z;
-
- child1.z = child2.z;
- child2.z = tempZ;
-
- if (sort)
- {
- this.sort();
- }
-
- return true;
-
- }
-
- public bringToTop(child): bool {
-
- //console.log('bringToTop', child.name,'current z', child.z);
- var oldZ = child.z;
-
- // If child not in this group, or is already at the top of the group, return false
- //if (!child || child.group == null || child.group.ID != this.ID || child.z == this._zCounter)
- if (!child || child.group == null || child.group.ID != this.ID)
- {
- //console.log('If child not in this group, or is already at the top of the group, return false');
- return false;
- }
-
- // Find out the largest z index
- var topZ: number = -1;
-
- for (var i = 0; i < this.length; i++)
- {
- if (this.members[i] && this.members[i].z > topZ)
- {
- topZ = this.members[i].z;
- }
- }
-
- // Child is already at the top
- if (child.z == topZ)
- {
- return false;
- }
-
- child.z = topZ + 1;
-
- // Sort them out based on the current z indexes
- this.sort();
-
- // Now tidy-up the z indexes, removing gaps, etc
- for (var i = 0; i < this.length; i++)
- {
- if (this.members[i])
- {
- this.members[i].z = i;
- }
- }
-
- //console.log('bringToTop', child.name, 'old z', oldZ, 'new z', child.z);
-
- return true;
-
- // What's the z index of the top most child?
- /*
- var childIndex: number = this._zCounter;
-
- console.log('childIndex', childIndex);
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member)
- {
- if (this._i > childIndex)
- {
- this._member.z--;
- }
- else if (this._member.z == child.z)
- {
- childIndex = this._i;
- this._member.z = this._zCounter;
- }
- }
- }
-
- console.log('child inserted at index', child.z);
-
- // Maybe redundant?
- this.sort();
-
- return true;
- */
-
- }
-
- /**
- * Call this function to sort the group according to a particular value and order.
- * For example, to sort game objects for Zelda-style overlaps you might call
- * myGroup.sort("y",Group.ASCENDING) at the bottom of your
- * State.update() override. To sort all existing objects after
- * a big explosion or bomb attack, you might call myGroup.sort("exists",Group.DESCENDING).
- *
- * @param {string} index The string name of the member variable you want to sort on. Default value is "z".
- * @param {number} order A Group constant that defines the sort order. Possible values are Group.ASCENDING and Group.DESCENDING. Default value is Group.ASCENDING.
- */
- public sort(index: string = 'z', order: number = Phaser.Types.SORT_ASCENDING) {
-
- this._sortIndex = index;
- this._sortOrder = order;
- this.members.sort((a, b) => this.sortHandler(a, b));
-
- }
-
- /**
- * Helper function for the sort process.
- *
- * @param {Basic} Obj1 The first object being sorted.
- * @param {Basic} Obj2 The second object being sorted.
- *
- * @return {number} An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
- */
- public sortHandler(obj1, obj2): number {
-
- if (!obj1 || !obj2)
- {
- //console.log('null objects in sort', obj1, obj2);
- return 0;
- }
-
- if (obj1[this._sortIndex] < obj2[this._sortIndex])
- {
- return this._sortOrder;
- }
- else if (obj1[this._sortIndex] > obj2[this._sortIndex])
- {
- return -this._sortOrder;
- }
-
- return 0;
-
- }
-
- /**
- * Go through and set the specified variable to the specified value on all members of the group.
- *
- * @param {string} VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor".
- * @param {Object} Value The value you want to assign to that variable.
- * @param {bool} Recurse Default value is true, meaning if setAll() encounters a member that is a group, it will call setAll() on that group rather than modifying its variable.
- */
- public setAll(variableName: string, value: Object, recurse: bool = true) {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null)
- {
- if (recurse && this._member.type == Phaser.Types.GROUP)
- {
- this._member.setAll(variableName, value, recurse);
- }
- else
- {
- this._member[variableName] = value;
- }
- }
- }
- }
-
- /**
- * Go through and call the specified function on all members of the group.
- * Currently only works on functions that have no required parameters.
- *
- * @param {string} FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()".
- * @param {bool} Recurse Default value is true, meaning if callAll() encounters a member that is a group, it will call callAll() on that group rather than calling the group's function.
- */
- public callAll(functionName: string, recurse: bool = true) {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null)
- {
- if (recurse && this._member.type == Phaser.Types.GROUP)
- {
- this._member.callAll(functionName, recurse);
- }
- else
- {
- this._member[functionName]();
- }
- }
- }
- }
-
- /**
- * @param {function} callback
- * @param {bool} recursive
- */
- public forEach(callback, recursive: bool = false) {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null)
- {
- if (recursive && this._member.type == Phaser.Types.GROUP)
- {
- this._member.forEach(callback, true);
- }
- else
- {
- callback.call(this, this._member);
- }
- }
- }
-
- }
-
- /**
- * @param {any} context
- * @param {function} callback
- * @param {bool} recursive
- */
- public forEachAlive(context, callback, recursive: bool = false) {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null && this._member.alive)
- {
- if (recursive && this._member.type == Phaser.Types.GROUP)
- {
- this._member.forEachAlive(context, callback, true);
- }
- else
- {
- callback.call(context, this._member);
- }
- }
- }
-
- }
-
- /**
- * Call this function to retrieve the first object with exists == false in the group.
- * This is handy for recycling in general, e.g. respawning enemies.
- *
- * @param {any} [ObjectClass] An optional parameter that lets you narrow the results to instances of this particular class.
- *
- * @return {any} A Basic currently flagged as not existing.
- */
- public getFirstAvailable(objectClass = null): any {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if ((this._member != null) && !this._member.exists && ((objectClass == null) || (typeof this._member === objectClass)))
- {
- return this._member;
- }
-
- }
-
- return null;
- }
-
- /**
- * Call this function to retrieve the first index set to 'null'.
- * Returns -1 if no index stores a null object.
- *
- * @return {number} An int indicating the first null slot in the group.
- */
- public getFirstNull(): number {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- if (this.members[this._i] == null)
- {
- return this._i;
- }
- else
- {
- this._i++;
- }
- }
-
- return -1;
-
- }
-
- /**
- * Call this function to retrieve the first object with exists == true in the group.
- * This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
- *
- * @return {Basic} A Basic currently flagged as existing.
- */
- public getFirstExtant(): any {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null && this._member.exists)
- {
- return this._member;
- }
- }
-
- return null;
-
- }
-
- /**
- * Call this function to retrieve the first object with dead == false in the group.
- * This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
- *
- * @return {Basic} A Basic currently flagged as not dead.
- */
- public getFirstAlive(): any {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if ((this._member != null) && this._member.exists && this._member.alive)
- {
- return this._member;
- }
- }
-
- return null;
-
- }
-
- /**
- * Call this function to retrieve the first object with dead == true in the group.
- * This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
- *
- * @return {Basic} A Basic currently flagged as dead.
- */
- public getFirstDead(): any {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if ((this._member != null) && !this._member.alive)
- {
- return this._member;
- }
- }
-
- return null;
-
- }
-
- /**
- * Call this function to find out how many members of the group are not dead.
- *
- * @return {number} The number of Basics flagged as not dead. Returns -1 if group is empty.
- */
- public countLiving(): number {
-
- this._count = -1;
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null)
- {
- if (this._count < 0)
- {
- this._count = 0;
- }
-
- if (this._member.exists && this._member.alive)
- {
- this._count++;
- }
- }
- }
-
- return this._count;
-
- }
-
- /**
- * Call this function to find out how many members of the group are dead.
- *
- * @return {number} The number of Basics flagged as dead. Returns -1 if group is empty.
- */
- public countDead(): number {
-
- this._count = -1;
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if (this._member != null)
- {
- if (this._count < 0)
- {
- this._count = 0;
- }
-
- if (!this._member.alive)
- {
- this._count++;
- }
- }
- }
-
- return this._count;
-
- }
-
- /**
- * Returns a member at random from the group.
- *
- * @param {number} StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
- * @param {number} Length Optional restriction on the number of values you want to randomly select from.
- *
- * @return {Basic} A Basic from the members list.
- */
- public getRandom(startIndex: number = 0, length: number = 0): any {
-
- if (length == 0)
- {
- length = this.length;
- }
-
- return this.game.math.getRandom(this.members, startIndex, length);
-
- }
-
- /**
- * Remove all instances of Basic subclass (Basic, Block, etc) from the list.
- * WARNING: does not destroy() or kill() any of these objects!
- */
- public clear() {
- this.length = this.members.length = 0;
- }
-
- /**
- * Calls kill on the group's members and then on the group itself.
- */
- public kill() {
-
- this._i = 0;
-
- while (this._i < this.length)
- {
- this._member = this.members[this._i++];
-
- if ((this._member != null) && this._member.exists)
- {
- this._member.kill();
- }
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/core/Plugin.ts b/wip/TS Source/core/Plugin.ts
deleted file mode 100644
index 5640ad97..00000000
--- a/wip/TS Source/core/Plugin.ts
+++ /dev/null
@@ -1,117 +0,0 @@
-///
-
-/**
-* Phaser - Plugin
-*/
-
-module Phaser {
-
- export class Plugin {
-
- constructor(game: Phaser.Game, parent) {
-
- this.game = game;
- this.parent = parent;
-
- this.active = false;
- this.visible = false;
-
- this.hasPreUpdate = false;
- this.hasUpdate = false;
- this.hasPostUpdate = false;
-
- this.hasPreRender = false;
- this.hasRender = false;
- this.hasPostRender = false;
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * The object that owns this Plugin (i.e. Camera, Game, Stage, etc).
- */
- public parent;
-
- /**
- * Controls whether preUpdate, update or postUpdate are called
- */
- public active: bool;
-
- /**
- * Controls whether preRender, render or postRender are called
- */
- public visible: bool;
-
- /**
- * Quick access bools to avoid having to do a function existence check during tight inner loops
- */
- public hasPreUpdate: bool;
- public hasUpdate: bool;
- public hasPostUpdate: bool;
-
- public hasPreRender: bool;
- public hasRender: bool;
- public hasPostRender: bool;
-
- /**
- * Pre-update is called at the start of the update cycle, before any other updates have taken place.
- * It is only called if active is set to true.
- */
- public preUpdate() {
- }
-
- /**
- * Pre-update is called at the start of the update cycle, before any other updates have taken place.
- * It is only called if active is set to true.
- */
- public update() {
- }
-
- /**
- * Post-update is called at the end of the objects update cycle, after other update logic has taken place.
- * It is only called if active is set to true.
- */
- public postUpdate() {
- }
-
- /**
- * Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
- * It is only called if visible is set to true.
- */
- public preRender() {
- }
-
- /**
- * Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
- * It is only called if visible is set to true.
- */
- public render() {
- }
-
- /**
- * Post-render is called after every camera and game object has been rendered, also after any custom postRender callbacks have been run.
- * It is only called if visible is set to true.
- */
- public postRender() {
- }
-
- /**
- * Clear down this Plugin and null out references
- */
- public destroy() {
-
- this.game = null;
- this.parent = null;
-
- this.active = false;
- this.visible = false;
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/core/PluginManager.ts b/wip/TS Source/core/PluginManager.ts
deleted file mode 100644
index d0bb985d..00000000
--- a/wip/TS Source/core/PluginManager.ts
+++ /dev/null
@@ -1,221 +0,0 @@
-///
-
-/**
-* Phaser - PluginManager
-*/
-
-module Phaser {
-
- export class PluginManager {
-
- constructor(game:Game, parent) {
-
- this.game = game;
-
- this._parent = parent;
-
- this.plugins = [];
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * The object that owns this PluginManager.
- */
- private _parent;
-
- /**
- * Plugin loop pointer
- * @type {number}
- */
- private _p: number;
-
- /**
- * Plugins array counter
- * @type {number}
- */
- private _pluginsLength: number;
-
- /**
- * An Array of Plugins
- * @type {Array}
- */
- public plugins: Phaser.Plugin[];
-
- /**
- * Add a new Plugin to the PluginManager.
- * The plugins game and parent reference are set to this game and pluginmanager parent.
- * @type {Phaser.Plugin}
- */
- public add(plugin):any {
-
- var result: bool = false;
-
- // Prototype?
- if (typeof plugin === 'function')
- {
- plugin = new plugin(this.game, this._parent);
- }
- else
- {
- plugin.game = this.game;
- plugin.parent = this._parent;
- }
-
- // Check for methods now to avoid having to do this every loop
-
- if (typeof plugin['preUpdate'] === 'function')
- {
- plugin.hasPreUpdate = true;
- result = true;
- }
-
- if (typeof plugin['update'] === 'function')
- {
- plugin.hasUpdate = true;
- result = true;
- }
-
- if (typeof plugin['postUpdate'] === 'function')
- {
- plugin.hasPostUpdate = true;
- result = true;
- }
-
- if (typeof plugin['preRender'] === 'function')
- {
- plugin.hasPreRender = true;
- result = true;
- }
-
- if (typeof plugin['render'] === 'function')
- {
- plugin.hasRender = true;
- result = true;
- }
-
- if (typeof plugin['postRender'] === 'function')
- {
- plugin.hasPostRender = true;
- result = true;
- }
-
- // The plugin must have at least one of the above functions to be added to the PluginManager.
- if (result == true)
- {
- if (plugin.hasPreUpdate || plugin.hasUpdate || plugin.hasPostUpdate)
- {
- plugin.active = true;
- }
-
- if (plugin.hasPreRender || plugin.hasRender || plugin.hasPostRender)
- {
- plugin.visible = true;
- }
-
- this._pluginsLength = this.plugins.push(plugin);
-
- return plugin;
- }
- else
- {
- return null;
- }
-
- }
-
- public remove(plugin) {
-
- // TODO :)
- this._pluginsLength--;
-
- }
-
- public preUpdate() {
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].active && this.plugins[this._p].hasPreUpdate)
- {
- this.plugins[this._p].preUpdate();
- }
- }
-
- }
-
- public update() {
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].active && this.plugins[this._p].hasUpdate)
- {
- this.plugins[this._p].update();
- }
- }
-
- }
-
- public postUpdate() {
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].active && this.plugins[this._p].hasPostUpdate)
- {
- this.plugins[this._p].postUpdate();
- }
- }
-
- }
-
- public preRender() {
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].visible && this.plugins[this._p].hasPreRender)
- {
- this.plugins[this._p].preRender();
- }
- }
-
- }
-
- public render() {
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].visible && this.plugins[this._p].hasRender)
- {
- this.plugins[this._p].render();
- }
- }
-
- }
-
- public postRender() {
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].visible && this.plugins[this._p].hasPostRender)
- {
- this.plugins[this._p].postRender();
- }
- }
-
- }
-
- public destroy() {
-
- this.plugins.length = 0;
- this._pluginsLength = 0;
- this.game = null;
- this._parent = null;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/core/Signal.ts b/wip/TS Source/core/Signal.ts
deleted file mode 100644
index 15fea4b8..00000000
--- a/wip/TS Source/core/Signal.ts
+++ /dev/null
@@ -1,330 +0,0 @@
-///
-
-/**
-* Phaser - Signal
-*
-* A Signal is used for object communication via a custom broadcaster instead of Events.
-* Based on JS Signals by Miller Medeiros. Converted by TypeScript by Richard Davey.
-* Released under the MIT license
-* http://millermedeiros.github.com/js-signals/
-*/
-
-module Phaser {
-
- export class Signal {
-
- /**
- *
- * @property _bindings
- * @type Array
- * @private
- */
- private _bindings: SignalBinding[] = [];
-
- /**
- *
- * @property _prevParams
- * @type Any
- * @private
- */
- private _prevParams = null;
-
- /**
- * Signals Version Number
- * @property VERSION
- * @type String
- * @const
- */
- public static VERSION: string = '1.0.0';
-
- /**
- * If Signal should keep record of previously dispatched parameters and
- * automatically execute listener during `add()`/`addOnce()` if Signal was
- * already dispatched before.
- * @type bool
- */
- public memorize: bool = false;
-
- /**
- * @type bool
- * @private
- */
- private _shouldPropagate: bool = true;
-
- /**
- * If Signal is active and should broadcast events.
- *
IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.
- * @type bool
- */
- public active: bool = true;
-
- /**
- *
- * @method validateListener
- * @param {Any} listener
- * @param {Any} fnName
- */
- public validateListener(listener, fnName) {
-
- if (typeof listener !== 'function')
- {
- throw new Error('listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName));
- }
-
- }
-
- /**
- * @param {Function} listener
- * @param {bool} isOnce
- * @param {Object} [listenerContext]
- * @param {Number} [priority]
- * @return {SignalBinding}
- * @private
- */
- private _registerListener(listener, isOnce: bool, listenerContext, priority: number): SignalBinding {
-
- var prevIndex: number = this._indexOfListener(listener, listenerContext);
- var binding: SignalBinding;
-
- if (prevIndex !== -1)
- {
- binding = this._bindings[prevIndex];
-
- if (binding.isOnce() !== isOnce)
- {
- throw new Error('You cannot add' + (isOnce ? '' : 'Once') + '() then add' + (!isOnce ? '' : 'Once') + '() the same listener without removing the relationship first.');
- }
- }
- else
- {
- binding = new SignalBinding(this, listener, isOnce, listenerContext, priority);
-
- this._addBinding(binding);
- }
-
- if (this.memorize && this._prevParams)
- {
- binding.execute(this._prevParams);
- }
-
- return binding;
-
- }
-
- /**
- *
- * @method _addBinding
- * @param {SignalBinding} binding
- * @private
- */
- private _addBinding(binding: SignalBinding) {
-
- //simplified insertion sort
-
- var n: number = this._bindings.length;
-
- do { --n; } while (this._bindings[n] && binding.priority <= this._bindings[n].priority);
-
- this._bindings.splice(n + 1, 0, binding);
-
- }
-
- /**
- *
- * @method _indexOfListener
- * @param {Function} listener
- * @return {number}
- * @private
- */
- private _indexOfListener(listener, context): number {
-
- var n: number = this._bindings.length;
- var cur: SignalBinding;
-
- while (n--)
- {
- cur = this._bindings[n];
-
- if (cur.getListener() === listener && cur.context === context)
- {
- return n;
- }
- }
-
- return -1;
-
- }
-
- /**
- * Check if listener was attached to Signal.
- * @param {Function} listener
- * @param {Object} [context]
- * @return {bool} if Signal has the specified listener.
- */
- public has(listener, context: any = null): bool {
-
- return this._indexOfListener(listener, context) !== -1;
-
- }
-
- /**
- * Add a listener to the signal.
- * @param {Function} listener Signal handler function.
- * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
- * @return {SignalBinding} An Object representing the binding between the Signal and listener.
- */
- public add(listener, listenerContext: any = null, priority: number = 0): SignalBinding {
-
- this.validateListener(listener, 'add');
-
- return this._registerListener(listener, false, listenerContext, priority);
-
- }
-
- /**
- * Add listener to the signal that should be removed after first execution (will be executed only once).
- * @param {Function} listener Signal handler function.
- * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
- * @return {SignalBinding} An Object representing the binding between the Signal and listener.
- */
- public addOnce(listener, listenerContext: any = null, priority: number = 0): SignalBinding {
-
- this.validateListener(listener, 'addOnce');
-
- return this._registerListener(listener, true, listenerContext, priority);
-
- }
-
- /**
- * Remove a single listener from the dispatch queue.
- * @param {Function} listener Handler function that should be removed.
- * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
- * @return {Function} Listener handler function.
- */
- public remove(listener, context: any = null) {
-
- this.validateListener(listener, 'remove');
-
- var i: number = this._indexOfListener(listener, context);
-
- if (i !== -1)
- {
- this._bindings[i]._destroy();
- this._bindings.splice(i, 1);
- }
-
- return listener;
-
- }
-
- /**
- * Remove all listeners from the Signal.
- */
- public removeAll() {
-
- if (this._bindings)
- {
- var n: number = this._bindings.length;
-
- while (n--)
- {
- this._bindings[n]._destroy();
- }
-
- this._bindings.length = 0;
- }
-
- }
-
- /**
- * @return {number} Number of listeners attached to the Signal.
- */
- public getNumListeners(): number {
-
- return this._bindings.length;
-
- }
-
- /**
- * Stop propagation of the event, blocking the dispatch to next listeners on the queue.
- *
IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.
- * @see Signal.prototype.disable
- */
- public halt() {
-
- this._shouldPropagate = false;
-
- }
-
- /**
- * Dispatch/Broadcast Signal to all listeners added to the queue.
- * @param {...*} [params] Parameters that should be passed to each handler.
- */
- public dispatch(...paramsArr: any[]) {
-
- if (!this.active)
- {
- return;
- }
-
- var n: number = this._bindings.length;
- var bindings: SignalBinding[];
-
- if (this.memorize)
- {
- this._prevParams = paramsArr;
- }
-
- if (!n)
- {
- //should come after memorize
- return;
- }
-
- bindings = this._bindings.slice(0); //clone array in case add/remove items during dispatch
-
- this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch.
-
- //execute all callbacks until end of the list or until a callback returns `false` or stops propagation
- //reverse loop since listeners with higher priority will be added at the end of the list
- do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
-
- }
-
- /**
- * Forget memorized arguments.
- * @see Signal.memorize
- */
- public forget() {
-
- this._prevParams = null;
-
- }
-
- /**
- * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).
- *
IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.
- */
- public dispose() {
-
- this.removeAll();
-
- delete this._bindings;
- delete this._prevParams;
-
- }
-
- /**
- * @return {string} String representation of the object.
- */
- public toString(): string {
-
- return '[Signal active:' + this.active + ' numListeners:' + this.getNumListeners() + ']';
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/core/SignalBinding.ts b/wip/TS Source/core/SignalBinding.ts
deleted file mode 100644
index df4f54d2..00000000
--- a/wip/TS Source/core/SignalBinding.ts
+++ /dev/null
@@ -1,184 +0,0 @@
-///
-
-/**
-* Phaser - SignalBinding
-*
-* An object that represents a binding between a Signal and a listener function.
-* Based on JS Signals by Miller Medeiros. Converted by TypeScript by Richard Davey.
-* Released under the MIT license
-* http://millermedeiros.github.com/js-signals/
-*/
-
-module Phaser {
-
- export class SignalBinding {
-
- /**
- * Object that represents a binding between a Signal and a listener function.
- * - This is an internal constructor and shouldn't be called by regular users.
- * - inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.
- * @author Miller Medeiros
- * @constructor
- * @internal
- * @name SignalBinding
- * @param {Signal} signal Reference to Signal object that listener is currently bound to.
- * @param {Function} listener Handler function bound to the signal.
- * @param {bool} isOnce If binding should be executed just once.
- * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @param {Number} [priority] The priority level of the event listener. (default = 0).
- */
- constructor(signal: Signal, listener, isOnce: bool, listenerContext, priority: number = 0) {
-
- this._listener = listener;
- this._isOnce = isOnce;
- this.context = listenerContext;
- this._signal = signal;
- this.priority = priority || 0;
-
- }
-
- /**
- * Handler function bound to the signal.
- * @type Function
- * @private
- */
- private _listener;
-
- /**
- * If binding should be executed just once.
- * @type bool
- * @private
- */
- private _isOnce: bool;
-
- /**
- * Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @memberOf SignalBinding.prototype
- * @name context
- * @type Object|undefined|null
- */
- public context;
-
- /**
- * Reference to Signal object that listener is currently bound to.
- * @type Signal
- * @private
- */
- private _signal: Signal;
-
- /**
- * Listener priority
- * @type Number
- */
- public priority: number;
-
- /**
- * If binding is active and should be executed.
- * @type bool
- */
- public active: bool = true;
-
- /**
- * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)
- * @type Array|null
- */
- public params = null;
-
- /**
- * Call listener passing arbitrary parameters.
- *
If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.
- * @param {Array} [paramsArr] Array of parameters that should be passed to the listener
- * @return {*} Value returned by the listener.
- */
- public execute(paramsArr: any[]) {
-
- var handlerReturn;
- var params;
-
- if (this.active && !!this._listener)
- {
- params = this.params ? this.params.concat(paramsArr) : paramsArr;
-
- handlerReturn = this._listener.apply(this.context, params);
-
- if (this._isOnce)
- {
- this.detach();
- }
- }
-
- return handlerReturn;
-
- }
-
- /**
- * Detach binding from signal.
- * - alias to: mySignal.remove(myBinding.getListener());
- * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
- */
- public detach() {
-
- return this.isBound() ? this._signal.remove(this._listener, this.context) : null;
-
- }
-
- /**
- * @return {bool} `true` if binding is still bound to the signal and have a listener.
- */
- public isBound(): bool {
-
- return (!!this._signal && !!this._listener);
-
- }
-
- /**
- * @return {bool} If SignalBinding will only be executed once.
- */
- public isOnce(): bool {
-
- return this._isOnce;
-
- }
-
- /**
- * @return {Function} Handler function bound to the signal.
- */
- public getListener() {
-
- return this._listener;
-
- }
-
- /**
- * @return {Signal} Signal that listener is currently bound to.
- */
- public getSignal() {
-
- return this._signal;
-
- }
-
- /**
- * Delete instance properties
- * @private
- */
- public _destroy() {
-
- delete this._signal;
- delete this._listener;
- delete this.context;
-
- }
-
- /**
- * @return {string} String representation of the object.
- */
- public toString(): string {
-
- return '[SignalBinding isOnce:' + this._isOnce + ', isBound:' + this.isBound() + ', active:' + this.active + ']';
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/display/CSS3Filters.ts b/wip/TS Source/display/CSS3Filters.ts
deleted file mode 100644
index 70d02e85..00000000
--- a/wip/TS Source/display/CSS3Filters.ts
+++ /dev/null
@@ -1,170 +0,0 @@
-///
-
-/**
-* Phaser - Display - CSS3Filters
-*
-* Allows for easy addition and modification of CSS3 Filters on DOM objects (typically the Game.Stage.canvas).
-*/
-
-module Phaser.Display {
-
- export class CSS3Filters {
-
- /**
- * Creates a new CSS3 Filter component
- * @param parent The DOM object to apply the filters to.
- */
- constructor(parent) {
- this.parent = parent;
- }
-
- /**
- * Reference to the parent DOM object (stage.canvas for example)
- */
- public parent;
-
- private _blur: number = 0;
- private _grayscale: number = 0;
- private _sepia: number = 0;
- private _brightness: number = 0;
- private _contrast: number = 0;
- private _hueRotate: number = 0;
- private _invert: number = 0;
- private _opacity: number = 0;
- private _saturate: number = 0;
-
- private setFilter(local: string, prefix: string, value: number, unit: string) {
-
- this[local] = value;
-
- if (this.parent)
- {
- this.parent.style['-webkit-filter'] = prefix + '(' + value + unit + ')';
- }
-
- }
-
- /**
- * Applies a Gaussian blur to the DOM element. The value of 'radius' defines the value of the standard deviation to the Gaussian function,
- * or how many pixels on the screen blend into each other, so a larger value will create more blur.
- * If no parameter is provided, then a value 0 is used. The parameter is specified as a CSS length, but does not accept percentage values.
- */
- public set blur(radius: number) {
- this.setFilter('_blur', 'blur', radius, 'px');
- }
-
- public get blur(): number {
- return this._blur;
- }
-
- /**
- * Converts the input image to grayscale. The value of 'amount' defines the proportion of the conversion.
- * A value of 100% is completely grayscale. A value of 0% leaves the input unchanged.
- * Values between 0% and 100% are linear multipliers on the effect. If the 'amount' parameter is missing, a value of 100% is used.
- */
- public set grayscale(amount: number) {
- this.setFilter('_grayscale', 'grayscale', amount, '%');
- }
-
- public get grayscale(): number {
- return this._grayscale;
- }
-
- /**
- * Converts the input image to sepia. The value of 'amount' defines the proportion of the conversion.
- * A value of 100% is completely sepia. A value of 0 leaves the input unchanged.
- * Values between 0% and 100% are linear multipliers on the effect. If the 'amount' parameter is missing, a value of 100% is used.
- */
- public set sepia(amount: number) {
- this.setFilter('_sepia', 'sepia', amount, '%');
- }
-
- public get sepia(): number {
- return this._sepia;
- }
-
- /**
- * Applies a linear multiplier to input image, making it appear more or less bright.
- * A value of 0% will create an image that is completely black. A value of 100% leaves the input unchanged.
- * Other values are linear multipliers on the effect. Values of an amount over 100% are allowed, providing brighter results.
- * If the 'amount' parameter is missing, a value of 100% is used.
- */
- public set brightness(amount: number) {
- this.setFilter('_brightness', 'brightness', amount, '%');
- }
-
- public get brightness(): number {
- return this._brightness;
- }
-
- /**
- * Adjusts the contrast of the input. A value of 0% will create an image that is completely black.
- * A value of 100% leaves the input unchanged. Values of amount over 100% are allowed, providing results with less contrast.
- * If the 'amount' parameter is missing, a value of 100% is used.
- */
- public set contrast(amount: number) {
- this.setFilter('_contrast', 'contrast', amount, '%');
- }
-
- public get contrast(): number {
- return this._contrast;
- }
-
- /**
- * Applies a hue rotation on the input image. The value of 'angle' defines the number of degrees around the color circle
- * the input samples will be adjusted. A value of 0deg leaves the input unchanged. If the 'angle' parameter is missing,
- * a value of 0deg is used. Maximum value is 360deg.
- */
- public set hueRotate(angle: number) {
- this.setFilter('_hueRotate', 'hue-rotate', angle, 'deg');
- }
-
- public get hueRotate(): number {
- return this._hueRotate;
- }
-
- /**
- * Inverts the samples in the input image. The value of 'amount' defines the proportion of the conversion.
- * A value of 100% is completely inverted. A value of 0% leaves the input unchanged.
- * Values between 0% and 100% are linear multipliers on the effect. If the 'amount' parameter is missing, a value of 100% is used.
- */
- public set invert(value: number) {
- this.setFilter('_invert', 'invert', value, '%');
- }
-
- public get invert(): number {
- return this._invert;
- }
-
- /**
- * Applies transparency to the samples in the input image. The value of 'amount' defines the proportion of the conversion.
- * A value of 0% is completely transparent. A value of 100% leaves the input unchanged.
- * Values between 0% and 100% are linear multipliers on the effect. This is equivalent to multiplying the input image samples by amount.
- * If the 'amount' parameter is missing, a value of 100% is used.
- * This function is similar to the more established opacity property; the difference is that with filters, some browsers provide hardware acceleration for better performance.
- */
- public set opacity(value: number) {
- this.setFilter('_opacity', 'opacity', value, '%');
- }
-
- public get opacity(): number {
- return this._opacity;
- }
-
- /**
- * Saturates the input image. The value of 'amount' defines the proportion of the conversion.
- * A value of 0% is completely un-saturated. A value of 100% leaves the input unchanged.
- * Other values are linear multipliers on the effect. Values of amount over 100% are allowed, providing super-saturated results.
- * If the 'amount' parameter is missing, a value of 100% is used.
- */
- public set saturate(value: number) {
- this.setFilter('_saturate', 'saturate', value, '%');
- }
-
- public get saturate(): number {
- return this._saturate;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/display/DynamicTexture.ts b/wip/TS Source/display/DynamicTexture.ts
deleted file mode 100644
index 6f10a0aa..00000000
--- a/wip/TS Source/display/DynamicTexture.ts
+++ /dev/null
@@ -1,331 +0,0 @@
-///
-
-/**
-* Phaser - Display - DynamicTexture
-*
-* A DynamicTexture can be thought of as a mini canvas into which you can draw anything.
-* Game Objects can be assigned a DynamicTexture, so when they render in the world they do so
-* based on the contents of the texture at the time. This allows you to create powerful effects
-* once and have them replicated across as many game objects as you like.
-*/
-
-module Phaser.Display {
-
- export class DynamicTexture {
-
- /**
- * DynamicTexture constructor
- * Create a new DynamicTexture.
- *
- * @param game {Phaser.Game} Current game instance.
- * @param width {number} Init width of this texture.
- * @param height {number} Init height of this texture.
- */
- constructor(game: Game, width: number, height: number) {
-
- this.game = game;
- this.type = Phaser.Types.DYNAMICTEXTURE;
-
- this.canvas = document.createElement('canvas');
- this.canvas.width = width;
- this.canvas.height = height;
- this.context = this.canvas.getContext('2d');
-
- this.css3 = new Phaser.Display.CSS3Filters(this.canvas);
-
- this.bounds = new Rectangle(0, 0, width, height);
-
- }
-
- /**
- * Reference to game.
- */
- public game: Phaser.Game;
-
- /**
- * The type of game object.
- */
- public type: number;
-
- private _sx: number = 0;
- private _sy: number = 0;
- private _sw: number = 0;
- private _sh: number = 0;
- private _dx: number = 0;
- private _dy: number = 0;
- private _dw: number = 0;
- private _dh: number = 0;
-
- // Input / Output nodes?
-
- /**
- * Controls the CSS3 Filters applied to the textures canvas object.
- * Only really useful if you attach this canvas to the DOM.
- * @type {Phaser.Components.CSS3Filters}
- */
- public css3: Phaser.Display.CSS3Filters;
-
- /**
- * Bound of this texture with width and height info.
- * @type {Rectangle}
- */
- public bounds: Phaser.Rectangle;
-
- /**
- * This class is actually a wrapper of canvas.
- * @type {HTMLCanvasElement}
- */
- public canvas: HTMLCanvasElement;
-
- /**
- * Canvas context of this object.
- * @type {CanvasRenderingContext2D}
- */
- public context: CanvasRenderingContext2D;
-
- /**
- * You can set a globalCompositeOperation that will be applied before the render method is called on this Sprite.
- * This is useful if you wish to apply an effect like 'lighten'.
- * If this value is set it will call a canvas context save and restore before and after the render pass, so use it sparingly.
- * Set to null to disable.
- */
- public globalCompositeOperation: string = null;
-
- /**
- * Get a color of a specific pixel.
- * @param x {number} X position of the pixel in this texture.
- * @param y {number} Y position of the pixel in this texture.
- * @return {number} A native color value integer (format: 0xRRGGBB)
- */
- public getPixel(x: number, y: number): number {
-
- //r = imageData.data[0];
- //g = imageData.data[1];
- //b = imageData.data[2];
- //a = imageData.data[3];
- var imageData = this.context.getImageData(x, y, 1, 1);
-
- return Phaser.ColorUtils.getColor(imageData.data[0], imageData.data[1], imageData.data[2]);
-
- }
-
- /**
- * Get a color of a specific pixel (including alpha value).
- * @param x {number} X position of the pixel in this texture.
- * @param y {number} Y position of the pixel in this texture.
- * @return A native color value integer (format: 0xAARRGGBB)
- */
- public getPixel32(x: number, y: number) {
-
- var imageData = this.context.getImageData(x, y, 1, 1);
-
- return Phaser.ColorUtils.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]);
-
- }
-
- /**
- * Get pixels in array in a specific Rectangle.
- * @param rect {Rectangle} The specific Rectangle.
- * @returns {array} CanvasPixelArray.
- */
- public getPixels(rect: Phaser.Rectangle) {
-
- return this.context.getImageData(rect.x, rect.y, rect.width, rect.height);
-
- }
-
- /**
- * Set color of a specific pixel.
- * @param x {number} X position of the target pixel.
- * @param y {number} Y position of the target pixel.
- * @param color {number} Native integer with color value. (format: 0xRRGGBB)
- */
- public setPixel(x: number, y: number, color: string) {
-
- this.context.fillStyle = color;
- this.context.fillRect(x, y, 1, 1);
-
- }
-
- /**
- * Set color (with alpha) of a specific pixel.
- * @param x {number} X position of the target pixel.
- * @param y {number} Y position of the target pixel.
- * @param color {number} Native integer with color value. (format: 0xAARRGGBB)
- */
- public setPixel32(x: number, y: number, color: number) {
-
- this.context.fillStyle = color;
- this.context.fillRect(x, y, 1, 1);
-
- }
-
- /**
- * Set image data to a specific Rectangle.
- * @param rect {Rectangle} Target Rectangle.
- * @param input {object} Source image data.
- */
- public setPixels(rect: Phaser.Rectangle, input) {
-
- this.context.putImageData(input, rect.x, rect.y);
-
- }
-
- /**
- * Fill a given Rectangle with specific color.
- * @param rect {Rectangle} Target Rectangle you want to fill.
- * @param color {number} A native number with color value. (format: 0xRRGGBB)
- */
- public fillRect(rect: Phaser.Rectangle, color: number) {
-
- this.context.fillStyle = color;
- this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
-
- }
-
- /**
- *
- */
- public pasteImage(key: string, frame: number = -1, destX: number = 0, destY: number = 0, destWidth: number = null, destHeight: number = null) {
-
- var texture = null;
- var frameData;
-
- this._sx = 0;
- this._sy = 0;
- this._dx = destX;
- this._dy = destY;
-
- // TODO - Load a frame from a sprite sheet, otherwise we'll draw the whole lot
- if (frame > -1)
- {
- //if (this.game.cache.isSpriteSheet(key))
- //{
- // texture = this.game.cache.getImage(key);
- //this.animations.loadFrameData(this.game.cache.getFrameData(key));
- //}
- }
- else
- {
- texture = this.game.cache.getImage(key);
- this._sw = texture.width;
- this._sh = texture.height;
- this._dw = texture.width;
- this._dh = texture.height;
- }
-
- if (destWidth !== null)
- {
- this._dw = destWidth;
- }
-
- if (destHeight !== null)
- {
- this._dh = destHeight;
- }
-
- if (texture != null)
- {
- this.context.drawImage(
- texture, // Source Image
- this._sx, // Source X (location within the source image)
- this._sy, // Source Y
- this._sw, // Source Width
- this._sh, // Source Height
- this._dx, // Destination X (where on the canvas it'll be drawn)
- this._dy, // Destination Y
- this._dw, // Destination Width (always same as Source Width unless scaled)
- this._dh // Destination Height (always same as Source Height unless scaled)
- );
- }
-
- }
-
- // TODO - Add in support for: alphaBitmapData: BitmapData = null, alphaPoint: Point = null, mergeAlpha: bool = false
- /**
- * Copy pixel from another DynamicTexture to this texture.
- * @param sourceTexture {DynamicTexture} Source texture object.
- * @param sourceRect {Rectangle} The specific region Rectangle to be copied to this in the source.
- * @param destPoint {Point} Top-left point the target image data will be paste at.
- */
- public copyPixels(sourceTexture: Phaser.Display.DynamicTexture, sourceRect: Phaser.Rectangle, destPoint: Phaser.Point) {
-
- // Swap for drawImage if the sourceRect is the same size as the sourceTexture to avoid a costly getImageData call
- if (Phaser.RectangleUtils.equals(sourceRect, this.bounds) == true)
- {
- this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y);
- }
- else
- {
- this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y);
- }
-
- }
-
- public add(sprite: Phaser.Sprite) {
-
- sprite.texture.canvas = this.canvas;
- sprite.texture.context = this.context;
-
- }
-
- /**
- * Given an array of Sprites it will update each of them so that their canvas/contexts reference this DynamicTexture
- * @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
- */
- public assignCanvasToGameObjects(objects) {
-
- for (var i = 0; i < objects.length; i++)
- {
- if (objects[i].texture)
- {
- objects[i].texture.canvas = this.canvas;
- objects[i].texture.context = this.context;
- }
- }
-
- }
-
- /**
- * Clear the whole canvas.
- */
- public clear() {
-
- this.context.clearRect(0, 0, this.bounds.width, this.bounds.height);
-
- }
-
- /**
- * Renders this DynamicTexture to the Stage at the given x/y coordinates
- *
- * @param x {number} The X coordinate to render on the stage to (given in screen coordinates, not world)
- * @param y {number} The Y coordinate to render on the stage to (given in screen coordinates, not world)
- */
- public render(x: number = 0, y: number = 0) {
-
- if (this.globalCompositeOperation)
- {
- this.game.stage.context.save();
- this.game.stage.context.globalCompositeOperation = this.globalCompositeOperation;
- }
-
- this.game.stage.context.drawImage(this.canvas, x, y);
-
- if (this.globalCompositeOperation)
- {
- this.game.stage.context.restore();
- }
-
- }
-
- public get width(): number {
- return this.bounds.width;
- }
-
- public get height(): number {
- return this.bounds.height;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/display/Texture.ts b/wip/TS Source/display/Texture.ts
deleted file mode 100644
index 144ff1d6..00000000
--- a/wip/TS Source/display/Texture.ts
+++ /dev/null
@@ -1,343 +0,0 @@
-///
-
-/**
-* Phaser - Display - Texture
-*
-* The Texture being used to render the object (Sprite, Group background, etc). Either Image based on a DynamicTexture.
-*/
-
-module Phaser.Display {
-
- export class Texture {
-
- /**
- * Creates a new Texture component
- * @param parent The object using this Texture to render.
- * @param key An optional Game.Cache key to load an image from
- */
- constructor(parent) {
-
- this.game = parent.game;
- this.parent = parent;
-
- this.canvas = parent.game.stage.canvas;
- this.context = parent.game.stage.context;
- this.alpha = 1;
- this.flippedX = false;
- this.flippedY = false;
-
- this._width = 16;
- this._height = 16;
-
- this.cameraBlacklist = [];
- this._blacklist = 0;
-
- }
-
- /**
- * Camera Blacklist length
- */
- private _blacklist: number;
-
- /**
- * Private _width - use the width getter/setter instead
- */
- private _width: number;
-
- /**
- * Private _height - use the height getter/setter instead
- */
- private _height: number;
-
- /**
- * Reference to Phaser.Game
- */
- public game: Phaser.Game;
-
- /**
- * Reference to the parent object (Sprite, Group, etc)
- */
- public parent;
-
- /**
- * Reference to the Image stored in the Game.Cache that is used as the texture for the Sprite.
- */
- public imageTexture = null;
-
- /**
- * Reference to the DynamicTexture that is used as the texture for the Sprite.
- * @type {DynamicTexture}
- */
- public dynamicTexture: Phaser.Display.DynamicTexture = null;
-
- /**
- * The load status of the texture image.
- * @type {bool}
- */
- public loaded: bool = false;
-
- /**
- * An Array of Cameras to which this texture won't render
- * @type {Array}
- */
- public cameraBlacklist: number[];
-
- /**
- * Whether the texture background is opaque or not. If set to true the object is filled with
- * the value of Texture.backgroundColor every frame. Normally you wouldn't enable this but
- * for some effects it can be handy.
- * @type {bool}
- */
- public opaque: bool = false;
-
- /**
- * Opacity of the Sprite texture where 1 is opaque (default) and 0 is fully transparent.
- * @type {number}
- */
- public alpha: number;
-
- /**
- * The Background Color of the Sprite if Texture.opaque is set to true.
- * Given in css color string format, i.e. 'rgb(0,0,0)' or '#ff0000'.
- * @type {string}
- */
- public backgroundColor: string = 'rgb(255,255,255)';
-
- /**
- * You can set a globalCompositeOperation that will be applied before the render method is called on this Sprite.
- * This is useful if you wish to apply an effect like 'lighten'.
- * If this value is set it will call a canvas context save and restore before and after the render pass, so use it sparingly.
- * Set to null to disable.
- */
- public globalCompositeOperation: string = null;
-
- /**
- * A reference to the Canvas this Sprite renders to.
- * @type {HTMLCanvasElement}
- */
- public canvas: HTMLCanvasElement;
-
- /**
- * A reference to the Canvas Context2D this Sprite renders to.
- * @type {CanvasRenderingContext2D}
- */
- public context: CanvasRenderingContext2D;
-
- /**
- * The Cache key used for the Image Texture.
- */
- public cacheKey: string;
-
- /**
- * The Texture being used to render the Sprite. Either an Image Texture from the Cache or a DynamicTexture.
- */
- public texture;
-
- /**
- * Controls if the Sprite is rendered rotated or not.
- * If renderRotation is false then the object can still rotate but it will never be rendered rotated.
- * @type {bool}
- */
- public renderRotation: bool = true;
-
- /**
- * The direction the animation frame is facing (can be Phaser.Types.RIGHT, LEFT, UP, DOWN).
- * Very useful when hooking animation to Sprite directions.
- */
- public facing: number;
-
- /**
- * Flip the graphic horizontally (defaults to false)
- * @type {bool}
- */
- public flippedX: bool = false;
-
- /**
- * Flip the graphic vertically (defaults to false)
- * @type {bool}
- */
- public flippedY: bool = false;
-
- /**
- * Is the texture a DynamicTexture?
- * @type {bool}
- */
- public isDynamic: bool = false;
-
- /**
- * The crop rectangle allows you to control which part of the sprite texture is rendered without distorting it.
- * Set to null to disable, set to a Phaser.Rectangle object to control the region that will be rendered, anything outside the rectangle is ignored.
- * @type {Phaser.Rectangle}
- */
- public crop: Phaser.Rectangle;
-
- /**
- * Hides an object from this Camera. Hidden objects are not rendered.
- *
- * @param object {Camera} The camera this object should ignore.
- */
- public hideFromCamera(camera: Phaser.Camera) {
-
- if (this.isHidden(camera) == false)
- {
- this.cameraBlacklist.push(camera.ID);
- this._blacklist++;
- }
-
- }
-
- /**
- * Returns true if this texture is hidden from rendering to the given camera, otherwise false.
- */
- public isHidden(camera: Phaser.Camera): bool {
-
- if (this._blacklist && this.cameraBlacklist.indexOf(camera.ID) !== -1)
- {
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Un-hides an object previously hidden to this Camera.
- * The object must implement a public cameraBlacklist property.
- *
- * @param object {Sprite/Group} The object this camera should display.
- */
- public showToCamera(camera: Phaser.Camera) {
-
- if (this.isHidden(camera))
- {
- this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1);
- this._blacklist--;
- }
-
- }
-
- /**
- * Updates the texture being used to render the Sprite.
- * Called automatically by SpriteUtils.loadTexture and SpriteUtils.loadDynamicTexture.
- */
- public setTo(image = null, dynamic: Phaser.Display.DynamicTexture = null) {
-
- if (dynamic)
- {
- this.isDynamic = true;
- this.dynamicTexture = dynamic;
- this.texture = this.dynamicTexture.canvas;
- }
- else
- {
- this.isDynamic = false;
- this.imageTexture = image;
- this.texture = this.imageTexture;
- this._width = image.width;
- this._height = image.height;
- }
-
- this.loaded = true;
-
- return this.parent;
-
- }
-
- /**
- * Sets a new graphic from the game cache to use as the texture for this Sprite.
- * The graphic can be SpriteSheet or Texture Atlas. If you need to use a DynamicTexture see loadDynamicTexture.
- * @param key {string} Key of the graphic you want to load for this sprite.
- * @param clearAnimations {bool} If this Sprite has a set of animation data already loaded you can choose to keep or clear it with this bool
- * @param updateBody {bool} Update the physics body dimensions to match the newly loaded texture/frame?
- */
- public loadImage(key: string, clearAnimations: bool = true, updateBody: bool = true) {
-
- if (clearAnimations && this.parent['animations'] && this.parent['animations'].frameData !== null)
- {
- this.parent.animations.destroy();
- }
-
- if (this.game.cache.getImage(key) !== null)
- {
- this.setTo(this.game.cache.getImage(key), null);
- this.cacheKey = key;
-
- if (this.game.cache.isSpriteSheet(key) && this.parent['animations'])
- {
- this.parent.animations.loadFrameData(this.parent.game.cache.getFrameData(key));
- }
- else
- {
- if (updateBody && this.parent['body'])
- {
- this.parent.body.bounds.width = this.width;
- this.parent.body.bounds.height = this.height;
- }
- }
- }
-
- }
-
- /**
- * Load a DynamicTexture as its texture.
- * @param texture {DynamicTexture} The texture object to be used by this sprite.
- */
- public loadDynamicTexture(texture: DynamicTexture) {
-
- if (this.parent.animations.frameData !== null)
- {
- this.parent.animations.destroy();
- }
-
- this.setTo(null, texture);
- this.parent.texture.width = this.width;
- this.parent.texture.height = this.height;
-
- }
-
- public set width(value: number) {
- this._width = value;
- }
-
- public set height(value: number) {
- this._height = value;
- }
-
- /**
- * The width of the texture. If an animation it will be the frame width, not the width of the sprite sheet.
- * If using a DynamicTexture it will be the width of the dynamic texture itself.
- * @type {number}
- */
- public get width(): number {
-
- if (this.isDynamic)
- {
- return this.dynamicTexture.width;
- }
- else
- {
- return this._width;
- }
- }
-
- /**
- * The height of the texture. If an animation it will be the frame height, not the height of the sprite sheet.
- * If using a DynamicTexture it will be the height of the dynamic texture itself.
- * @type {number}
- */
- public get height(): number {
-
- if (this.isDynamic)
- {
- return this.dynamicTexture.height;
- }
- else
- {
- return this._height;
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/gameobjects/Events.ts b/wip/TS Source/gameobjects/Events.ts
deleted file mode 100644
index 5a8c284b..00000000
--- a/wip/TS Source/gameobjects/Events.ts
+++ /dev/null
@@ -1,112 +0,0 @@
-///
-
-/**
-* Phaser - Components - Events
-*
-* Signals that are dispatched by the Sprite and its various components
-*/
-
-module Phaser.Components {
-
- export class Events {
-
- /**
- * The Events component is a collection of events fired by the parent game object and its components.
- * @param parent The game object using this Input component
- */
- constructor(parent: Phaser.Sprite) {
-
- this.game = parent.game;
- this._parent = parent;
-
- this.onAddedToGroup = new Phaser.Signal;
- this.onRemovedFromGroup = new Phaser.Signal;
- this.onKilled = new Phaser.Signal;
- this.onRevived = new Phaser.Signal;
- this.onOutOfBounds = new Phaser.Signal;
-
- }
-
- /**
- * Reference to Phaser.Game
- */
- public game: Phaser.Game;
-
- /**
- * Local private reference to its parent game object.
- */
- private _parent: Phaser.Sprite;
-
- /**
- * Dispatched by the Group this Sprite is added to.
- */
- public onAddedToGroup: Phaser.Signal;
-
- /**
- * Dispatched by the Group this Sprite is removed from.
- */
- public onRemovedFromGroup: Phaser.Signal;
-
- /**
- * Dispatched when this Sprite is killed.
- */
- public onKilled: Phaser.Signal;
-
- /**
- * Dispatched when this Sprite is revived.
- */
- public onRevived: Phaser.Signal;
-
- /**
- * Dispatched by the Input component when a pointer moves over an Input enabled sprite.
- */
- public onInputOver: Phaser.Signal;
-
- /**
- * Dispatched by the Input component when a pointer moves out of an Input enabled sprite.
- */
- public onInputOut: Phaser.Signal;
-
- /**
- * Dispatched by the Input component when a pointer is pressed down on an Input enabled sprite.
- */
- public onInputDown: Phaser.Signal;
-
- /**
- * Dispatched by the Input component when a pointer is released over an Input enabled sprite
- */
- public onInputUp: Phaser.Signal;
-
- /**
- * Dispatched by the Input component when the Sprite starts being dragged
- */
- public onDragStart: Phaser.Signal;
-
- /**
- * Dispatched by the Input component when the Sprite stops being dragged
- */
- public onDragStop: Phaser.Signal;
-
- /**
- * Dispatched by the Animation component when the Sprite starts being animated
- */
- public onAnimationStart: Phaser.Signal;
-
- /**
- * Dispatched by the Animation component when the Sprite animation completes
- */
- public onAnimationComplete: Phaser.Signal;
-
- /**
- * Dispatched by the Animation component when the Sprite animation loops
- */
- public onAnimationLoop: Phaser.Signal;
-
- /**
- * Dispatched by the Sprite when it first leaves the world bounds
- */
- public onOutOfBounds: Phaser.Signal;
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/gameobjects/GameObjectFactory.ts b/wip/TS Source/gameobjects/GameObjectFactory.ts
deleted file mode 100644
index 114594bd..00000000
--- a/wip/TS Source/gameobjects/GameObjectFactory.ts
+++ /dev/null
@@ -1,276 +0,0 @@
-///
-
-/**
-* Phaser - GameObjectFactory
-*
-* A quick way to create new world objects and add existing objects to the current world.
-*/
-
-module Phaser {
-
- export class GameObjectFactory {
-
- /**
- * GameObjectFactory constructor
- * @param game {Game} A reference to the current Game.
- */
- constructor(game: Phaser.Game) {
-
- this.game = game;
- this._world = this.game.world;
-
- }
-
- /**
- * Local reference to Game
- */
- public game: Phaser.Game;
-
- /**
- * Local private reference to World
- */
- private _world: Phaser.World;
-
- /**
- * Create a new camera with specific position and size.
- *
- * @param x {number} X position of the new camera.
- * @param y {number} Y position of the new camera.
- * @param width {number} Width of the new camera.
- * @param height {number} Height of the new camera.
- * @returns {Camera} The newly created camera object.
- */
- public camera(x: number, y: number, width: number, height: number): Phaser.Camera {
- return this._world.cameras.addCamera(x, y, width, height);
- }
-
- /**
- * Create a new GeomSprite with specific position.
- *
- * @param x {number} X position of the new geom sprite.
- * @param y {number} Y position of the new geom sprite.
- * @returns {GeomSprite} The newly created geom sprite object.
- */
- //public geomSprite(x: number, y: number): GeomSprite {
- // return this._world.group.add(new GeomSprite(this.game, x, y));
- //}
-
- /**
- * Create a new Button game object.
- *
- * @param [x] {number} X position of the button.
- * @param [y] {number} Y position of the button.
- * @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this button.
- * @param [callback] {function} The function to call when this button is pressed
- * @param [callbackContext] {object} The context in which the callback will be called (usually 'this')
- * @param [overFrame] {string|number} This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
- * @param [outFrame] {string|number} This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
- * @param [downFrame] {string|number} This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
- * @returns {Button} The newly created button object.
- */
- public button(x: number = 0, y: number = 0, key: string = null, callback = null, callbackContext = null, overFrame = null, outFrame = null, downFrame = null): Phaser.UI.Button {
- return this._world.group.add(new Phaser.UI.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
- }
-
- /**
- * Create a new Sprite with specific position and sprite sheet key.
- *
- * @param x {number} X position of the new sprite.
- * @param y {number} Y position of the new sprite.
- * @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this sprite
- * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
- * @returns {Sprite} The newly created sprite object.
- */
- public sprite(x: number, y: number, key: string = '', frame = null): Phaser.Sprite {
- return this._world.group.add(new Phaser.Sprite(this.game, x, y, key, frame));
- }
-
- public audio(key: string, volume: number = 1, loop: bool = false): Phaser.Sound {
- return this.game.sound.add(key, volume, loop);
- }
-
- public circle(x: number, y: number, radius: number): Phaser.Physics.Circle {
- return new Phaser.Physics.Circle(this.game, x, y, radius);
- }
-
- public aabb(x: number, y: number, width: number, height:number): Phaser.Physics.AABB {
- return new Phaser.Physics.AABB(this.game, x, y, Math.floor(width / 2), Math.floor(height / 2));
- }
-
- public cell(x: number, y: number, width: number, height: number, state: number = Phaser.Physics.TileMapCell.TID_FULL): Phaser.Physics.TileMapCell {
- return new Phaser.Physics.TileMapCell(this.game, x, y, width, height).SetState(state);
- }
-
- /**
- * Create a new DynamicTexture with specific size.
- *
- * @param width {number} Width of the texture.
- * @param height {number} Height of the texture.
- * @returns {DynamicTexture} The newly created dynamic texture object.
- */
- public dynamicTexture(width: number, height: number): Phaser.Display.DynamicTexture {
- return new Phaser.Display.DynamicTexture(this.game, width, height);
- }
-
- /**
- * Create a new object container.
- *
- * @param maxSize {number} Optional, capacity of this group.
- * @returns {Group} The newly created group.
- */
- public group(maxSize: number = 0): Phaser.Group {
- return this._world.group.add(new Phaser.Group(this.game, maxSize));
- }
-
- /**
- * Create a new Particle.
- *
- * @return {Particle} The newly created particle object.
- */
- //public particle(): Phaser.ArcadeParticle {
- // return new Phaser.ArcadeParticle(this.game);
- //}
-
- /**
- * Create a new Emitter.
- *
- * @param x {number} Optional, x position of the emitter.
- * @param y {number} Optional, y position of the emitter.
- * @param size {number} Optional, size of this emitter.
- * @return {Emitter} The newly created emitter object.
- */
- //public emitter(x: number = 0, y: number = 0, size: number = 0): Phaser.ArcadeEmitter {
- // return this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size));
- //}
-
- /**
- * Create a new ScrollZone object with image key, position and size.
- *
- * @param key {string} Key to a image you wish this object to use.
- * @param x {number} X position of this object.
- * @param y {number} Y position of this object.
- * @param width number} Width of this object.
- * @param height {number} Height of this object.
- * @returns {ScrollZone} The newly created scroll zone object.
- */
- public scrollZone(key: string, x: number = 0, y: number = 0, width: number = 0, height: number = 0): Phaser.ScrollZone {
- return this._world.group.add(new Phaser.ScrollZone(this.game, key, x, y, width, height));
- }
-
- /**
- * Create a new Tilemap.
- *
- * @param key {string} Key for tileset image.
- * @param mapData {string} Data of this tilemap.
- * @param format {number} Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
- * @param [resizeWorld] {bool} resize the world to make same as tilemap?
- * @param [tileWidth] {number} width of each tile.
- * @param [tileHeight] {number} height of each tile.
- * @return {Tilemap} The newly created tilemap object.
- */
- public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth: number = 0, tileHeight: number = 0): Phaser.Tilemap {
- return this._world.group.add(new Phaser.Tilemap(this.game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
- }
-
- /**
- * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
- *
- * @param obj {object} Object the tween will be run on.
- * @param [localReference] {bool} If true the tween will be stored in the object.tween property so long as it exists. If already set it'll be over-written.
- * @return {Phaser.Tween} The newly created tween object.
- */
- public tween(obj, localReference: bool = false): Phaser.Tween {
- return this.game.tweens.create(obj, localReference);
- }
-
- /**
- * Add an existing Sprite to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param sprite The Sprite to add to the Game World
- * @return {Phaser.Sprite} The Sprite object
- */
- public existingSprite(sprite: Phaser.Sprite): Phaser.Sprite {
- return this._world.group.add(sprite);
- }
-
- /**
- * Add an existing Group to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param group The Group to add to the Game World
- * @return {Phaser.Group} The Group object
- */
- public existingGroup(group: Phaser.Group): Phaser.Group {
- return this._world.group.add(group);
- }
-
- /**
- * Add an existing Button to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param button The Button to add to the Game World
- * @return {Phaser.Button} The Button object
- */
- public existingButton(button: Phaser.UI.Button): Phaser.UI.Button {
- return this._world.group.add(button);
- }
-
- /**
- * Add an existing GeomSprite to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param sprite The GeomSprite to add to the Game World
- * @return {Phaser.GeomSprite} The GeomSprite object
- */
- //public existingGeomSprite(sprite: GeomSprite): GeomSprite {
- // return this._world.group.add(sprite);
- //}
-
- /**
- * Add an existing Emitter to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param emitter The Emitter to add to the Game World
- * @return {Phaser.Emitter} The Emitter object
- */
- //public existingEmitter(emitter: Phaser.ArcadeEmitter): Phaser.ArcadeEmitter {
- // return this._world.group.add(emitter);
- //}
-
- /**
- * Add an existing ScrollZone to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param scrollZone The ScrollZone to add to the Game World
- * @return {Phaser.ScrollZone} The ScrollZone object
- */
- public existingScrollZone(scrollZone: Phaser.ScrollZone): Phaser.ScrollZone {
- return this._world.group.add(scrollZone);
- }
-
- /**
- * Add an existing Tilemap to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param tilemap The Tilemap to add to the Game World
- * @return {Phaser.Tilemap} The Tilemap object
- */
- public existingTilemap(tilemap: Phaser.Tilemap): Phaser.Tilemap {
- return this._world.group.add(tilemap);
- }
-
- /**
- * Add an existing Tween to the current world.
- * Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
- *
- * @param tween The Tween to add to the Game World
- * @return {Phaser.Tween} The Tween object
- */
- public existingTween(tween: Phaser.Tween): Phaser.Tween {
- return this.game.tweens.add(tween);
- }
-
- }
-
-}
diff --git a/wip/TS Source/gameobjects/IGameObject.ts b/wip/TS Source/gameobjects/IGameObject.ts
deleted file mode 100644
index 9ff82ef2..00000000
--- a/wip/TS Source/gameobjects/IGameObject.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-///
-
-module Phaser {
-
- export interface IGameObject {
-
- /**
- * Reference to the main game object
- */
- game: Phaser.Game;
-
- /**
- * The type of game object.
- */
- type: number;
-
- /**
- * The ID of the Group this Sprite belongs to.
- */
- group: Phaser.Group;
-
- /**
- * The name of the Game Object. Typically not set by Phaser, but extremely useful for debugging / logic.
- */
- name: string;
-
- /**
- * x value of the object.
- */
- x: number;
-
- /**
- * y value of the object.
- */
- y: number;
-
- /**
- * z-index value of the object.
- */
- z: number;
-
- /**
- * Controls if both update and render are called by the core game loop.
- */
- exists: bool;
-
- /**
- * Controls if update() is automatically called by the core game loop.
- */
- active: bool;
-
- /**
- * Controls if this is rendered or skipped during the core game loop.
- */
- visible: bool;
-
- /**
- * The animation manager component
- */
- animations: Phaser.Components.AnimationManager;
-
- /**
- * Associated events
- */
- events: Phaser.Components.Events;
-
- /**
- * The input component
- */
- input: Phaser.Components.InputHandler;
-
- /**
- * The texture used to render.
- */
- texture: Phaser.Display.Texture;
-
- /**
- * The transform component.
- */
- transform: Phaser.Components.TransformManager;
- //transform;
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/gameobjects/ScrollRegion.ts b/wip/TS Source/gameobjects/ScrollRegion.ts
deleted file mode 100644
index 681e3dcd..00000000
--- a/wip/TS Source/gameobjects/ScrollRegion.ts
+++ /dev/null
@@ -1,206 +0,0 @@
-///
-
-/**
-* Phaser - ScrollRegion
-*
-* Creates a scrolling region within a ScrollZone.
-* It is scrolled via the scrollSpeed.x/y properties.
-*/
-
-module Phaser {
-
- export class ScrollRegion {
-
- /**
- * ScrollRegion constructor
- * Create a new ScrollRegion.
- *
- * @param x {number} X position in world coordinate.
- * @param y {number} Y position in world coordinate.
- * @param width {number} Width of this object.
- * @param height {number} Height of this object.
- * @param speedX {number} X-axis scrolling speed.
- * @param speedY {number} Y-axis scrolling speed.
- */
- constructor(x: number, y: number, width: number, height: number, speedX:number, speedY:number) {
-
- // Our seamless scrolling quads
- this._A = new Rectangle(x, y, width, height);
- this._B = new Rectangle(x, y, width, height);
- this._C = new Rectangle(x, y, width, height);
- this._D = new Rectangle(x, y, width, height);
- this._scroll = new Vec2();
- this._bounds = new Rectangle(x, y, width, height);
- this.scrollSpeed = new Vec2(speedX, speedY);
-
- }
-
- private _A: Rectangle;
- private _B: Rectangle;
- private _C: Rectangle;
- private _D: Rectangle;
-
- private _bounds: Rectangle;
- private _scroll: Vec2;
-
- private _anchorWidth: number = 0;
- private _anchorHeight: number = 0;
- private _inverseWidth: number = 0;
- private _inverseHeight: number = 0;
-
- /**
- * Will this region be rendered? (default to true)
- * @type {bool}
- */
- public visible: bool = true;
-
- /**
- * Region scrolling speed.
- * @type {Vec2}
- */
- public scrollSpeed: Vec2;
-
- /**
- * Update region scrolling with tick time.
- * @param delta {number} Elapsed time since last update.
- */
- public update(delta: number) {
-
- this._scroll.x += this.scrollSpeed.x;
- this._scroll.y += this.scrollSpeed.y;
-
- if (this._scroll.x > this._bounds.right)
- {
- this._scroll.x = this._bounds.x;
- }
-
- if (this._scroll.x < this._bounds.x)
- {
- this._scroll.x = this._bounds.right;
- }
-
- if (this._scroll.y > this._bounds.bottom)
- {
- this._scroll.y = this._bounds.y;
- }
-
- if (this._scroll.y < this._bounds.y)
- {
- this._scroll.y = this._bounds.bottom;
- }
-
- // Anchor Dimensions
- this._anchorWidth = (this._bounds.width - this._scroll.x) + this._bounds.x;
- this._anchorHeight = (this._bounds.height - this._scroll.y) + this._bounds.y;
-
- if (this._anchorWidth > this._bounds.width)
- {
- this._anchorWidth = this._bounds.width;
- }
-
- if (this._anchorHeight > this._bounds.height)
- {
- this._anchorHeight = this._bounds.height;
- }
-
- this._inverseWidth = this._bounds.width - this._anchorWidth;
- this._inverseHeight = this._bounds.height - this._anchorHeight;
-
- // Rectangle A
- this._A.setTo(this._scroll.x, this._scroll.y, this._anchorWidth, this._anchorHeight);
-
- // Rectangle B
- this._B.y = this._scroll.y;
- this._B.width = this._inverseWidth;
- this._B.height = this._anchorHeight;
-
- // Rectangle C
- this._C.x = this._scroll.x;
- this._C.width = this._anchorWidth;
- this._C.height = this._inverseHeight;
-
- // Rectangle D
- this._D.width = this._inverseWidth;
- this._D.height = this._inverseHeight;
-
- }
-
- /**
- * Render this region to specific context.
- * @param context {CanvasRenderingContext2D} Canvas context this region will be rendered to.
- * @param texture {object} The texture to be rendered.
- * @param dx {number} X position in world coordinate.
- * @param dy {number} Y position in world coordinate.
- * @param width {number} Width of this region to be rendered.
- * @param height {number} Height of this region to be rendered.
- */
- public render(context:CanvasRenderingContext2D, texture, dx: number, dy: number, dw: number, dh: number) {
-
- if (this.visible == false)
- {
- return;
- }
-
- // dx/dy are the world coordinates to render the FULL ScrollZone into.
- // This ScrollRegion may be smaller than that and offset from the dx/dy coordinates.
-
- this.crop(context, texture, this._A.x, this._A.y, this._A.width, this._A.height, dx, dy, dw, dh, 0, 0);
- this.crop(context, texture, this._B.x, this._B.y, this._B.width, this._B.height, dx, dy, dw, dh, this._A.width, 0);
- this.crop(context, texture, this._C.x, this._C.y, this._C.width, this._C.height, dx, dy, dw, dh, 0, this._A.height);
- this.crop(context, texture, this._D.x, this._D.y, this._D.width, this._D.height, dx, dy, dw, dh, this._C.width, this._A.height);
-
- //context.fillStyle = 'rgb(255,255,255)';
- //context.font = '18px Arial';
- //context.fillText('RectangleA: ' + this._A.toString(), 32, 450);
- //context.fillText('RectangleB: ' + this._B.toString(), 32, 480);
- //context.fillText('RectangleC: ' + this._C.toString(), 32, 510);
- //context.fillText('RectangleD: ' + this._D.toString(), 32, 540);
-
- }
-
- /**
- * Crop part of the texture and render it to the given context.
- * @param context {CanvasRenderingContext2D} Canvas context the texture will be rendered to.
- * @param texture {object} Texture to be rendered.
- * @param srcX {number} Target region top-left x coordinate in the texture.
- * @param srcX {number} Target region top-left y coordinate in the texture.
- * @param srcW {number} Target region width in the texture.
- * @param srcH {number} Target region height in the texture.
- * @param destX {number} Render region top-left x coordinate in the context.
- * @param destX {number} Render region top-left y coordinate in the context.
- * @param destW {number} Target region width in the context.
- * @param destH {number} Target region height in the context.
- * @param offsetX {number} X offset to the context.
- * @param offsetY {number} Y offset to the context.
- */
- private crop(context, texture, srcX, srcY, srcW, srcH, destX, destY, destW, destH, offsetX, offsetY) {
-
- offsetX += destX;
- offsetY += destY;
-
- if (srcW > (destX + destW) - offsetX)
- {
- srcW = (destX + destW) - offsetX;
- }
-
- if (srcH > (destY + destH) - offsetY)
- {
- srcH = (destY + destH) - offsetY;
- }
-
- srcX = Math.floor(srcX);
- srcY = Math.floor(srcY);
- srcW = Math.floor(srcW);
- srcH = Math.floor(srcH);
- offsetX = Math.floor(offsetX + this._bounds.x);
- offsetY = Math.floor(offsetY + this._bounds.y);
-
- if (srcW > 0 && srcH > 0)
- {
- context.drawImage(texture, srcX, srcY, srcW, srcH, offsetX, offsetY, srcW, srcH);
- }
- }
-
- }
-
-}
diff --git a/wip/TS Source/gameobjects/ScrollZone.ts b/wip/TS Source/gameobjects/ScrollZone.ts
deleted file mode 100644
index 613f903e..00000000
--- a/wip/TS Source/gameobjects/ScrollZone.ts
+++ /dev/null
@@ -1,147 +0,0 @@
-///
-
-/**
-* Phaser - ScrollZone
-*
-* Creates a scrolling region of the given width and height from an image in the cache.
-* The ScrollZone can be positioned anywhere in-world like a normal game object, re-act to physics, collision, etc.
-* The image within it is scrolled via ScrollRegions and their scrollSpeed.x/y properties.
-* If you create a scroll zone larger than the given source image it will create a DynamicTexture and fill it with a pattern of the source image.
-*/
-
-module Phaser {
-
- export class ScrollZone extends Sprite {
-
- /**
- * ScrollZone constructor
- * Create a new ScrollZone.
- *
- * @param game {Phaser.Game} Current game instance.
- * @param key {string} Asset key for image texture of this object.
- * @param x {number} X position in world coordinate.
- * @param y {number} Y position in world coordinate.
- * @param [width] {number} width of this object.
- * @param [height] {number} height of this object.
- */
- constructor(game: Game, key:string, x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
-
- super(game, x, y, key);
-
- this.type = Phaser.Types.SCROLLZONE;
-
- this.regions = [];
-
- if (this.texture.loaded)
- {
- if (width > this.width || height > this.height)
- {
- // Create our repeating texture (as the source image wasn't large enough for the requested size)
- this.createRepeatingTexture(width, height);
- this.width = width;
- this.height = height;
- }
-
- // Create a default ScrollRegion at the requested size
- this.addRegion(0, 0, this.width, this.height);
-
- // If the zone is smaller than the image itself then shrink the bounds
- if ((width < this.width || height < this.height) && width !== 0 && height !== 0)
- {
- this.width = width;
- this.height = height;
- }
-
- }
-
- }
-
- /**
- * Current region this zone is scrolling.
- * @type {ScrollRegion}
- */
- public currentRegion: Phaser.ScrollRegion;
-
- /**
- * Array contains all added regions.
- * @type {ScrollRegion[]}
- */
- public regions: Phaser.ScrollRegion[];
-
- /**
- * Add a new region to this zone.
- * @param x {number} X position of the new region.
- * @param y {number} Y position of the new region.
- * @param width {number} Width of the new region.
- * @param height {number} Height of the new region.
- * @param [speedX] {number} x-axis scrolling speed.
- * @param [speedY] {number} y-axis scrolling speed.
- * @return {ScrollRegion} The newly added region.
- */
- public addRegion(x: number, y: number, width: number, height: number, speedX: number = 0, speedY: number = 0): Phaser.ScrollRegion {
-
- if (x > this.width || y > this.height || x < 0 || y < 0 || (x + width) > this.width || (y + height) > this.height)
- {
- throw Error('Invalid ScrollRegion defined. Cannot be larger than parent ScrollZone');
- return null;
- }
-
- this.currentRegion = new Phaser.ScrollRegion(x, y, width, height, speedX, speedY);
-
- this.regions.push(this.currentRegion);
-
- return this.currentRegion;
-
- }
-
- /**
- * Set scrolling speed of current region.
- * @param x {number} X speed of current region.
- * @param y {number} Y speed of current region.
- */
- public setSpeed(x: number, y: number) {
-
- if (this.currentRegion)
- {
- this.currentRegion.scrollSpeed.setTo(x, y);
- }
-
- return this;
-
- }
-
- /**
- * Update regions.
- */
- public update() {
-
- for (var i = 0; i < this.regions.length; i++)
- {
- this.regions[i].update(this.game.time.delta);
- }
-
- }
-
- /**
- * Create repeating texture with _texture, and store it into the _dynamicTexture.
- * Used to create texture when texture image is small than size of the zone.
- */
- private createRepeatingTexture(regionWidth: number, regionHeight: number) {
-
- // Work out how many we'll need of the source image to make it tile properly
- var tileWidth = Math.ceil(this.width / regionWidth) * regionWidth;
- var tileHeight = Math.ceil(this.height / regionHeight) * regionHeight;
-
- var dt: Phaser.Display.DynamicTexture = new Phaser.Display.DynamicTexture(this.game, tileWidth, tileHeight);
-
- dt.context.rect(0, 0, tileWidth, tileHeight);
- dt.context.fillStyle = dt.context.createPattern(this.texture.imageTexture, "repeat");
- dt.context.fill();
-
- this.texture.loadDynamicTexture(dt);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/gameobjects/Sprite.ts b/wip/TS Source/gameobjects/Sprite.ts
deleted file mode 100644
index 9219b838..00000000
--- a/wip/TS Source/gameobjects/Sprite.ts
+++ /dev/null
@@ -1,447 +0,0 @@
-///
-
-/**
-* Phaser - Sprite
-*/
-
-module Phaser {
-
- export class Sprite implements IGameObject {
-
- /**
- * Create a new Sprite.
- *
- * @param game {Phaser.Game} Current game instance.
- * @param [x] {number} the initial x position of the sprite.
- * @param [y] {number} the initial y position of the sprite.
- * @param [key] {string} Key of the graphic you want to load for this sprite.
- */
- constructor(game: Game, x: number = 0, y: number = 0, key: string = null, frame = null) {
-
- this.game = game;
- this.type = Phaser.Types.SPRITE;
-
- this.exists = true;
- this.active = true;
- this.visible = true;
- this.alive = true;
-
- this.x = x;
- this.y = y;
- this.z = -1;
- this.group = null;
- this.name = '';
-
- this.events = new Phaser.Components.Events(this);
- this.animations = new Phaser.Components.AnimationManager(this);
- this.input = new Phaser.Components.InputHandler(this);
- this.texture = new Phaser.Display.Texture(this);
- this.transform = new Phaser.Components.TransformManager(this);
-
- if (key !== null)
- {
- this.texture.loadImage(key, false);
- }
- else
- {
- this.texture.opaque = true;
- }
-
- if (frame !== null)
- {
- if (typeof frame == 'string')
- {
- this.frameName = frame;
- }
- else
- {
- this.frame = frame;
- }
- }
-
- this.worldView = new Rectangle(x, y, this.width, this.height);
- this.cameraView = new Rectangle(x, y, this.width, this.height);
-
- this.transform.setCache();
-
- //this.body = new Phaser.Physics.Body(this, 0);
-
- this.outOfBounds = false;
- this.outOfBoundsAction = Phaser.Types.OUT_OF_BOUNDS_PERSIST;
-
- // Handy proxies
- this.scale = this.transform.scale;
- this.alpha = this.texture.alpha;
- this.origin = this.transform.origin;
- this.crop = this.texture.crop;
-
- }
-
- /**
- * Reference to the main game object
- */
- public game: Phaser.Game;
-
- /**
- * The type of game object.
- */
- public type: number;
-
- /**
- * The name of game object.
- */
- public name: string;
-
- /**
- * The Group this Sprite belongs to.
- */
- public group: Phaser.Group;
-
- /**
- * Controls if both update and render are called by the core game loop.
- */
- public exists: bool;
-
- /**
- * Controls if update() is automatically called by the core game loop.
- */
- public active: bool;
-
- /**
- * Controls if this Sprite is rendered or skipped during the core game loop.
- */
- public visible: bool;
-
- /**
- * A useful state for many game objects. Kill and revive both flip this switch.
- */
- public alive: bool;
-
- /**
- * Is the Sprite out of the world bounds or not?
- */
- public outOfBounds: bool;
-
- /**
- * The action to be taken when the sprite is fully out of the world bounds
- * Defaults to Phaser.Types.OUT_OF_BOUNDS_PERSIST
- */
- public outOfBoundsAction: number;
-
- /**
- * The texture used to render the Sprite.
- */
- public texture: Phaser.Display.Texture;
-
- /**
- * The Sprite transform component.
- */
- public transform: Phaser.Components.TransformManager;
-
- /**
- * The Input component
- */
- public input: Phaser.Components.InputHandler;
-
- /**
- * The Events component
- */
- public events: Phaser.Components.Events;
-
- /**
- * The Physics Body
- */
- public body: Phaser.Physics.Body;
-
- /**
- * This manages animations of the sprite. You can modify animations through it. (see AnimationManager)
- * @type AnimationManager
- */
- public animations: Phaser.Components.AnimationManager;
-
- /**
- * A Rectangle that defines the size and placement of the Sprite in the game world,
- * after taking into consideration both scrollFactor and scaling.
- */
- public worldView: Phaser.Rectangle;
-
- /**
- * A Rectangle that maps to the placement of this sprite with respect to a specific Camera.
- * This value is constantly updated and modified during the internal render pass, it is not meant to be accessed directly.
- */
- public cameraView: Phaser.Rectangle;
-
- /**
- * A local tween variable. Used by the TweenManager when setting a tween on this sprite or a property of it.
- */
- public tween: Phaser.Tween;
-
- /**
- * A bool representing if the Sprite has been modified in any way via a scale, rotate, flip or skew.
- */
- public modified: bool = false;
-
- /**
- * x value of the object.
- */
- public x: number = 0;
-
- /**
- * y value of the object.
- */
- public y: number = 0;
-
- /**
- * z order value of the object.
- */
- public z: number = -1;
-
- /**
- * Render iteration counter
- */
- public renderOrderID: number = 0;
-
- /**
- * The rotation of the sprite in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
- */
- public get rotation(): number {
- return this.transform.rotation;
- }
-
- /**
- * Set the rotation of the sprite in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
- * The value is automatically wrapped to be between 0 and 360.
- */
- public set rotation(value: number) {
-
- this.transform.rotation = this.game.math.wrap(value, 360, 0);
-
- if (this.body)
- {
- //this.body.angle = this.game.math.degreesToRadians(this.game.math.wrap(value, 360, 0));
- }
-
- }
-
- /**
- * Brings this Sprite to the top of its current Group, if set.
- */
- public bringToTop() {
-
- if (this.group)
- {
- this.group.bringToTop(this);
- }
-
- }
-
- /**
- * The scale of the Sprite. A value of 1 is original scale. 0.5 is half size. 2 is double the size.
- * This is a reference to Sprite.transform.scale
- */
- public scale: Phaser.Vec2;
-
- /**
- * The crop rectangle allows you to control which part of the sprite texture is rendered without distorting it.
- * Set to null to disable, set to a Phaser.Rectangle object to control the region that will be rendered, anything outside the rectangle is ignored.
- * This is a reference to Sprite.texture.crop
- * @type {Phaser.Rectangle}
- */
- public crop: Phaser.Rectangle;
-
- /**
- * The origin of the Sprite around which rotation and positioning takes place.
- * This is a reference to Sprite.transform.origin
- */
- public origin: Phaser.Vec2;
-
- /**
- * The alpha of the Sprite between 0 and 1, a value of 1 being fully opaque.
- */
- public set alpha(value: number) {
- this.texture.alpha = value;
- }
-
- /**
- * The alpha of the Sprite between 0 and 1, a value of 1 being fully opaque.
- */
- public get alpha(): number {
- return this.texture.alpha;
- }
-
- /**
- * Set the animation frame by frame number.
- */
- public set frame(value: number) {
- this.animations.frame = value;
- }
-
- /**
- * Get the animation frame number.
- */
- public get frame(): number {
- return this.animations.frame;
- }
-
- /**
- * Set the animation frame by frame name.
- */
- public set frameName(value: string) {
- this.animations.frameName = value;
- }
-
- /**
- * Get the animation frame name.
- */
- public get frameName(): string {
- return this.animations.frameName;
- }
-
- public set width(value: number) {
- this.transform.scale.x = value / this.texture.width;
- }
-
- public get width(): number {
- return this.texture.width * this.transform.scale.x;
- }
-
- public set height(value: number) {
- this.transform.scale.y = value / this.texture.height;
- }
-
- public get height(): number {
- return this.texture.height * this.transform.scale.y;
- }
-
- /**
- * Pre-update is called right before update() on each object in the game loop.
- */
- public preUpdate() {
-
- this.transform.update();
-
- if (this.transform.scrollFactor.x != 1 && this.transform.scrollFactor.x != 0)
- {
- this.worldView.x = (this.x * this.transform.scrollFactor.x) - (this.width * this.transform.origin.x);
- }
- else
- {
- this.worldView.x = this.x - (this.width * this.transform.origin.x);
- }
-
- if (this.transform.scrollFactor.y != 1 && this.transform.scrollFactor.y != 0)
- {
- this.worldView.y = (this.y * this.transform.scrollFactor.y) - (this.height * this.transform.origin.y);
- }
- else
- {
- this.worldView.y = this.y - (this.height * this.transform.origin.y);
- }
-
- this.worldView.width = this.width;
- this.worldView.height = this.height;
-
- if (this.modified == false && (!this.transform.scale.equals(1) || !this.transform.skew.equals(0) || this.transform.rotation != 0 || this.transform.rotationOffset != 0 || this.texture.flippedX || this.texture.flippedY))
- {
- this.modified = true;
- }
-
- }
-
- /**
- * Override this function to update your sprites position and appearance.
- */
- public update() {
- }
-
- /**
- * Automatically called after update() by the game loop for all 'alive' objects.
- */
- public postUpdate() {
-
- this.animations.update();
-
- this.checkBounds();
-
- //this.transform.centerOn(this.body.aabb.pos.x, this.body.aabb.pos.y);
-
- if (this.modified == true && this.transform.scale.equals(1) && this.transform.skew.equals(0) && this.transform.rotation == 0 && this.transform.rotationOffset == 0 && this.texture.flippedX == false && this.texture.flippedY == false)
- {
- this.modified = false;
- }
-
- }
-
- private checkBounds() {
-
- if (Phaser.RectangleUtils.intersects(this.worldView, this.game.world.bounds))
- {
- this.outOfBounds = false;
- }
- else
- {
- if (this.outOfBounds == false)
- {
- this.events.onOutOfBounds.dispatch(this);
- }
-
- this.outOfBounds = true;
-
- if (this.outOfBoundsAction == Phaser.Types.OUT_OF_BOUNDS_KILL)
- {
- this.kill();
- }
- else if (this.outOfBoundsAction == Phaser.Types.OUT_OF_BOUNDS_DESTROY)
- {
- this.destroy();
- }
- }
-
- }
-
- /**
- * Clean up memory.
- */
- public destroy() {
-
- this.input.destroy();
-
- }
-
- /**
- * Handy for "killing" game objects.
- * Default behavior is to flag them as nonexistent AND dead.
- * However, if you want the "corpse" to remain in the game,
- * like to animate an effect or whatever, you should override this,
- * setting only alive to false, and leaving exists true.
- */
- public kill(removeFromGroup:bool = false) {
-
- this.alive = false;
- this.exists = false;
-
- if (removeFromGroup && this.group)
- {
- //this.group.remove(this);
- }
-
- this.events.onKilled.dispatch(this);
-
- }
-
- /**
- * Handy for bringing game objects "back to life". Just sets alive and exists back to true.
- * In practice, this is most often called by Object.reset().
- */
- public revive() {
-
- this.alive = true;
- this.exists = true;
-
- this.events.onRevived.dispatch(this);
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/gameobjects/TransformManager.ts b/wip/TS Source/gameobjects/TransformManager.ts
deleted file mode 100644
index 0ca3ffb7..00000000
--- a/wip/TS Source/gameobjects/TransformManager.ts
+++ /dev/null
@@ -1,357 +0,0 @@
-///
-
-/**
-* Phaser - Components - TransformManager
-*/
-
-module Phaser.Components {
-
- export class TransformManager {
-
- /**
- * Creates a new TransformManager component
- * @param parent The game object using this transform
- */
- constructor(parent) {
-
- this.game = parent.game;
- this.parent = parent;
-
- this.local = new Phaser.Mat3;
-
- this.scrollFactor = new Phaser.Vec2(1, 1);
- this.origin = new Phaser.Vec2;
- this.scale = new Phaser.Vec2(1, 1);
- this.skew = new Phaser.Vec2;
-
- this.center = new Phaser.Point;
- this.upperLeft = new Phaser.Point;
- this.upperRight = new Phaser.Point;
- this.bottomLeft = new Phaser.Point;
- this.bottomRight = new Phaser.Point;
-
- this._pos = new Phaser.Point;
- this._scale = new Phaser.Point;
- this._size = new Phaser.Point;
- this._halfSize = new Phaser.Point;
- this._offset = new Phaser.Point;
- this._origin = new Phaser.Point;
- this._sc = new Phaser.Point;
- this._scA = new Phaser.Point;
-
- }
-
- private _rotation: number;
-
- private _dirty: bool = false;
-
- // Cache vars
- private _pos: Phaser.Point;
- private _scale: Phaser.Point;
- private _size: Phaser.Point;
- private _halfSize: Phaser.Point;
- private _offset: Phaser.Point;
- private _origin: Phaser.Point;
- private _sc: Phaser.Point;
- private _scA: Phaser.Point;
- private _angle: number;
- private _distance: number;
- private _prevRotation: number;
- private _flippedX: bool;
- private _flippedY: bool;
-
- /**
- * Reference to Phaser.Game
- */
- public game: Phaser.Game;
-
- /**
- * Reference to the parent object (Sprite, Group, etc)
- */
- public parent: Phaser.Sprite;
-
- /**
- * Scale of the object. A scale of 1.0 is the original size. 0.5 half size. 2.0 double sized.
- */
- public scale: Phaser.Vec2;
-
- /**
- * Skew the object along the x and y axis. A skew value of 0 is no skew.
- */
- public skew: Phaser.Vec2;
-
- /**
- * The influence of camera movement upon the object, if supported.
- */
- public scrollFactor: Phaser.Vec2;
-
- /**
- * The origin is the point around which scale and rotation takes place and defaults to the top-left of the sprite.
- */
- public origin: Phaser.Vec2;
-
- /**
- * This value is added to the rotation of the object.
- * For example if you had a texture drawn facing straight up then you could set
- * rotationOffset to 90 and it would correspond correctly with Phasers right-handed coordinate system.
- * @type {number}
- */
- public rotationOffset: number = 0;
-
- /**
- * The rotation of the object in degrees. Phaser uses a right-handed coordinate system, where 0 points to the right.
- */
- public rotation: number = 0;
-
- /**
- * The center of the Sprite in world coordinates, after taking scaling and rotation into consideration
- */
- public center: Phaser.Point;
-
- /**
- * The upper-left corner of the Sprite in world coordinates, after taking scaling and rotation into consideration
- */
- public upperLeft: Phaser.Point;
-
- /**
- * The upper-right corner of the Sprite in world coordinates, after taking scaling and rotation into consideration
- */
- public upperRight: Phaser.Point;
-
- /**
- * The bottom-left corner of the Sprite in world coordinates, after taking scaling and rotation into consideration
- */
- public bottomLeft: Phaser.Point;
-
- /**
- * The bottom-right corner of the Sprite in world coordinates, after taking scaling and rotation into consideration
- */
- public bottomRight: Phaser.Point;
-
- /**
- * The local transform matrix
- */
- public local: Phaser.Mat3;
-
- /**
- * The distance from the center of the transform to the rotation origin.
- */
- public get distance(): number {
- return this._distance;
- }
-
- /**
- * The angle between the center of the transform to the rotation origin.
- */
- public get angleToCenter(): number {
- return this._angle;
- }
-
- /**
- * The offset on the X axis of the origin That is the difference between the top left of the Sprite and the origin.x.
- * So if the origin.x is 0 the offsetX will be 0. If the origin.x is 0.5 then offsetX will be sprite width / 2, and so on.
- */
- public get offsetX(): number {
- return this._offset.x;
- }
-
- /**
- * The offset on the Y axis of the origin
- */
- public get offsetY(): number {
- return this._offset.y;
- }
-
- /**
- * Half the width of the parent sprite, taking into consideration scaling
- */
- public get halfWidth(): number {
- return this._halfSize.x;
- }
-
- /**
- * Half the height of the parent sprite, taking into consideration scaling
- */
- public get halfHeight(): number {
- return this._halfSize.y;
- }
-
- /**
- * The equivalent of Math.sin(rotation + rotationOffset)
- */
- public get sin(): number {
- return this._sc.x;
- }
-
- /**
- * The equivalent of Math.cos(rotation + rotationOffset)
- */
- public get cos(): number {
- return this._sc.y;
- }
-
- /**
- * Moves the sprite so its center is located on the given x and y coordinates.
- * Doesn't change the origin of the sprite.
- */
- public centerOn(x: number, y: number) {
-
- this.parent.x = x + (this.parent.x - this.center.x);
- this.parent.y = y + (this.parent.y - this.center.y);
-
- //this.setCache();
-
- }
-
- /**
- * Populates the transform cache. Called by the parent object on creation.
- */
- public setCache() {
-
- this._pos.x = this.parent.x;
- this._pos.y = this.parent.y;
- this._halfSize.x = this.parent.width / 2;
- this._halfSize.y = this.parent.height / 2;
- this._offset.x = this.origin.x * this.parent.width;
- this._offset.y = this.origin.y * this.parent.height;
- this._angle = Math.atan2(this.halfHeight - this._offset.x, this.halfWidth - this._offset.y);
- this._distance = Math.sqrt(((this._offset.x - this._halfSize.x) * (this._offset.x - this._halfSize.x)) + ((this._offset.y - this._halfSize.y) * (this._offset.y - this._halfSize.y)));
- this._size.x = this.parent.width;
- this._size.y = this.parent.height;
- this._origin.x = this.origin.x;
- this._origin.y = this.origin.y;
- this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
- this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
- this._prevRotation = this.rotation;
-
- if (this.parent.texture && this.parent.texture.renderRotation)
- {
- this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
- this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
- }
- else
- {
- this._sc.x = 0;
- this._sc.y = 1;
- }
-
- this.center.x = this.parent.x + this._distance * this._scA.y;
- this.center.y = this.parent.y + this._distance * this._scA.x;
-
- this.upperLeft.setTo(this.center.x - this._halfSize.x * this._sc.y + this._halfSize.y * this._sc.x, this.center.y - this._halfSize.y * this._sc.y - this._halfSize.x * this._sc.x);
- this.upperRight.setTo(this.center.x + this._halfSize.x * this._sc.y + this._halfSize.y * this._sc.x, this.center.y - this._halfSize.y * this._sc.y + this._halfSize.x * this._sc.x);
- this.bottomLeft.setTo(this.center.x - this._halfSize.x * this._sc.y - this._halfSize.y * this._sc.x, this.center.y + this._halfSize.y * this._sc.y - this._halfSize.x * this._sc.x);
- this.bottomRight.setTo(this.center.x + this._halfSize.x * this._sc.y - this._halfSize.y * this._sc.x, this.center.y + this._halfSize.y * this._sc.y + this._halfSize.x * this._sc.x);
-
- this._pos.x = this.parent.x;
- this._pos.y = this.parent.y;
-
- this._flippedX = this.parent.texture.flippedX;
- this._flippedY = this.parent.texture.flippedY;
-
- }
-
- /**
- * Updates the local transform matrix and the cache values if anything has changed in the parent.
- */
- public update() {
-
- // Check cache
- this._dirty = false;
-
- // 1) Height or Width change (also triggered by a change in scale) or an Origin change
- if (this.parent.width !== this._size.x || this.parent.height !== this._size.y || this.origin.x !== this._origin.x|| this.origin.y !== this._origin.y)
- {
- this._halfSize.x = this.parent.width / 2;
- this._halfSize.y = this.parent.height / 2;
- this._offset.x = this.origin.x * this.parent.width;
- this._offset.y = this.origin.y * this.parent.height;
- this._angle = Math.atan2(this.halfHeight - this._offset.y, this.halfWidth - this._offset.x);
- this._distance = Math.sqrt(((this._offset.x - this._halfSize.x) * (this._offset.x - this._halfSize.x)) + ((this._offset.y - this._halfSize.y) * (this._offset.y - this._halfSize.y)));
- // Store
- this._size.x = this.parent.width;
- this._size.y = this.parent.height;
- this._origin.x = this.origin.x;
- this._origin.y = this.origin.y;
- this._dirty = true;
- }
-
- // 2) Rotation change
- if (this.rotation != this._prevRotation || this._dirty)
- {
- this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
- this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
-
- if (this.parent.texture.renderRotation)
- {
- this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
- this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
- }
- else
- {
- this._sc.x = 0;
- this._sc.y = 1;
- }
-
- // Store
- this._prevRotation = this.rotation;
- this._dirty = true;
- }
-
- // 3) If it has moved (or any of the above) then update the edges and center
- if (this._dirty || this.parent.x != this._pos.x || this.parent.y != this._pos.y)
- {
- this.center.x = this.parent.x + this._distance * this._scA.y;
- this.center.y = this.parent.y + this._distance * this._scA.x;
-
- this.upperLeft.setTo(this.center.x - this._halfSize.x * this._sc.y + this._halfSize.y * this._sc.x, this.center.y - this._halfSize.y * this._sc.y - this._halfSize.x * this._sc.x);
- this.upperRight.setTo(this.center.x + this._halfSize.x * this._sc.y + this._halfSize.y * this._sc.x, this.center.y - this._halfSize.y * this._sc.y + this._halfSize.x * this._sc.x);
- this.bottomLeft.setTo(this.center.x - this._halfSize.x * this._sc.y - this._halfSize.y * this._sc.x, this.center.y + this._halfSize.y * this._sc.y - this._halfSize.x * this._sc.x);
- this.bottomRight.setTo(this.center.x + this._halfSize.x * this._sc.y - this._halfSize.y * this._sc.x, this.center.y + this._halfSize.y * this._sc.y + this._halfSize.x * this._sc.x);
-
- this._pos.x = this.parent.x;
- this._pos.y = this.parent.y;
-
- // Translate
- this.local.data[2] = this.parent.x;
- this.local.data[5] = this.parent.y;
- }
-
- // Scale and Skew
- if (this._dirty || this._flippedX != this.parent.texture.flippedX)
- {
- this._flippedX = this.parent.texture.flippedX;
-
- if (this._flippedX)
- {
- this.local.data[0] = this._sc.y * -this.scale.x;
- this.local.data[3] = (this._sc.x * -this.scale.x) + this.skew.x;
- }
- else
- {
- this.local.data[0] = this._sc.y * this.scale.x;
- this.local.data[3] = (this._sc.x * this.scale.x) + this.skew.x;
- }
- }
-
- if (this._dirty || this._flippedY != this.parent.texture.flippedY)
- {
- this._flippedY = this.parent.texture.flippedY;
-
- if (this._flippedY)
- {
- this.local.data[4] = this._sc.y * -this.scale.y;
- this.local.data[1] = -(this._sc.x * -this.scale.y) + this.skew.y;
- }
- else
- {
- this.local.data[4] = this._sc.y * this.scale.y;
- this.local.data[1] = -(this._sc.x * this.scale.y) + this.skew.y;
- }
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/geom/Circle.ts b/wip/TS Source/geom/Circle.ts
deleted file mode 100644
index 836ed6fd..00000000
--- a/wip/TS Source/geom/Circle.ts
+++ /dev/null
@@ -1,316 +0,0 @@
-///
-
-/**
-* Phaser - Circle
-*
-* A Circle object is an area defined by its position, as indicated by its center point (x,y) and diameter.
-*/
-
-module Phaser {
-
- export class Circle {
-
- /**
- * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created.
- * @class Circle
- * @constructor
- * @param {Number} [x] The x coordinate of the center of the circle.
- * @param {Number} [y] The y coordinate of the center of the circle.
- * @param {Number} [diameter] The diameter of the circle.
- * @return {Circle} This circle object
- **/
- constructor(x: number = 0, y: number = 0, diameter: number = 0) {
-
- this.setTo(x, y, diameter);
-
- }
-
- private _diameter: number = 0;
- private _radius: number = 0;
-
- /**
- * The x coordinate of the center of the circle
- * @property x
- * @type Number
- **/
- public x: number = 0;
-
- /**
- * The y coordinate of the center of the circle
- * @property y
- * @type Number
- **/
- public y: number = 0;
-
- /**
- * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2.
- * @method diameter
- * @return {Number}
- **/
- get diameter(): number {
- return this._diameter;
- }
-
- /**
- * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2.
- * @method diameter
- * @param {Number} The diameter of the circle.
- **/
- set diameter(value: number) {
-
- if (value > 0)
- {
- this._diameter = value;
- this._radius = value * 0.5;
- }
-
- }
-
- /**
- * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.
- * @method radius
- * @return {Number}
- **/
- get radius(): number {
- return this._radius;
- }
-
- /**
- * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.
- * @method radius
- * @param {Number} The radius of the circle.
- **/
- set radius(value: number) {
-
- if (value > 0)
- {
- this._radius = value;
- this._diameter = value * 2;
- }
-
- }
-
- /**
- * The circumference of the circle.
- * @method circumference
- * @return {Number}
- **/
- circumference(): number {
- return 2 * (Math.PI * this._radius);
- }
-
- /**
- * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.
- * @method bottom
- * @return {Number}
- **/
- get bottom(): number {
- return this.y + this._radius;
- }
-
- /**
- * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.
- * @method bottom
- * @param {Number} The value to adjust the height of the circle by.
- **/
- set bottom(value: number) {
-
- if (value < this.y)
- {
- this._radius = 0;
- this._diameter = 0;
- }
- else
- {
- this.radius = value - this.y;
- }
-
- }
-
- /**
- * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
- * @method left
- * @return {Number} The x coordinate of the leftmost point of the circle.
- **/
- get left(): number {
- return this.x - this._radius;
- }
-
- /**
- * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
- * @method left
- * @param {Number} The value to adjust the position of the leftmost point of the circle by.
- **/
- set left(value: number) {
-
- if (value > this.x)
- {
- this._radius = 0;
- this._diameter = 0;
- }
- else
- {
- this.radius = this.x - value;
- }
-
- }
-
- /**
- * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
- * @method right
- * @return {Number}
- **/
- get right(): number {
- return this.x + this._radius;
- }
-
- /**
- * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
- * @method right
- * @param {Number} The amount to adjust the diameter of the circle by.
- **/
- set right(value: number) {
-
- if (value < this.x)
- {
- this._radius = 0;
- this._diameter = 0;
- }
- else
- {
- this.radius = value - this.x;
- }
-
- }
-
- /**
- * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter.
- * @method bottom
- * @return {Number}
- **/
- get top(): number {
- return this.y - this._radius;
- }
-
- /**
- * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter.
- * @method bottom
- * @param {Number} The amount to adjust the height of the circle by.
- **/
- set top(value: number) {
-
- if (value > this.y)
- {
- this._radius = 0;
- this._diameter = 0;
- }
- else
- {
- this.radius = this.y - value;
- }
-
- }
-
- /**
- * Gets the area of this Circle.
- * @method area
- * @return {Number} This area of this circle.
- **/
- get area(): number {
-
- if (this._radius > 0)
- {
- return Math.PI * this._radius * this._radius;
- }
- else
- {
- return 0;
- }
-
- }
-
- /**
- * Sets the members of Circle to the specified values.
- * @method setTo
- * @param {Number} x The x coordinate of the center of the circle.
- * @param {Number} y The y coordinate of the center of the circle.
- * @param {Number} diameter The diameter of the circle in pixels.
- * @return {Circle} This circle object
- **/
- public setTo(x: number, y: number, diameter: number): Circle {
-
- this.x = x;
- this.y = y;
- this._diameter = diameter;
- this._radius = diameter * 0.5;
-
- return this;
-
- }
-
- /**
- * Copies the x, y and diameter properties from any given object to this Circle.
- * @method copyFrom
- * @param {any} source - The object to copy from.
- * @return {Circle} This Circle object.
- **/
- public copyFrom(source: any): Circle {
- return this.setTo(source.x, source.y, source.diameter);
- }
-
- /**
- * Determines whether or not this Circle object is empty.
- * @method empty
- * @return {bool} A value of true if the Circle objects diameter is less than or equal to 0; otherwise false.
- **/
- get empty(): bool {
- return (this._diameter == 0);
- }
-
- /**
- * Sets all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0.
- * @method setEmpty
- * @return {Circle} This Circle object
- **/
- set empty(value: bool) {
- this.setTo(0, 0, 0);
- }
-
- /**
- * Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts.
- * @method offset
- * @param {Number} dx Moves the x value of the Circle object by this amount.
- * @param {Number} dy Moves the y value of the Circle object by this amount.
- * @return {Circle} This Circle object.
- **/
- public offset(dx: number, dy: number): Circle {
-
- this.x += dx;
- this.y += dy;
-
- return this;
-
- }
-
- /**
- * Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter.
- * @method offsetPoint
- * @param {Point} point A Point object to use to offset this Circle object.
- * @return {Circle} This Circle object.
- **/
- public offsetPoint(point: Point): Circle {
- return this.offset(point.x, point.y);
- }
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {string} a string representation of the instance.
- **/
- public toString(): string {
- return "[{Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]";
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/geom/Line.ts b/wip/TS Source/geom/Line.ts
deleted file mode 100644
index b9c3ae1e..00000000
--- a/wip/TS Source/geom/Line.ts
+++ /dev/null
@@ -1,307 +0,0 @@
-///
-
-/**
-* Phaser - Line
-*
-* A Line object is an infinte line through space. The two sets of x/y coordinates define the Line Segment.
-*/
-
-module Phaser {
-
- export class Line {
-
- /**
- *
- * @constructor
- * @param {Number} x1
- * @param {Number} y1
- * @param {Number} x2
- * @param {Number} y2
- * @return {Phaser.Line} This Object
- */
- constructor(x1: number = 0, y1: number = 0, x2: number = 0, y2: number = 0) {
-
- this.setTo(x1, y1, x2, y2);
-
- }
-
- /**
- *
- * @property x1
- * @type {Number}
- */
- public x1: number = 0;
-
- /**
- *
- * @property y1
- * @type {Number}
- */
- public y1: number = 0;
-
- /**
- *
- * @property x2
- * @type {Number}
- */
- public x2: number = 0;
-
- /**
- *
- * @property y2
- * @type {Number}
- */
- public y2: number = 0;
-
- /**
- *
- * @method clone
- * @param {Phaser.Line} [output]
- * @return {Phaser.Line}
- */
- public clone(output: Line = new Line): Line {
-
- return output.setTo(this.x1, this.y1, this.x2, this.y2);
-
- }
-
- /**
- *
- * @method copyFrom
- * @param {Phaser.Line} source
- * @return {Phaser.Line}
- */
- public copyFrom(source: Line): Line {
-
- return this.setTo(source.x1, source.y1, source.x2, source.y2);
-
- }
-
- /**
- *
- * @method copyTo
- * @param {Phaser.Line} target
- * @return {Phaser.Line}
- */
- public copyTo(target: Line): Line {
-
- return target.copyFrom(this);
-
- }
-
- /**
- *
- * @method setTo
- * @param {Number} x1
- * @param {Number} y1
- * @param {Number} x2
- * @param {Number} y2
- * @return {Phaser.Line}
- */
- public setTo(x1: number = 0, y1: number = 0, x2: number = 0, y2: number = 0): Line {
-
- this.x1 = x1;
- this.y1 = y1;
- this.x2 = x2;
- this.y2 = y2;
-
- return this;
-
- }
-
- public get width(): number {
-
- return Math.max(this.x1, this.x2) - Math.min(this.x1, this.x2);
-
- }
-
- public get height(): number {
-
- return Math.max(this.y1, this.y2) - Math.min(this.y1, this.y2);
-
- }
-
- /**
- *
- * @method length
- * @return {Number}
- */
- public get length(): number {
-
- return Math.sqrt((this.x2 - this.x1) * (this.x2 - this.x1) + (this.y2 - this.y1) * (this.y2 - this.y1));
-
- }
-
- /**
- *
- * @method getY
- * @param {Number} x
- * @return {Number}
- */
- public getY(x: number): number {
-
- return this.slope * x + this.yIntercept;
-
- }
-
- /**
- *
- * @method angle
- * @return {Number}
- */
- public get angle(): number {
-
- return Math.atan2(this.x2 - this.x1, this.y2 - this.y1);
-
- }
-
- /**
- *
- * @method slope
- * @return {Number}
- */
- public get slope(): number {
-
- return (this.y2 - this.y1) / (this.x2 - this.x1);
-
- }
-
- /**
- *
- * @method perpSlope
- * @return {Number}
- */
- public get perpSlope(): number {
-
- return -((this.x2 - this.x1) / (this.y2 - this.y1));
-
- }
-
- /**
- *
- * @method yIntercept
- * @return {Number}
- */
- public get yIntercept(): number {
-
- return (this.y1 - this.slope * this.x1);
-
- }
-
- /**
- *
- * @method isPointOnLine
- * @param {Number} x
- * @param {Number} y
- * @return {bool}
- */
- public isPointOnLine(x: number, y: number): bool {
-
- if ((x - this.x1) * (this.y2 - this.y1) === (this.x2 - this.x1) * (y - this.y1))
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- *
- * @method isPointOnLineSegment
- * @param {Number} x
- * @param {Number} y
- * @return {bool}
- */
- public isPointOnLineSegment(x: number, y: number): bool {
-
- var xMin = Math.min(this.x1, this.x2);
- var xMax = Math.max(this.x1, this.x2);
- var yMin = Math.min(this.y1, this.y2);
- var yMax = Math.max(this.y1, this.y2);
-
- if (this.isPointOnLine(x, y) && (x >= xMin && x <= xMax) && (y >= yMin && y <= yMax))
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- *
- * @method intersectLineLine
- * @param {Any} line
- * @return {Any}
- */
- public intersectLineLine(line) {
- //return Phaser.intersectLineLine(this,line);
- }
-
- /**
- *
- * @method perp
- * @param {Number} x
- * @param {Number} y
- * @param {Phaser.Line} [output]
- * @return {Phaser.Line}
- */
- /*
- public perp(x: number, y: number, output: Line): Line {
-
- if (this.y1 === this.y2)
- {
- if (output)
- {
- output.setTo(x, y, x, this.y1);
- }
- else
- {
- return new Line(x, y, x, this.y1);
- }
- }
-
- var yInt: number = (y - this.perpSlope * x);
-
- var pt = this.intersectLineLine({ x1: x, y1: y, x2: 0, y2: yInt });
-
- if (output)
- {
- output.setTo(x, y, pt.x, pt.y);
- }
- else
- {
- return new Line(x, y, pt.x, pt.y);
- }
-
- }
- */
-
- /*
- intersectLineCircle (circle:Circle)
- {
- var perp = this.perp()
- return Phaser.intersectLineCircle(this,circle);
-
- }
- */
-
- /**
- *
- * @method toString
- * @return {String}
- */
- public toString(): string {
-
- return "[{Line (x1=" + this.x1 + " y1=" + this.y1 + " x2=" + this.x2 + " y2=" + this.y2 + ")}]";
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/geom/Point.ts b/wip/TS Source/geom/Point.ts
deleted file mode 100644
index c8f386e6..00000000
--- a/wip/TS Source/geom/Point.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-///
-
-/**
-* Phaser - Point
-*
-* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
-*/
-
-module Phaser {
-
- export class Point {
-
- /**
- * Creates a new Point. If you pass no parameters a Point is created set to (0,0).
- * @class Point
- * @constructor
- * @param {Number} x The horizontal position of this Point (default 0)
- * @param {Number} y The vertical position of this Point (default 0)
- **/
- constructor(x: number = 0, y: number = 0) {
-
- this.x = x;
- this.y = y;
-
- }
-
- x: number;
- y: number;
-
- /**
- * Copies the x and y properties from any given object to this Point.
- * @method copyFrom
- * @param {any} source - The object to copy from.
- * @return {Point} This Point object.
- **/
- public copyFrom(source: any): Point {
- return this.setTo(source.x, source.y);
- }
-
- /**
- * Inverts the x and y values of this Point
- * @method invert
- * @return {Point} This Point object.
- **/
- public invert(): Point {
- return this.setTo(this.y, this.x);
- }
-
- /**
- * Sets the x and y values of this MicroPoint object to the given coordinates.
- * @method setTo
- * @param {Number} x - The horizontal position of this point.
- * @param {Number} y - The vertical position of this point.
- * @return {MicroPoint} This MicroPoint object. Useful for chaining method calls.
- **/
- public setTo(x: number, y: number): Point {
-
- this.x = x;
- this.y = y;
-
- return this;
-
- }
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {string} a string representation of the instance.
- **/
- public toString(): string {
- return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/geom/Rectangle.ts b/wip/TS Source/geom/Rectangle.ts
deleted file mode 100644
index 5f3e74d2..00000000
--- a/wip/TS Source/geom/Rectangle.ts
+++ /dev/null
@@ -1,335 +0,0 @@
-///
-
-/**
- * Rectangle
- *
- * @desc A Rectangle object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
- *
- * @version 1.6 - 24th May 2013
- * @author Richard Davey
- */
-
-module Phaser {
-
- export class Rectangle {
-
- /**
- * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created.
- * @class Rectangle
- * @constructor
- * @param {Number} x The x coordinate of the top-left corner of the Rectangle.
- * @param {Number} y The y coordinate of the top-left corner of the Rectangle.
- * @param {Number} width The width of the Rectangle in pixels.
- * @param {Number} height The height of the Rectangle in pixels.
- * @return {Rectangle} This Rectangle object
- **/
- constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
-
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
-
- }
-
- /**
- * The x coordinate of the top-left corner of the Rectangle
- * @property x
- * @type Number
- **/
- x: number;
-
- /**
- * The y coordinate of the top-left corner of the Rectangle
- * @property y
- * @type Number
- **/
- y: number;
-
- /**
- * The width of the Rectangle in pixels
- * @property width
- * @type Number
- **/
- width: number;
-
- /**
- * The height of the Rectangle in pixels
- * @property height
- * @type Number
- **/
- height: number;
-
- /**
- * Half of the width of the Rectangle
- * @property halfWidth
- * @type Number
- **/
- get halfWidth(): number {
- return Math.round(this.width / 2);
- }
-
- /**
- * Half of the height of the Rectangle
- * @property halfHeight
- * @type Number
- **/
- get halfHeight(): number {
- return Math.round(this.height / 2);
- }
-
- /**
- * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
- * @method bottom
- * @return {Number}
- **/
- get bottom(): number {
- return this.y + this.height;
- }
-
- /**
- * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
- * @method bottom
- * @param {Number} value
- **/
- set bottom(value: number) {
-
- if (value <= this.y)
- {
- this.height = 0;
- }
- else
- {
- this.height = (this.y - value);
- }
-
- }
-
- /**
- * Sets the bottom-right corner of the Rectangle, determined by the values of the given Point object.
- * @method bottomRight
- * @param {Point} value
- **/
- set bottomRight(value: Point) {
-
- this.right = value.x;
- this.bottom = value.y;
-
- }
-
- /**
- * The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property.
- * @method left
- * @ return {number}
- **/
- get left(): number {
- return this.x;
- }
-
- /**
- * The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties.
- * However it does affect the width, whereas changing the x value does not affect the width property.
- * @method left
- * @param {Number} value
- **/
- set left(value: number) {
-
- if (value >= this.right)
- {
- this.width = 0;
- }
- else
- {
- this.width = this.right - value;
- }
-
- this.x = value;
-
- }
-
- /**
- * The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties.
- * However it does affect the width property.
- * @method right
- * @return {Number}
- **/
- get right(): number {
- return this.x + this.width;
- }
-
- /**
- * The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties.
- * However it does affect the width property.
- * @method right
- * @param {Number} value
- **/
- set right(value: number) {
-
- if (value <= this.x)
- {
- this.width = 0;
- }
- else
- {
- this.width = this.x + value;
- }
-
- }
-
- /**
- * The volume of the Rectangle derived from width * height
- * @method volume
- * @return {Number}
- **/
- get volume(): number {
- return this.width * this.height;
- }
-
- /**
- * The perimeter size of the Rectangle. This is the sum of all 4 sides.
- * @method perimeter
- * @return {Number}
- **/
- get perimeter(): number {
- return (this.width * 2) + (this.height * 2);
- }
-
- /**
- * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties.
- * However it does affect the height property, whereas changing the y value does not affect the height property.
- * @method top
- * @return {Number}
- **/
- get top(): number {
- return this.y;
- }
-
- /**
- * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties.
- * However it does affect the height property, whereas changing the y value does not affect the height property.
- * @method top
- * @param {Number} value
- **/
- set top(value: number) {
-
- if (value >= this.bottom)
- {
- this.height = 0;
- this.y = value;
- }
- else
- {
- this.height = (this.bottom - value);
- }
-
- }
-
- /**
- * The location of the Rectangles top-left corner, determined by the x and y coordinates of the Point.
- * @method topLeft
- * @param {Point} value
- **/
- set topLeft(value: Point) {
-
- this.x = value.x;
- this.y = value.y;
-
- }
-
- /**
- * Determines whether or not this Rectangle object is empty.
- * @method isEmpty
- * @return {bool} A value of true if the Rectangle objects width or height is less than or equal to 0; otherwise false.
- **/
- get empty(): bool {
- return (!this.width || !this.height);
- }
-
- /**
- * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0.
- * @method setEmpty
- * @return {Rectangle} This Rectangle object
- **/
- set empty(value: bool) {
- this.setTo(0, 0, 0, 0);
- }
-
- /**
- * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
- * @method offset
- * @param {Number} dx Moves the x value of the Rectangle object by this amount.
- * @param {Number} dy Moves the y value of the Rectangle object by this amount.
- * @return {Rectangle} This Rectangle object.
- **/
- offset(dx: number, dy: number): Rectangle {
-
- this.x += dx;
- this.y += dy;
-
- return this;
-
- }
-
- /**
- * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.
- * @method offsetPoint
- * @param {Point} point A Point object to use to offset this Rectangle object.
- * @return {Rectangle} This Rectangle object.
- **/
- offsetPoint(point: Point): Rectangle {
- return this.offset(point.x, point.y);
- }
-
- /**
- * Sets the members of Rectangle to the specified values.
- * @method setTo
- * @param {Number} x The x coordinate of the top-left corner of the Rectangle.
- * @param {Number} y The y coordinate of the top-left corner of the Rectangle.
- * @param {Number} width The width of the Rectangle in pixels.
- * @param {Number} height The height of the Rectangle in pixels.
- * @return {Rectangle} This Rectangle object
- **/
- setTo(x: number, y: number, width: number, height: number): Rectangle {
-
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
-
- return this;
-
- }
-
- /**
- * Runs Math.floor() on both the x and y values of this Rectangle.
- * @method floor
- **/
- public floor() {
-
- this.x = Math.floor(this.x);
- this.y = Math.floor(this.y);
-
- }
-
- /**
- * Copies the x, y, width and height properties from any given object to this Rectangle.
- * @method copyFrom
- * @param {any} source - The object to copy from.
- * @return {Rectangle} This Rectangle object.
- **/
- public copyFrom(source: any): Rectangle {
- return this.setTo(source.x, source.y, source.width, source.height);
- }
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {string} a string representation of the instance.
- **/
- toString(): string {
- return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]";
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/input/InputHandler.ts b/wip/TS Source/input/InputHandler.ts
deleted file mode 100644
index d9a3b7fa..00000000
--- a/wip/TS Source/input/InputHandler.ts
+++ /dev/null
@@ -1,732 +0,0 @@
-///
-
-/**
-* Phaser - Components - InputHandler
-*
-* Input detection component
-*/
-
-module Phaser.Components {
-
- export class InputHandler {
-
- /**
- * Sprite Input component constructor
- * @param parent The Sprite using this Input component
- */
- constructor(parent: Phaser.Sprite) {
-
- this.game = parent.game;
- this._parent = parent;
- this.enabled = false;
-
- }
-
- /**
- * Reference to Phaser.Game
- */
- public game: Phaser.Game;
-
- /**
- * Local private reference to its parent game object.
- */
- private _parent: Phaser.Sprite;
-
- private _pointerData;
-
- /**
- * If enabled the Input component will be updated by the parent Sprite
- * @type {bool}
- */
- public enabled: bool;
-
- /**
- * The PriorityID controls which Sprite receives an Input event first if they should overlap.
- */
- public priorityID: number = 0;
-
- /**
- * The index of this Input component entry in the Game.Input manager.
- */
- public indexID: number = 0;
-
- private _dragPoint: Point;
- private _draggedPointerID: number;
- public dragOffset: Point;
- public isDragged: bool = false;
- public dragFromCenter: bool;
- public dragPixelPerfect: bool = false;
- public dragPixelPerfectAlpha: number;
-
- public allowHorizontalDrag: bool = true;
- public allowVerticalDrag: bool = true;
- public bringToTop: bool = false;
-
- public snapOnDrag: bool = false;
- public snapOnRelease: bool = false;
- public snapOffset: Point;
- public snapX: number = 0;
- public snapY: number = 0;
-
-
- /**
- * Is this sprite allowed to be dragged by the mouse? true = yes, false = no
- * @default false
- */
- public draggable: bool = false;
-
- /**
- * A region of the game world within which the sprite is restricted during drag
- * @default null
- */
- public boundsRect: Rectangle = null;
-
- /**
- * An Sprite the bounds of which this sprite is restricted during drag
- * @default null
- */
- public boundsSprite: Phaser.Sprite = null;
-
- /**
- * The Input component can monitor either the physics body of the Sprite or the frameBounds
- * If checkBody is set to true it will monitor the bounds of the physics body.
- * @type {bool}
- */
- public checkBody: bool;
-
- /**
- * Turn the mouse pointer into a hand image by temporarily setting the CSS style of the Game canvas
- * on Input over. Only works on desktop browsers or browsers with a visible input pointer.
- * @type {bool}
- */
- public useHandCursor: bool;
-
- /**
- * If this object is set to consume the pointer event then it will stop all propogation from this object on.
- * For example if you had a stack of 6 sprites with the same priority IDs and one consumed the event, none of the others would receive it.
- * @type {bool}
- */
- public consumePointerEvent: bool = false;
-
- /**
- * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite.
- * This value is only set when the pointer is over this Sprite.
- * @type {number}
- */
- public pointerX(pointer: number = 0): number {
- return this._pointerData[pointer].x;
- }
-
- /**
- * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite
- * This value is only set when the pointer is over this Sprite.
- * @type {number}
- */
- public pointerY(pointer: number = 0): number {
- return this._pointerData[pointer].y;
- }
-
- /**
- * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true
- * @property isDown
- * @type {bool}
- **/
- public pointerDown(pointer: number = 0): bool {
- return this._pointerData[pointer].isDown;
- }
-
- /**
- * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
- * @property isUp
- * @type {bool}
- **/
- public pointerUp(pointer: number = 0): bool {
- return this._pointerData[pointer].isUp;
- }
-
- /**
- * A timestamp representing when the Pointer first touched the touchscreen.
- * @property timeDown
- * @type {Number}
- **/
- public pointerTimeDown(pointer: number = 0): bool {
- return this._pointerData[pointer].timeDown;
- }
-
- /**
- * A timestamp representing when the Pointer left the touchscreen.
- * @property timeUp
- * @type {Number}
- **/
- public pointerTimeUp(pointer: number = 0): bool {
- return this._pointerData[pointer].timeUp;
- }
-
- /**
- * Is the Pointer over this Sprite
- * @property isOver
- * @type {bool}
- **/
- public pointerOver(pointer: number = 0): bool {
- return this._pointerData[pointer].isOver;
- }
-
- /**
- * Is the Pointer outside of this Sprite
- * @property isOut
- * @type {bool}
- **/
- public pointerOut(pointer: number = 0): bool {
- return this._pointerData[pointer].isOut;
- }
-
- /**
- * A timestamp representing when the Pointer first touched the touchscreen.
- * @property timeDown
- * @type {Number}
- **/
- public pointerTimeOver(pointer: number = 0): bool {
- return this._pointerData[pointer].timeOver;
- }
-
- /**
- * A timestamp representing when the Pointer left the touchscreen.
- * @property timeUp
- * @type {Number}
- **/
- public pointerTimeOut(pointer: number = 0): bool {
- return this._pointerData[pointer].timeOut;
- }
-
- /**
- * Is this sprite being dragged by the mouse or not?
- * @default false
- */
- public pointerDragged(pointer: number = 0): bool {
- return this._pointerData[pointer].isDragged;
- }
-
- public start(priority: number = 0, checkBody: bool = false, useHandCursor: bool = false): Phaser.Sprite {
-
- // Turning on
- if (this.enabled == false)
- {
- // Register, etc
- this.checkBody = checkBody;
- this.useHandCursor = useHandCursor;
- this.priorityID = priority;
-
- this._pointerData = [];
-
- for (var i = 0; i < 10; i++)
- {
- this._pointerData.push({ id: i, x: 0, y: 0, isDown: false, isUp: false, isOver: false, isOut: false, timeOver: 0, timeOut: 0, timeDown: 0, timeUp: 0, downDuration: 0, isDragged: false });
- }
-
- this.snapOffset = new Point;
- this.enabled = true;
-
- this.game.input.addGameObject(this._parent);
-
- // Create the signals the Input component will emit
- if (this._parent.events.onInputOver == null)
- {
- this._parent.events.onInputOver = new Phaser.Signal;
- this._parent.events.onInputOut = new Phaser.Signal;
- this._parent.events.onInputDown = new Phaser.Signal;
- this._parent.events.onInputUp = new Phaser.Signal;
- this._parent.events.onDragStart = new Phaser.Signal;
- this._parent.events.onDragStop = new Phaser.Signal;
- }
- }
-
- return this._parent;
-
- }
-
- public reset() {
-
- this.enabled = false;
-
- for (var i = 0; i < 10; i++)
- {
- this._pointerData[i] = { id: i, x: 0, y: 0, isDown: false, isUp: false, isOver: false, isOut: false, timeOver: 0, timeOut: 0, timeDown: 0, timeUp: 0, downDuration: 0, isDragged: false };
- }
-
- }
-
- public stop() {
-
- // Turning off
- if (this.enabled == false)
- {
- return;
- }
- else
- {
- // De-register, etc
- this.enabled = false;
- this.game.input.removeGameObject(this.indexID);
- }
-
- }
-
- /**
- * Clean up memory.
- */
- public destroy() {
-
- if (this.enabled)
- {
- this.enabled = false;
- this.game.input.removeGameObject(this.indexID);
- }
-
- }
-
- /**
- * Checks if the given pointer is over this Sprite. All checks are done in world coordinates.
- */
- public checkPointerOver(pointer: Phaser.Pointer): bool {
-
- if (this.enabled == false || this._parent.visible == false)
- {
- return false;
- }
- else
- {
- //return SpriteUtils.overlapsXY(this._parent, pointer.worldX, pointer.worldY);
- //return SpriteUtils.overlapsXY(this._parent, pointer.screenX, pointer.screenY);
- return SpriteUtils.overlapsPointer(this._parent, pointer);
- }
-
- }
-
- /**
- * Update
- */
- public update(pointer: Phaser.Pointer): bool {
-
- if (this.enabled == false || this._parent.visible == false)
- {
- this._pointerOutHandler(pointer);
- return false;
- }
-
- if (this.draggable && this._draggedPointerID == pointer.id)
- {
- return this.updateDrag(pointer);
- }
- else if (this._pointerData[pointer.id].isOver == true)
- {
- //if (SpriteUtils.overlapsXY(this._parent, pointer.worldX, pointer.worldY))
- if (SpriteUtils.overlapsPointer(this._parent, pointer))
- {
- this._pointerData[pointer.id].x = pointer.x - this._parent.x;
- this._pointerData[pointer.id].y = pointer.y - this._parent.y;
- return true;
- }
- else
- {
- this._pointerOutHandler(pointer);
- return false;
- }
- }
-
- }
-
- public _pointerOverHandler(pointer: Pointer) {
-
- if (this._pointerData[pointer.id].isOver == false)
- {
- this._pointerData[pointer.id].isOver = true;
- this._pointerData[pointer.id].isOut = false;
- this._pointerData[pointer.id].timeOver = this.game.time.now;
- this._pointerData[pointer.id].x = pointer.x - this._parent.x;
- this._pointerData[pointer.id].y = pointer.y - this._parent.y;
-
- if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
- {
- this.game.stage.canvas.style.cursor = "pointer";
- }
-
- this._parent.events.onInputOver.dispatch(this._parent, pointer);
- }
-
- }
-
- public _pointerOutHandler(pointer: Pointer) {
-
- this._pointerData[pointer.id].isOver = false;
- this._pointerData[pointer.id].isOut = true;
- this._pointerData[pointer.id].timeOut = this.game.time.now;
-
- if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
- {
- this.game.stage.canvas.style.cursor = "default";
- }
-
- this._parent.events.onInputOut.dispatch(this._parent, pointer);
-
- }
-
- public _touchedHandler(pointer: Pointer): bool {
-
- if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true)
- {
- this._pointerData[pointer.id].isDown = true;
- this._pointerData[pointer.id].isUp = false;
- this._pointerData[pointer.id].timeDown = this.game.time.now;
-
- //console.log('touchedHandler: ' + Date.now());
- this._parent.events.onInputDown.dispatch(this._parent, pointer);
-
- // Start drag
- //if (this.draggable && this.isDragged == false && pointer.targetObject == null)
- if (this.draggable && this.isDragged == false)
- {
- this.startDrag(pointer);
- }
-
- if (this.bringToTop)
- {
- this._parent.bringToTop();
- //this._parent.game.world.group.bringToTop(this._parent);
- }
-
- }
-
- // Consume the event?
- return this.consumePointerEvent;
-
- }
-
- public _releasedHandler(pointer: Pointer) {
-
- // If was previously touched by this Pointer, check if still is AND still over this item
- if (this._pointerData[pointer.id].isDown && pointer.isUp)
- {
- this._pointerData[pointer.id].isDown = false;
- this._pointerData[pointer.id].isUp = true;
- this._pointerData[pointer.id].timeUp = this.game.time.now;
- this._pointerData[pointer.id].downDuration = this._pointerData[pointer.id].timeUp - this._pointerData[pointer.id].timeDown;
-
- // Only release the InputUp signal if the pointer is still over this sprite
- //if (SpriteUtils.overlapsXY(this._parent, pointer.worldX, pointer.worldY))
- if (SpriteUtils.overlapsPointer(this._parent, pointer))
- {
- //console.log('releasedHandler: ' + Date.now());
- this._parent.events.onInputUp.dispatch(this._parent, pointer);
- }
- else
- {
- // Pointer outside the sprite? Reset the cursor
- if (this.useHandCursor)
- {
- this.game.stage.canvas.style.cursor = "default";
- }
- }
-
- // Stop drag
- if (this.draggable && this.isDragged && this._draggedPointerID == pointer.id)
- {
- this.stopDrag(pointer);
- }
-
- }
-
- }
-
- /**
- * Updates the Pointer drag on this Sprite.
- */
- private updateDrag(pointer: Pointer): bool {
-
- if (pointer.isUp)
- {
- this.stopDrag(pointer);
- return false;
- }
-
- if (this.allowHorizontalDrag)
- {
- this._parent.x = pointer.x + this._dragPoint.x + this.dragOffset.x;
- }
-
- if (this.allowVerticalDrag)
- {
- this._parent.y = pointer.y + this._dragPoint.y + this.dragOffset.y;
- }
-
- if (this.boundsRect)
- {
- this.checkBoundsRect();
- }
-
- if (this.boundsSprite)
- {
- this.checkBoundsSprite();
- }
-
- if (this.snapOnDrag)
- {
- this._parent.x = Math.floor(this._parent.x / this.snapX) * this.snapX;
- this._parent.y = Math.floor(this._parent.y / this.snapY) * this.snapY;
- }
-
- return true;
- }
-
- /**
- * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @param delay The time below which the pointer is considered as just over.
- * @returns {bool}
- */
- public justOver(pointer: number = 0, delay: number = 500): bool {
- return (this._pointerData[pointer].isOver && this.overDuration(pointer) < delay);
- }
-
- /**
- * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @param delay The time below which the pointer is considered as just out.
- * @returns {bool}
- */
- public justOut(pointer: number = 0, delay: number = 500): bool {
- return (this._pointerData[pointer].isOut && (this.game.time.now - this._pointerData[pointer].timeOut < delay));
- }
-
- /**
- * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @param delay The time below which the pointer is considered as just over.
- * @returns {bool}
- */
- public justPressed(pointer: number = 0, delay: number = 500): bool {
- return (this._pointerData[pointer].isDown && this.downDuration(pointer) < delay);
- }
-
- /**
- * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @param delay The time below which the pointer is considered as just out.
- * @returns {bool}
- */
- public justReleased(pointer: number = 0, delay: number = 500): bool {
- return (this._pointerData[pointer].isUp && (this.game.time.now - this._pointerData[pointer].timeUp < delay));
- }
-
- /**
- * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
- * @returns {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over.
- */
- public overDuration(pointer: number = 0): number {
-
- if (this._pointerData[pointer].isOver)
- {
- return this.game.time.now - this._pointerData[pointer].timeOver;
- }
-
- return -1;
-
- }
-
- /**
- * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
- * @returns {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over.
- */
- public downDuration(pointer: number = 0): number {
-
- if (this._pointerData[pointer].isDown)
- {
- return this.game.time.now - this._pointerData[pointer].timeDown;
- }
-
- return -1;
-
- }
-
- /**
- * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback
- *
- * @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer.
- * @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group.
- * @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.
- * @param alphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)
- * @param boundsRect If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere
- * @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here
- */
- public enableDrag(lockCenter: bool = false, bringToTop: bool = false, pixelPerfect: bool = false, alphaThreshold: number = 255, boundsRect: Rectangle = null, boundsSprite: Phaser.Sprite = null) {
-
- this._dragPoint = new Point;
-
- this.draggable = true;
- this.bringToTop = bringToTop;
-
- this.dragOffset = new Point;
- this.dragFromCenter = lockCenter;
- this.dragPixelPerfect = pixelPerfect;
- this.dragPixelPerfectAlpha = alphaThreshold;
-
- if (boundsRect)
- {
- this.boundsRect = boundsRect;
- }
-
- if (boundsSprite)
- {
- this.boundsSprite = boundsSprite;
- }
-
- }
-
- /**
- * Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.
- */
- public disableDrag() {
-
- if (this._pointerData)
- {
- for (var i = 0; i < 10; i++)
- {
- this._pointerData[i].isDragged = false;
- }
- }
-
- this.draggable = false;
- this.isDragged = false;
- this._draggedPointerID = -1;
-
- }
-
- /**
- * Called by Pointer when drag starts on this Sprite. Should not usually be called directly.
- */
- public startDrag(pointer: Pointer) {
-
- this.isDragged = true;
- this._draggedPointerID = pointer.id;
- this._pointerData[pointer.id].isDragged = true;
-
- if (this.dragFromCenter)
- {
- this._parent.transform.centerOn(pointer.worldX, pointer.worldY);
- this._dragPoint.setTo(this._parent.x - pointer.x, this._parent.y - pointer.y);
- }
- else
- {
- this._dragPoint.setTo(this._parent.x - pointer.x, this._parent.y - pointer.y);
- }
-
- this.updateDrag(pointer);
-
- if (this.bringToTop)
- {
- this._parent.bringToTop();
- }
-
- this._parent.events.onDragStart.dispatch(this._parent, pointer);
-
- }
-
- /**
- * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.
- */
- public stopDrag(pointer: Pointer) {
-
- this.isDragged = false;
- this._draggedPointerID = -1;
- this._pointerData[pointer.id].isDragged = false;
-
- if (this.snapOnRelease)
- {
- this._parent.x = Math.floor(this._parent.x / this.snapX) * this.snapX;
- this._parent.y = Math.floor(this._parent.y / this.snapY) * this.snapY;
- }
-
- this._parent.events.onDragStop.dispatch(this._parent, pointer);
- this._parent.events.onInputUp.dispatch(this._parent, pointer);
-
- }
-
- /**
- * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!
- *
- * @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false
- * @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false
- */
- public setDragLock(allowHorizontal: bool = true, allowVertical: bool = true) {
- this.allowHorizontalDrag = allowHorizontal;
- this.allowVerticalDrag = allowVertical;
- }
-
- /**
- * Make this Sprite snap to the given grid either during drag or when it's released.
- * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels.
- *
- * @param snapX The width of the grid cell in pixels
- * @param snapY The height of the grid cell in pixels
- * @param onDrag If true the sprite will snap to the grid while being dragged
- * @param onRelease If true the sprite will snap to the grid when released
- */
- public enableSnap(snapX: number, snapY: number, onDrag: bool = true, onRelease: bool = false) {
- this.snapOnDrag = onDrag;
- this.snapOnRelease = onRelease;
- this.snapX = snapX;
- this.snapY = snapY;
- }
-
- /**
- * Stops the sprite from snapping to a grid during drag or release.
- */
- public disableSnap() {
- this.snapOnDrag = false;
- this.snapOnRelease = false;
- }
-
- /**
- * Bounds Rect check for the sprite drag
- */
- private checkBoundsRect() {
- if (this._parent.x < this.boundsRect.left)
- {
- this._parent.x = this.boundsRect.x;
- }
- else if ((this._parent.x + this._parent.width) > this.boundsRect.right)
- {
- this._parent.x = this.boundsRect.right - this._parent.width;
- }
-
- if (this._parent.y < this.boundsRect.top)
- {
- this._parent.y = this.boundsRect.top;
- }
- else if ((this._parent.y + this._parent.height) > this.boundsRect.bottom)
- {
- this._parent.y = this.boundsRect.bottom - this._parent.height;
- }
- }
-
- /**
- * Parent Sprite Bounds check for the sprite drag
- */
- private checkBoundsSprite() {
- if (this._parent.x < this.boundsSprite.x)
- {
- this._parent.x = this.boundsSprite.x;
- }
- else if ((this._parent.x + this._parent.width) > (this.boundsSprite.x + this.boundsSprite.width))
- {
- this._parent.x = (this.boundsSprite.x + this.boundsSprite.width) - this._parent.width;
- }
-
- if (this._parent.y < this.boundsSprite.y)
- {
- this._parent.y = this.boundsSprite.y;
- }
- else if ((this._parent.y + this._parent.height) > (this.boundsSprite.y + this.boundsSprite.height))
- {
- this._parent.y = (this.boundsSprite.y + this.boundsSprite.height) - this._parent.height;
- }
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/input/InputManager.ts b/wip/TS Source/input/InputManager.ts
deleted file mode 100644
index ff00787e..00000000
--- a/wip/TS Source/input/InputManager.ts
+++ /dev/null
@@ -1,840 +0,0 @@
-///
-
-/**
-* Phaser - InputManager
-*
-* A game specific Input manager that looks after the mouse, keyboard and touch objects.
-* This is updated by the core game loop.
-*/
-
-module Phaser {
-
- export class InputManager {
-
- constructor(game: Game) {
-
- this.game = game;
-
- this.mousePointer = new Pointer(this.game, 0);
- this.pointer1 = new Pointer(this.game, 1);
- this.pointer2 = new Pointer(this.game, 2);
-
- this.mouse = new Mouse(this.game);
- this.keyboard = new Keyboard(this.game);
- this.touch = new Touch(this.game);
- this.mspointer = new MSPointer(this.game);
- //this.gestures = new Gestures(this.game);
-
- this.onDown = new Phaser.Signal();
- this.onUp = new Phaser.Signal();
- this.onTap = new Phaser.Signal();
- this.onHold = new Phaser.Signal();
-
- this.scale = new Vec2(1, 1);
- this.speed = new Vec2;
- this.position = new Vec2;
- this._oldPosition = new Vec2;
- this.circle = new Circle(0, 0, 44);
-
- this.activePointer = this.mousePointer;
- this.currentPointers = 0;
-
- this.hitCanvas = document.createElement('canvas');
- this.hitCanvas.width = 1;
- this.hitCanvas.height = 1;
- this.hitContext = this.hitCanvas.getContext('2d');
-
- }
-
- /**
- * Local reference to game.
- */
- public game: Phaser.Game;
-
- /**
- * How often should the input pointers be checked for updates?
- * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.
- * @type {number}
- */
- public pollRate: number = 0;
-
- private _pollCounter: number = 0;
-
- /**
- * A 1x1 sized canvas used for pixel-perfect checks
- * @type {HTMLCanvasElement}
- */
- public hitCanvas: HTMLCanvasElement;
-
- /**
- * The context of the 1x1 pixel check canvas
- * @type {CanvasRenderingContext2D}
- */
- public hitContext: CanvasRenderingContext2D;
-
- /**
- * A vector object representing the previous position of the Pointer.
- * @property vector
- * @type {Vec2}
- **/
- private _oldPosition: Vec2 = null;
-
- /**
- * X coordinate of the most recent Pointer event
- * @type {Number}
- * @private
- */
- private _x: number = 0;
-
- /**
- * X coordinate of the most recent Pointer event
- * @type {Number}
- * @private
- */
- private _y: number = 0;
-
- /**
- * You can disable all Input by setting Input.disabled = true. While set all new input related events will be ignored.
- * If you need to disable just one type of input, for example mouse, use Input.mouse.disabled = true instead
- * @type {bool}
- */
- public disabled: bool = false;
-
- /**
- * Controls the expected behaviour when using a mouse and touch together on a multi-input device
- */
- public multiInputOverride: number = InputManager.MOUSE_TOUCH_COMBINE;
-
- /**
- * Static defining the behaviour expected on a multi-input device system.
- * With this setting when the mouse is used it updates the Input.x/y globals regardless if another pointer is active or not
- */
- public static MOUSE_OVERRIDES_TOUCH: number = 0;
-
- /**
- * Static defining the behaviour expected on a multi-input device system.
- * With this setting when the mouse is used it only updates the Input.x/y globals if no other pointer is active
- */
- public static TOUCH_OVERRIDES_MOUSE: number = 1;
-
- /**
- * Static defining the behaviour expected on a multi-input device system.
- * With this setting when the mouse is used it updates the Input.x/y globals at the same time as any active Pointer objects might
- */
- public static MOUSE_TOUCH_COMBINE: number = 2;
-
- /**
- * The camera being used for mouse and touch based pointers to calculate their world coordinates.
- * This is only ever the camera set by the most recently active Pointer.
- * If you need to know exactly which camera a specific Pointer is over then see Pointer.camera instead.
- * @property camera
- * @type {Camera}
- **/
- public get camera(): Camera {
- return this.activePointer.camera;
- }
-
- /**
- * Phaser.Mouse handler
- * @type {Mouse}
- */
- public mouse: Mouse;
-
- /**
- * Phaser.Keyboard handler
- * @type {Keyboard}
- */
- public keyboard: Keyboard;
-
- /**
- * Phaser.Touch handler
- * @type {Touch}
- */
- public touch: Touch;
-
- /**
- * Phaser.MSPointer handler
- * @type {MSPointer}
- */
- public mspointer: MSPointer;
-
- /**
- * Phaser.Gestures handler
- * @type {Gestures}
- */
- //public gestures: Gestures;
-
- /**
- * A vector object representing the current position of the Pointer.
- * @property vector
- * @type {Vec2}
- **/
- public position: Vec2 = null;
-
- /**
- * A vector object representing the speed of the Pointer. Only really useful in single Pointer games,
- * otherwise see the Pointer objects directly.
- * @property vector
- * @type {Vec2}
- **/
- public speed: Vec2 = null;
-
- /**
- * A Circle object centered on the x/y screen coordinates of the Input.
- * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything
- * @property circle
- * @type {Circle}
- **/
- public circle: Circle = null;
-
- /**
- * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode.
- * In an un-scaled game the values will be x: 1 and y: 1.
- * @type {Vec2}
- */
- public scale: Vec2 = null;
-
- /**
- * The maximum number of Pointers allowed to be active at any one time.
- * For lots of games it's useful to set this to 1
- * @type {Number}
- */
- public maxPointers: number = 10;
-
- /**
- * The current number of active Pointers.
- * @type {Number}
- */
- public currentPointers: number = 0;
-
- /**
- * A Signal dispatched when a mouse/Pointer object is pressed
- * @type {Phaser.Signal}
- */
- public onDown: Phaser.Signal;
-
- /**
- * A Signal dispatched when a mouse/Pointer object is released
- * @type {Phaser.Signal}
- */
- public onUp: Phaser.Signal;
-
- /**
- * A Signal dispatched when a Pointer object (including the mouse) is tapped: pressed and released quickly.
- * The signal sends 2 parameters. The Pointer that caused it and a bool depending if the tap was a single tap or a double tap.
- * @type {Phaser.Signal}
- */
- public onTap: Phaser.Signal;
-
- /**
- * A Signal dispatched when a Pointer object (including the mouse) is held down
- * @type {Phaser.Signal}
- */
- public onHold: Phaser.Signal;
-
- /**
- * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click
- * @property tapRate
- * @type {Number}
- **/
- public tapRate: number = 200;
-
- /**
- * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click
- * @property doubleTapRate
- * @type {Number}
- **/
- public doubleTapRate: number = 300;
-
- /**
- * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
- * @property holdRate
- * @type {Number}
- **/
- public holdRate: number = 2000;
-
- /**
- * The number of milliseconds below which the Pointer is considered justPressed
- * @property justPressedRate
- * @type {Number}
- **/
- public justPressedRate: number = 200;
-
- /**
- * The number of milliseconds below which the Pointer is considered justReleased
- * @property justReleasedRate
- * @type {Number}
- **/
- public justReleasedRate: number = 200;
-
- /**
- * Sets if the Pointer objects should record a history of x/y coordinates they have passed through.
- * The history is cleared each time the Pointer is pressed down.
- * The history is updated at the rate specified in Input.pollRate
- * @property recordPointerHistory
- * @type {bool}
- **/
- public recordPointerHistory: bool = false;
-
- /**
- * The rate in milliseconds at which the Pointer objects should update their tracking history
- * @property recordRate
- * @type {Number}
- */
- public recordRate: number = 100;
-
- /**
- * The total number of entries that can be recorded into the Pointer objects tracking history.
- * If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.
- * @property recordLimit
- * @type {Number}
- */
- public recordLimit: number = 100;
-
- /**
- * A Pointer object specifically used by the Mouse
- * @property mousePointer
- * @type {Pointer}
- **/
- public mousePointer: Pointer;
-
- /**
- * A Pointer object
- * @property pointer1
- * @type {Pointer}
- **/
- public pointer1: Pointer;
-
- /**
- * A Pointer object
- * @property pointer2
- * @type {Pointer}
- **/
- public pointer2: Pointer;
-
- /**
- * A Pointer object
- * @property pointer3
- * @type {Pointer}
- **/
- public pointer3: Pointer = null;
-
- /**
- * A Pointer object
- * @property pointer4
- * @type {Pointer}
- **/
- public pointer4: Pointer = null;
-
- /**
- * A Pointer object
- * @property pointer5
- * @type {Pointer}
- **/
- public pointer5: Pointer = null;
-
- /**
- * A Pointer object
- * @property pointer6
- * @type {Pointer}
- **/
- public pointer6: Pointer = null;
-
- /**
- * A Pointer object
- * @property pointer7
- * @type {Pointer}
- **/
- public pointer7: Pointer = null;
-
- /**
- * A Pointer object
- * @property pointer8
- * @type {Pointer}
- **/
- public pointer8: Pointer = null;
-
- /**
- * A Pointer object
- * @property pointer9
- * @type {Pointer}
- **/
- public pointer9: Pointer = null;
-
- /**
- * A Pointer object
- * @property pointer10
- * @type {Pointer}
- **/
- public pointer10: Pointer = null;
-
- /**
- * The most recently active Pointer object.
- * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.
- * @property activePointer
- * @type {Pointer}
- **/
- public activePointer: Pointer = null;
-
- public inputObjects = [];
-
- public totalTrackedObjects: number = 0;
-
- /**
- * The X coordinate of the most recently active pointer.
- * This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
- * @property x
- * @type {Number}
- **/
- public get x(): number {
- return this._x;
- }
-
- public set x(value: number) {
- this._x = Math.floor(value);
- }
-
- /**
- * The Y coordinate of the most recently active pointer.
- * This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.
- * @property y
- * @type {Number}
- **/
- public get y(): number {
- return this._y;
- }
-
- public set y(value: number) {
- this._y = Math.floor(value);
- }
-
- /**
- * Add a new Pointer object to the Input Manager. By default Input creates 2 pointer objects for you. If you need more
- * use this to create a new one, up to a maximum of 10.
- * @method addPointer
- * @return {Pointer} A reference to the new Pointer object
- **/
- public addPointer(): Pointer {
-
- var next: number = 0;
-
- for (var i = 10; i > 0; i--)
- {
- if (this['pointer' + i] === null)
- {
- next = i;
- }
- }
-
- if (next == 0)
- {
- throw new Error("You can only have 10 Pointer objects");
- return null;
- }
- else
- {
- this['pointer' + next] = new Pointer(this.game, next);
- return this['pointer' + next];
- }
-
- }
-
- /**
- * Starts the Input Manager running
- * @method start
- **/
- public boot() {
-
- this.mouse.start();
- this.keyboard.start();
- this.touch.start();
- this.mspointer.start();
- //this.gestures.start();
-
- this.mousePointer.active = true;
-
- }
-
- /**
- * Adds a new game object to be tracked by the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
- * @method addGameObject
- **/
- public addGameObject(object) {
-
- // Find a spare slot
- for (var i = 0; i < this.inputObjects.length; i++)
- {
- if (this.inputObjects[i] == null)
- {
- this.inputObjects[i] = object;
- object.input.indexID = i;
- this.totalTrackedObjects++;
- return;
- }
- }
-
- // If we got this far we need to push a new entry into the array
- object.input.indexID = this.inputObjects.length;
-
- this.inputObjects.push(object);
-
- this.totalTrackedObjects++;
-
- }
-
- /**
- * Removes a game object from the Input Manager. Called by the Sprite.Input component, should not usually be called directly.
- * @method removeGameObject
- **/
- public removeGameObject(index: number) {
-
- if (this.inputObjects[index])
- {
- this.inputObjects[index] = null;
- }
-
- }
-
- public get pollLocked(): bool {
- return (this.pollRate > 0 && this._pollCounter < this.pollRate);
- }
-
- /**
- * Updates the Input Manager. Called by the core Game loop.
- * @method update
- **/
- public update() {
-
- if (this.pollRate > 0 && this._pollCounter < this.pollRate)
- {
- this._pollCounter++;
- return;
- }
-
- this.speed.x = this.position.x - this._oldPosition.x;
- this.speed.y = this.position.y - this._oldPosition.y;
-
- this._oldPosition.copyFrom(this.position);
-
- this.mousePointer.update();
- this.pointer1.update();
- this.pointer2.update();
-
- if (this.pointer3) { this.pointer3.update(); }
- if (this.pointer4) { this.pointer4.update(); }
- if (this.pointer5) { this.pointer5.update(); }
- if (this.pointer6) { this.pointer6.update(); }
- if (this.pointer7) { this.pointer7.update(); }
- if (this.pointer8) { this.pointer8.update(); }
- if (this.pointer9) { this.pointer9.update(); }
- if (this.pointer10) { this.pointer10.update(); }
-
- this._pollCounter = 0;
-
- }
-
- /**
- * Reset all of the Pointers and Input states
- * @method reset
- * @param hard {bool} A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will.
- **/
- public reset(hard: bool = false) {
-
- this.keyboard.reset();
-
- this.mousePointer.reset();
-
- for (var i = 1; i <= 10; i++)
- {
- if (this['pointer' + i])
- {
- this['pointer' + i].reset();
- }
- }
-
- this.currentPointers = 0;
-
- this.game.stage.canvas.style.cursor = "default";
-
- if (hard == true)
- {
- this.onDown.dispose();
- this.onUp.dispose();
- this.onTap.dispose();
- this.onHold.dispose();
-
- this.onDown = new Phaser.Signal();
- this.onUp = new Phaser.Signal();
- this.onTap = new Phaser.Signal();
- this.onHold = new Phaser.Signal();
-
- for (var i = 0; i < this.totalTrackedObjects; i++)
- {
- if (this.inputObjects[i] && this.inputObjects[i].input)
- {
- this.inputObjects[i].input.reset();
- }
- }
-
- this.inputObjects.length = 0;
- this.totalTrackedObjects = 0;
- }
-
- this._pollCounter = 0;
-
- }
-
- public resetSpeed(x: number, y: number) {
- this._oldPosition.setTo(x, y);
- this.speed.setTo(0, 0);
- }
-
- /**
- * Get the total number of inactive Pointers
- * @method totalInactivePointers
- * @return {Number} The number of Pointers currently inactive
- **/
- public get totalInactivePointers(): number {
-
- return 10 - this.currentPointers;
-
- }
-
- /**
- * Recalculates the total number of active Pointers
- * @method totalActivePointers
- * @return {Number} The number of Pointers currently active
- **/
- public get totalActivePointers(): number {
-
- this.currentPointers = 0;
-
- for (var i = 1; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active)
- {
- this.currentPointers++;
- }
- }
-
- return this.currentPointers;
-
- }
-
- /**
- * Find the first free Pointer object and start it, passing in the event data.
- * @method startPointer
- * @param {Any} event The event data from the Touch event
- * @return {Pointer} The Pointer object that was started or null if no Pointer object is available
- **/
- public startPointer(event): Pointer {
-
- if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers)
- {
- return null;
- }
-
- // Unrolled for speed
- if (this.pointer1.active == false)
- {
- return this.pointer1.start(event);
- }
- else if (this.pointer2.active == false)
- {
- return this.pointer2.start(event);
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active == false)
- {
- return this['pointer' + i].start(event);
- }
- }
- }
-
- return null;
-
- }
-
- /**
- * Updates the matching Pointer object, passing in the event data.
- * @method updatePointer
- * @param {Any} event The event data from the Touch event
- * @return {Pointer} The Pointer object that was updated or null if no Pointer object is available
- **/
- public updatePointer(event): Pointer {
-
- // Unrolled for speed
- if (this.pointer1.active && this.pointer1.identifier == event.identifier)
- {
- return this.pointer1.move(event);
- }
- else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
- {
- return this.pointer2.move(event);
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
- {
- return this['pointer' + i].move(event);
- }
- }
- }
-
- return null;
-
- }
-
- /**
- * Stops the matching Pointer object, passing in the event data.
- * @method stopPointer
- * @param {Any} event The event data from the Touch event
- * @return {Pointer} The Pointer object that was stopped or null if no Pointer object is available
- **/
- public stopPointer(event): Pointer {
-
- // Unrolled for speed
- if (this.pointer1.active && this.pointer1.identifier == event.identifier)
- {
- return this.pointer1.stop(event);
- }
- else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
- {
- return this.pointer2.stop(event);
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
- {
- return this['pointer' + i].stop(event);
- }
- }
- }
-
- return null;
-
- }
-
- /**
- * Get the next Pointer object whos active property matches the given state
- * @method getPointer
- * @param {bool} state The state the Pointer should be in (false for inactive, true for active)
- * @return {Pointer} A Pointer object or null if no Pointer object matches the requested state.
- **/
- public getPointer(state: bool = false): Pointer {
-
- // Unrolled for speed
- if (this.pointer1.active == state)
- {
- return this.pointer1;
- }
- else if (this.pointer2.active == state)
- {
- return this.pointer2;
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active == state)
- {
- return this['pointer' + i];
- }
- }
- }
-
- return null;
-
- }
-
- /**
- * Get the Pointer object whos identified property matches the given identifier value
- * @method getPointerFromIdentifier
- * @param {Number} identifier The Pointer.identifier value to search for
- * @return {Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
- **/
- public getPointerFromIdentifier(identifier: number): Pointer {
-
- // Unrolled for speed
- if (this.pointer1.identifier == identifier)
- {
- return this.pointer1;
- }
- else if (this.pointer2.identifier == identifier)
- {
- return this.pointer2;
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].identifier == identifier)
- {
- return this['pointer' + i];
- }
- }
- }
-
- return null;
-
- }
-
- public get worldX(): number {
-
- if (this.camera)
- {
- return (this.camera.worldView.x - this.camera.screenView.x) + this.x;
- }
-
- return null;
-
- }
-
- public get worldY(): number {
-
- if (this.camera)
- {
- return (this.camera.worldView.y - this.camera.screenView.y) + this.y;
- }
-
- return null;
- }
-
- /**
- * Get the distance between two Pointer objects
- * @method getDistance
- * @param {Pointer} pointer1
- * @param {Pointer} pointer2
- **/
- public getDistance(pointer1: Pointer, pointer2: Pointer): number {
- return Vec2Utils.distance(pointer1.position, pointer2.position);
- }
-
- /**
- * Get the angle between two Pointer objects
- * @method getAngle
- * @param {Pointer} pointer1
- * @param {Pointer} pointer2
- **/
- public getAngle(pointer1: Pointer, pointer2: Pointer): number {
- return Vec2Utils.angle(pointer1.position, pointer2.position);
- }
-
- public pixelPerfectCheck(sprite: Phaser.Sprite, pointer: Phaser.Pointer, alpha: number = 255): bool {
-
- this.hitContext.clearRect(0, 0, 1, 1);
-
- return true;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/input/Keyboard.ts b/wip/TS Source/input/Keyboard.ts
deleted file mode 100644
index 84c11ba9..00000000
--- a/wip/TS Source/input/Keyboard.ts
+++ /dev/null
@@ -1,325 +0,0 @@
-///
-
-/**
-* Phaser - Keyboard
-*
-* The Keyboard class handles keyboard interactions with the game and the resulting events.
-* The avoid stealing all browser input we don't use event.preventDefault. If you would like to trap a specific key however
-* then use the addKeyCapture() method.
-*/
-
-module Phaser {
-
- export class Keyboard {
-
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- }
-
- /**
- * Local reference to game.
- * @property game
- * @type {Phaser.Game}
- **/
- public game: Phaser.Game;
-
- private _keys = {};
- private _capture = {};
-
- /**
- * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
- * @type {bool}
- */
- public disabled: bool = false;
-
- /**
- * A reference to the event handlers to allow removeEventListener support
- */
- public _onKeyDown;
- public _onKeyUp;
-
- public start() {
-
- this._onKeyDown = (event: KeyboardEvent) => this.onKeyDown(event);
- this._onKeyUp = (event: KeyboardEvent) => this.onKeyUp(event);
-
- document.body.addEventListener('keydown', this._onKeyDown , false);
- document.body.addEventListener('keyup', this._onKeyUp, false);
-
- }
-
- public stop() {
-
- document.body.removeEventListener('keydown', this._onKeyDown);
- document.body.removeEventListener('keyup', this._onKeyUp);
-
- }
-
- /**
- * By default when a key is pressed Phaser will not stop the event from propagating up to the browser.
- * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll.
- * You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser.
- * Pass in either a single keycode or an array of keycodes.
- * @param {Any} keycode
- */
- public addKeyCapture(keycode) {
-
- if (typeof keycode === 'object')
- {
- for (var i:number = 0; i < keycode.length; i++)
- {
- this._capture[keycode[i]] = true;
- }
- }
- else
- {
- this._capture[keycode] = true;
- }
-
- }
-
- /**
- * @param {Number} keycode
- */
- public removeKeyCapture(keycode: number) {
-
- delete this._capture[keycode];
-
- }
-
- public clearCaptures() {
-
- this._capture = {};
-
- }
-
- /**
- * @param {KeyboardEvent} event
- */
- public onKeyDown(event: KeyboardEvent) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- if (this._capture[event.keyCode])
- {
- event.preventDefault();
- }
-
- if (!this._keys[event.keyCode])
- {
- this._keys[event.keyCode] = { isDown: true, timeDown: this.game.time.now, timeUp: 0 };
- }
- else
- {
- this._keys[event.keyCode].isDown = true;
- this._keys[event.keyCode].timeDown = this.game.time.now;
- }
-
- }
-
- /**
- * @param {KeyboardEvent} event
- */
- public onKeyUp(event: KeyboardEvent) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- if (this._capture[event.keyCode])
- {
- event.preventDefault();
- }
-
- if (!this._keys[event.keyCode])
- {
- this._keys[event.keyCode] = { isDown: false, timeDown: 0, timeUp: this.game.time.now };
- }
- else
- {
- this._keys[event.keyCode].isDown = false;
- this._keys[event.keyCode].timeUp = this.game.time.now;
- }
-
- }
-
- public reset() {
-
- for (var key in this._keys)
- {
- this._keys[key].isDown = false;
- }
-
- }
-
- /**
- * @param {Number} keycode
- * @param {Number} [duration]
- * @return {bool}
- */
- public justPressed(keycode: number, duration: number = 250): bool {
-
- if (this._keys[keycode] && this._keys[keycode].isDown === true && (this.game.time.now - this._keys[keycode].timeDown < duration))
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- * @param {Number} keycode
- * @param {Number} [duration]
- * @return {bool}
- */
- public justReleased(keycode: number, duration: number = 250): bool {
-
- if (this._keys[keycode] && this._keys[keycode].isDown === false && (this.game.time.now - this._keys[keycode].timeUp < duration))
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- * @param {Number} keycode
- * @return {bool}
- */
- public isDown(keycode: number): bool {
-
- if (this._keys[keycode])
- {
- return this._keys[keycode].isDown;
- }
- else
- {
- return false;
- }
-
- }
-
- // Letters
- public static A: number = "A".charCodeAt(0);
- public static B: number = "B".charCodeAt(0);
- public static C: number = "C".charCodeAt(0);
- public static D: number = "D".charCodeAt(0);
- public static E: number = "E".charCodeAt(0);
- public static F: number = "F".charCodeAt(0);
- public static G: number = "G".charCodeAt(0);
- public static H: number = "H".charCodeAt(0);
- public static I: number = "I".charCodeAt(0);
- public static J: number = "J".charCodeAt(0);
- public static K: number = "K".charCodeAt(0);
- public static L: number = "L".charCodeAt(0);
- public static M: number = "M".charCodeAt(0);
- public static N: number = "N".charCodeAt(0);
- public static O: number = "O".charCodeAt(0);
- public static P: number = "P".charCodeAt(0);
- public static Q: number = "Q".charCodeAt(0);
- public static R: number = "R".charCodeAt(0);
- public static S: number = "S".charCodeAt(0);
- public static T: number = "T".charCodeAt(0);
- public static U: number = "U".charCodeAt(0);
- public static V: number = "V".charCodeAt(0);
- public static W: number = "W".charCodeAt(0);
- public static X: number = "X".charCodeAt(0);
- public static Y: number = "Y".charCodeAt(0);
- public static Z: number = "Z".charCodeAt(0);
-
- // Numbers
- public static ZERO: number = "0".charCodeAt(0);
- public static ONE: number = "1".charCodeAt(0);
- public static TWO: number = "2".charCodeAt(0);
- public static THREE: number = "3".charCodeAt(0);
- public static FOUR: number = "4".charCodeAt(0);
- public static FIVE: number = "5".charCodeAt(0);
- public static SIX: number = "6".charCodeAt(0);
- public static SEVEN: number = "7".charCodeAt(0);
- public static EIGHT: number = "8".charCodeAt(0);
- public static NINE: number = "9".charCodeAt(0);
-
- // Numpad
- public static NUMPAD_0: number = 96;
- public static NUMPAD_1: number = 97;
- public static NUMPAD_2: number = 98;
- public static NUMPAD_3: number = 99;
- public static NUMPAD_4: number = 100;
- public static NUMPAD_5: number = 101;
- public static NUMPAD_6: number = 102;
- public static NUMPAD_7: number = 103;
- public static NUMPAD_8: number = 104;
- public static NUMPAD_9: number = 105;
- public static NUMPAD_MULTIPLY: number = 106;
- public static NUMPAD_ADD: number = 107;
- public static NUMPAD_ENTER: number = 108;
- public static NUMPAD_SUBTRACT: number = 109;
- public static NUMPAD_DECIMAL: number = 110;
- public static NUMPAD_DIVIDE: number = 111;
-
- // Function Keys
- public static F1: number = 112;
- public static F2: number = 113;
- public static F3: number = 114;
- public static F4: number = 115;
- public static F5: number = 116;
- public static F6: number = 117;
- public static F7: number = 118;
- public static F8: number = 119;
- public static F9: number = 120;
- public static F10: number = 121;
- public static F11: number = 122;
- public static F12: number = 123;
- public static F13: number = 124;
- public static F14: number = 125;
- public static F15: number = 126;
-
- // Symbol Keys
- public static COLON: number = 186;
- public static EQUALS: number = 187;
- public static UNDERSCORE: number = 189;
- public static QUESTION_MARK: number = 191;
- public static TILDE: number = 192;
- public static OPEN_BRACKET: number = 219;
- public static BACKWARD_SLASH: number = 220;
- public static CLOSED_BRACKET: number = 221;
- public static QUOTES: number = 222;
-
- // Other Keys
- public static BACKSPACE: number = 8;
- public static TAB: number = 9;
- public static CLEAR: number = 12;
- public static ENTER: number = 13;
- public static SHIFT: number = 16;
- public static CONTROL: number = 17;
- public static ALT: number = 18;
- public static CAPS_LOCK: number = 20;
- public static ESC: number = 27;
- public static SPACEBAR: number = 32;
- public static PAGE_UP: number = 33;
- public static PAGE_DOWN: number = 34;
- public static END: number = 35;
- public static HOME: number = 36;
- public static LEFT: number = 37;
- public static UP: number = 38;
- public static RIGHT: number = 39;
- public static DOWN: number = 40;
- public static INSERT: number = 45;
- public static DELETE: number = 46;
- public static HELP: number = 47;
- public static NUM_LOCK: number = 144;
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/input/MSPointer.ts b/wip/TS Source/input/MSPointer.ts
deleted file mode 100644
index 1e97a980..00000000
--- a/wip/TS Source/input/MSPointer.ts
+++ /dev/null
@@ -1,139 +0,0 @@
-///
-
-/**
-* Phaser - MSPointer
-*
-* The MSPointer class handles touch interactions with the game and the resulting Pointer objects.
-* It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript.
-* http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx
-*/
-
-module Phaser {
-
- export class MSPointer {
-
- /**
- * Constructor
- * @param {Game} game.
- * @return {MSPointer} This object.
- */
- constructor(game: Game) {
-
- this.game = game;
-
- }
-
- /**
- * Local reference to game.
- * @property game
- * @type Game
- **/
- public game: Phaser.Game;
-
- /**
- * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
- * @type {bool}
- */
- public disabled: bool = false;
-
- /**
- * A reference to the event handlers to allow removeEventListener support
- */
- public _onMSPointerDown;
- public _onMSPointerMove;
- public _onMSPointerUp;
-
- /**
- * Starts the event listeners running
- * @method start
- */
- public start() {
-
- if (this.game.device.mspointer == true)
- {
- this._onMSPointerDown = (event) => this.onPointerDown(event);
- this._onMSPointerMove = (event) => this.onPointerMove(event);
- this._onMSPointerUp = (event) => this.onPointerUp(event);
-
- this.game.stage.canvas.addEventListener('MSPointerDown', this._onMSPointerDown, false);
- this.game.stage.canvas.addEventListener('MSPointerMove', this._onMSPointerMove, false);
- this.game.stage.canvas.addEventListener('MSPointerUp', this._onMSPointerUp, false);
- }
-
- }
-
- /**
- *
- * @method onPointerDown
- * @param {Any} event
- **/
- private onPointerDown(event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
- event.identifier = event.pointerId;
-
- this.game.input.startPointer(event);
-
- }
-
- /**
- *
- * @method onPointerMove
- * @param {Any} event
- **/
- private onPointerMove(event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
- event.identifier = event.pointerId;
-
- this.game.input.updatePointer(event);
-
- }
-
- /**
- *
- * @method onPointerUp
- * @param {Any} event
- **/
- private onPointerUp(event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
- event.identifier = event.pointerId;
-
- this.game.input.stopPointer(event);
-
- }
-
- /**
- * Stop the event listeners
- * @method stop
- */
- public stop() {
-
- if (this.game.device.mspointer == true)
- {
- this.game.stage.canvas.removeEventListener('MSPointerDown', this._onMSPointerDown);
- this.game.stage.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove);
- this.game.stage.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp);
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/input/Mouse.ts b/wip/TS Source/input/Mouse.ts
deleted file mode 100644
index 9e6cccbf..00000000
--- a/wip/TS Source/input/Mouse.ts
+++ /dev/null
@@ -1,152 +0,0 @@
-///
-
-/**
-* Phaser - Mouse
-*
-* The Mouse class handles mouse interactions with the game and the resulting events.
-*/
-
-module Phaser {
-
- export class Mouse {
-
- constructor(game: Game) {
-
- this.game = game;
- this.callbackContext = this.game;
-
- }
-
- /**
- * Local reference to game.
- * @property game
- * @type {Phaser.Game}
- **/
- public game: Phaser.Game;
-
- public static LEFT_BUTTON: number = 0;
- public static MIDDLE_BUTTON: number = 1;
- public static RIGHT_BUTTON: number = 2;
-
- /**
- * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
- * @type {bool}
- */
- public disabled: bool = false;
-
- /**
- * Custom callback useful for hooking into a 3rd party library. Will be passed the mouse event as the only parameter.
- * Callbacks are fired even if this component is disabled and before the event propagation is disabled.
- */
- public callbackContext;
- public mouseDownCallback = null;
- public mouseMoveCallback = null;
- public mouseUpCallback = null;
-
- /**
- * A reference to the event handlers to allow removeEventListener support
- */
- public _onMouseDown;
- public _onMouseMove;
- public _onMouseUp;
-
- /**
- * Starts the event listeners running
- * @method start
- */
- public start() {
-
- if (this.game.device.android && this.game.device.chrome == false)
- {
- // Android stock browser fires mouse events even if you preventDefault on the touchStart, so ...
- return;
- }
-
- this._onMouseDown = (event: MouseEvent) => this.onMouseDown(event);
- this._onMouseMove = (event: MouseEvent) => this.onMouseMove(event);
- this._onMouseUp = (event: MouseEvent) => this.onMouseUp(event);
-
- this.game.stage.canvas.addEventListener('mousedown', this._onMouseDown, true);
- this.game.stage.canvas.addEventListener('mousemove', this._onMouseMove, true);
- this.game.stage.canvas.addEventListener('mouseup', this._onMouseUp, true);
-
- }
-
- /**
- * @param {MouseEvent} event
- */
- public onMouseDown(event: MouseEvent) {
-
- if (this.mouseDownCallback)
- {
- this.mouseDownCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event['identifier'] = 0;
-
- this.game.input.mousePointer.start(event);
-
- }
-
- /**
- * @param {MouseEvent} event
- */
- public onMouseMove(event: MouseEvent) {
-
- if (this.mouseMoveCallback)
- {
- this.mouseMoveCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event['identifier'] = 0;
-
- this.game.input.mousePointer.move(event);
-
- }
-
- /**
- * @param {MouseEvent} event
- */
- public onMouseUp(event: MouseEvent) {
-
- if (this.mouseUpCallback)
- {
- this.mouseUpCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event['identifier'] = 0;
-
- this.game.input.mousePointer.stop(event);
-
- }
-
- /**
- * Stop the event listeners
- * @method stop
- */
- public stop() {
-
- this.game.stage.canvas.removeEventListener('mousedown', this._onMouseDown);
- this.game.stage.canvas.removeEventListener('mousemove', this._onMouseMove);
- this.game.stage.canvas.removeEventListener('mouseup', this._onMouseUp);
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/input/Pointer.ts b/wip/TS Source/input/Pointer.ts
deleted file mode 100644
index f0173324..00000000
--- a/wip/TS Source/input/Pointer.ts
+++ /dev/null
@@ -1,698 +0,0 @@
-///
-
-/**
-* Phaser - Pointer
-*
-* A Pointer object is used by the Touch and MSPoint managers and represents a single finger on the touch screen.
-*/
-
-module Phaser {
-
- export class Pointer {
-
- /**
- * Constructor
- * @param {Phaser.Game} game.
- * @return {Phaser.Pointer} This object.
- */
- constructor(game: Game, id: number) {
-
- this.game = game;
-
- this.id = id;
- this.active = false;
- this.position = new Vec2;
- this.positionDown = new Vec2;
- this.circle = new Circle(0, 0, 44);
-
- if (id == 0)
- {
- this.isMouse = true;
- }
-
- }
-
- private _highestRenderOrderID: number;
- private _highestRenderObject: number;
- private _highestInputPriorityID: number;
-
- /**
- * Local reference to Game.
- * @property game
- * @type {Phaser.Game}
- * @private
- **/
- public game: Phaser.Game;
-
- /**
- * Local private variable to store the status of dispatching a hold event
- * @property _holdSent
- * @type {bool}
- * @private
- */
- private _holdSent: bool = false;
-
- /**
- * Local private variable storing the short-term history of pointer movements
- * @property _history
- * @type {Array}
- * @private
- */
- private _history = [];
-
- /**
- * Local private variable storing the time at which the next history drop should occur
- * @property _lastDrop
- * @type {Number}
- * @private
- */
- private _nextDrop: number = 0;
-
- // Monitor events outside of a state reset loop
- private _stateReset: bool = false;
-
- /**
- * The Pointer ID (a number between 1 and 10, 0 is reserved for the mouse pointer specifically)
- * @property id
- * @type {Number}
- */
- public id: number;
-
- /**
- * An identification number for each touch point.
- * When a touch point becomes active, it is assigned an identifier that is distinct from any other active touch point.
- * While the touch point remains active, all events that refer to it are assigned the same identifier.
- * @property identifier
- * @type {Number}
- */
- public identifier: number;
-
- /**
- * Is this Pointer active or not? An active Pointer is one that is in contact with the touch screen.
- * @property active
- * @type {bool}
- */
- public active: bool;
-
- /**
- * A Vector object containing the initial position when the Pointer was engaged with the screen.
- * @property positionDown
- * @type {Vec2}
- **/
- public positionDown: Phaser.Vec2 = null;
-
- /**
- * A Vector object containing the current position of the Pointer on the screen.
- * @property position
- * @type {Vec2}
- **/
- public position: Phaser.Vec2 = null;
-
- /**
- * A Circle object centered on the x/y screen coordinates of the Pointer.
- * Default size of 44px (Apple's recommended "finger tip" size)
- * @property circle
- * @type {Circle}
- **/
- public circle: Phaser.Circle = null;
-
- /**
- *
- * @property withinGame
- * @type {bool}
- */
- public withinGame: bool = false;
-
- /**
- * If this Pointer is a mouse the button property holds the value of which mouse button was pressed down
- * @property button
- * @type {Number}
- */
- public button: number;
-
- /**
- * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset
- * @property clientX
- * @type {Number}
- */
- public clientX: number = -1;
-
- /**
- * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset
- * @property clientY
- * @type {Number}
- */
- public clientY: number = -1;
-
- /**
- * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset
- * @property pageX
- * @type {Number}
- */
- public pageX: number = -1;
-
- /**
- * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset
- * @property pageY
- * @type {Number}
- */
- public pageY: number = -1;
-
- /**
- * The horizontal coordinate of point relative to the screen in pixels
- * @property screenX
- * @type {Number}
- */
- public screenX: number = -1;
-
- /**
- * The vertical coordinate of point relative to the screen in pixels
- * @property screenY
- * @type {Number}
- */
- public screenY: number = -1;
-
- /**
- * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
- * @property x
- * @type {Number}
- */
- public x: number = -1;
-
- /**
- * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.
- * @property y
- * @type {Number}
- */
- public y: number = -1;
-
- /**
- * The Element on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element.
- * @property target
- * @type {Any}
- */
- public target;
-
- /**
- * If the Pointer is a mouse this is true, otherwise false
- * @property isMouse
- * @type {bool}
- **/
- public isMouse: bool = false;
-
- /**
- * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true
- * @property isDown
- * @type {bool}
- **/
- public isDown: bool = false;
-
- /**
- * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
- * @property isUp
- * @type {bool}
- **/
- public isUp: bool = true;
-
- /**
- * A timestamp representing when the Pointer first touched the touchscreen.
- * @property timeDown
- * @type {Number}
- **/
- public timeDown: number = 0;
-
- /**
- * A timestamp representing when the Pointer left the touchscreen.
- * @property timeUp
- * @type {Number}
- **/
- public timeUp: number = 0;
-
- /**
- * A timestamp representing when the Pointer was last tapped or clicked
- * @property previousTapTime
- * @type {Number}
- **/
- public previousTapTime: number = 0;
-
- /**
- * The total number of times this Pointer has been touched to the touchscreen
- * @property totalTouches
- * @type {Number}
- **/
- public totalTouches: number = 0;
-
- /**
- * The number of miliseconds since the last click
- * @property msSinceLastClick
- * @type {Number}
- **/
- public msSinceLastClick: number = Number.MAX_VALUE;
-
- /**
- * How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
- * @property duration
- * @type {Number}
- **/
- public get duration(): number {
-
- if (this.isUp)
- {
- return -1;
- }
-
- return this.game.time.now - this.timeDown;
-
- }
-
- /**
- * The Game Object this Pointer is currently over / touching / dragging.
- * @property targetObject
- * @type {Any}
- **/
- public targetObject = null;
-
- /**
- * The top-most Camera that this Pointer is over (if any, null if none).
- * If the Pointer is over several cameras that are stacked on-top of each other this is only ever set to the top-most rendered camera.
- * @property camera
- * @type {Phaser.Camera}
- **/
- public camera: Phaser.Camera = null;
-
- /**
- * Gets the X value of this Pointer in world coordinates based on the given camera.
- * @param {Camera} [camera]
- */
- public get worldX(): number {
-
- if (this.camera)
- {
- return (this.camera.worldView.x - this.camera.screenView.x) + this.x;
- }
-
- return null;
-
- }
-
- /**
- * Gets the Y value of this Pointer in world coordinates based on the given camera.
- * @param {Camera} [camera]
- */
- public get worldY(): number {
-
- if (this.camera)
- {
- return (this.camera.worldView.y - this.camera.screenView.y) + this.y;
- }
-
- return null;
- }
-
- /**
- * Called when the Pointer is pressed onto the touchscreen
- * @method start
- * @param {Any} event
- */
- public start(event): Pointer {
-
- this.identifier = event.identifier;
- this.target = event.target;
-
- if (event.button)
- {
- this.button = event.button;
- }
-
- // Fix to stop rogue browser plugins from blocking the visibility state event
- if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false)
- {
- this.game.stage.resumeGame();
- return this;
- }
-
- this._history.length = 0;
-
- this.active = true;
- this.withinGame = true;
- this.isDown = true;
- this.isUp = false;
-
- // Work out how long it has been since the last click
- this.msSinceLastClick = this.game.time.now - this.timeDown;
-
- this.timeDown = this.game.time.now;
-
- this._holdSent = false;
-
- // This sets the x/y and other local values
- this.move(event);
-
- // x and y are the old values here?
- this.positionDown.setTo(this.x, this.y);
-
- if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- //this.game.input.x = this.x * this.game.input.scale.x;
- //this.game.input.y = this.y * this.game.input.scale.y;
- this.game.input.x = this.x;
- this.game.input.y = this.y;
- this.game.input.position.setTo(this.x, this.y);
- this.game.input.onDown.dispatch(this);
- this.game.input.resetSpeed(this.x, this.y);
- }
-
- this._stateReset = false;
- this.totalTouches++;
-
- if (this.isMouse == false)
- {
- this.game.input.currentPointers++;
- }
-
- if (this.targetObject !== null)
- {
- this.targetObject.input._touchedHandler(this);
- }
-
- return this;
-
- }
-
- public update() {
-
- if (this.active)
- {
- if (this._holdSent == false && this.duration >= this.game.input.holdRate)
- {
- if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- this.game.input.onHold.dispatch(this);
- }
-
- this._holdSent = true;
- }
-
- // Update the droppings history
- if (this.game.input.recordPointerHistory && this.game.time.now >= this._nextDrop)
- {
- this._nextDrop = this.game.time.now + this.game.input.recordRate;
- this._history.push({ x: this.position.x, y: this.position.y });
-
- if (this._history.length > this.game.input.recordLimit)
- {
- this._history.shift();
- }
- }
-
- // Check which camera they are over
- this.camera = this.game.world.cameras.getCameraUnderPoint(this.x, this.y);
- }
-
- }
-
- /**
- * Called when the Pointer is moved on the touchscreen
- * @method move
- * @param {Any} event
- */
- public move(event): Pointer {
-
- if (this.game.input.pollLocked)
- {
- return;
- }
-
- if (event.button)
- {
- this.button = event.button;
- }
-
- this.clientX = event.clientX;
- this.clientY = event.clientY;
- this.pageX = event.pageX;
- this.pageY = event.pageY;
- this.screenX = event.screenX;
- this.screenY = event.screenY;
-
- this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x;
- this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y;
-
- this.position.setTo(this.x, this.y);
- this.circle.x = this.x;
- this.circle.y = this.y;
-
- if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- this.game.input.activePointer = this;
- this.game.input.x = this.x;
- this.game.input.y = this.y;
- this.game.input.position.setTo(this.game.input.x, this.game.input.y);
- this.game.input.circle.x = this.game.input.x;
- this.game.input.circle.y = this.game.input.y;
- }
-
- // If the game is paused we don't process any target objects
- if (this.game.paused)
- {
- return this;
- }
-
- // Easy out if we're dragging something and it still exists
- if (this.targetObject !== null && this.targetObject.input && this.targetObject.input.isDragged == true)
- {
- if (this.targetObject.input.update(this) == false)
- {
- this.targetObject = null;
- }
- return this;
- }
-
- // Work out which object is on the top
- this._highestRenderOrderID = -1;
- this._highestRenderObject = -1;
- this._highestInputPriorityID = -1;
-
- for (var i = 0; i < this.game.input.totalTrackedObjects; i++)
- {
- if (this.game.input.inputObjects[i] && this.game.input.inputObjects[i].input && this.game.input.inputObjects[i].input.checkPointerOver(this))
- {
- // If the object has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
- if (this.game.input.inputObjects[i].input.priorityID > this._highestInputPriorityID || (this.game.input.inputObjects[i].input.priorityID == this._highestInputPriorityID && this.game.input.inputObjects[i].renderOrderID > this._highestRenderOrderID))
- {
- this._highestRenderOrderID = this.game.input.inputObjects[i].renderOrderID;
- this._highestRenderObject = i;
- this._highestInputPriorityID = this.game.input.inputObjects[i].input.priorityID;
- }
- }
- }
-
- if (this._highestRenderObject == -1)
- {
- // The pointer isn't over anything, check if we've got a lingering previous target
- if (this.targetObject !== null)
- {
- this.targetObject.input._pointerOutHandler(this);
- this.targetObject = null;
- }
- }
- else
- {
- if (this.targetObject == null)
- {
- // And now set the new one
- this.targetObject = this.game.input.inputObjects[this._highestRenderObject];
- this.targetObject.input._pointerOverHandler(this);
- }
- else
- {
- // We've got a target from the last update
- if (this.targetObject == this.game.input.inputObjects[this._highestRenderObject])
- {
- // Same target as before, so update it
- if (this.targetObject.input.update(this) == false)
- {
- this.targetObject = null;
- }
- }
- else
- {
- // The target has changed, so tell the old one we've left it
- this.targetObject.input._pointerOutHandler(this);
-
- // And now set the new one
- this.targetObject = this.game.input.inputObjects[this._highestRenderObject];
- this.targetObject.input._pointerOverHandler(this);
- }
- }
- }
-
- return this;
-
- }
-
- /**
- * Called when the Pointer leaves the target area
- * @method leave
- * @param {Any} event
- */
- public leave(event) {
-
- this.withinGame = false;
- this.move(event);
-
- }
-
- /**
- * Called when the Pointer leaves the touchscreen
- * @method stop
- * @param {Any} event
- */
- public stop(event): Pointer {
-
- if (this._stateReset)
- {
- event.preventDefault();
- return;
- }
-
- this.timeUp = this.game.time.now;
-
- if (this.game.input.multiInputOverride == InputManager.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == InputManager.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == InputManager.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- this.game.input.onUp.dispatch(this);
-
- // Was it a tap?
- if (this.duration >= 0 && this.duration <= this.game.input.tapRate)
- {
- // Was it a double-tap?
- if (this.timeUp - this.previousTapTime < this.game.input.doubleTapRate)
- {
- // Yes, let's dispatch the signal then with the 2nd parameter set to true
- this.game.input.onTap.dispatch(this, true);
- }
- else
- {
- // Wasn't a double-tap, so dispatch a single tap signal
- this.game.input.onTap.dispatch(this, false);
- }
-
- this.previousTapTime = this.timeUp;
- }
-
- }
-
- // Mouse is always active
- if (this.id > 0)
- {
- this.active = false;
- }
-
- this.withinGame = false;
- this.isDown = false;
- this.isUp = true;
-
- if (this.isMouse == false)
- {
- this.game.input.currentPointers--;
- }
-
- for (var i = 0; i < this.game.input.totalTrackedObjects; i++)
- {
- if (this.game.input.inputObjects[i] && this.game.input.inputObjects[i].input && this.game.input.inputObjects[i].input.enabled)
- {
- this.game.input.inputObjects[i].input._releasedHandler(this);
- }
- }
-
- if (this.targetObject)
- {
- this.targetObject.input._releasedHandler(this);
- }
-
- this.targetObject = null;
-
- return this;
-
- }
-
- /**
- * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate
- * @method justPressed
- * @param {Number} [duration].
- * @return {bool}
- */
- public justPressed(duration: number = this.game.input.justPressedRate): bool {
-
- if (this.isDown === true && (this.timeDown + duration) > this.game.time.now)
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate
- * @method justReleased
- * @param {Number} [duration].
- * @return {bool}
- */
- public justReleased(duration: number = this.game.input.justReleasedRate): bool {
-
- if (this.isUp === true && (this.timeUp + duration) > this.game.time.now)
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- * Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
- * @method reset
- */
- public reset() {
-
- if (this.isMouse == false)
- {
- this.active = false;
- }
-
- this.identifier = null;
- this.isDown = false;
- this.isUp = true;
- this.totalTouches = 0;
- this._holdSent = false;
- this._history.length = 0;
- this._stateReset = true;
-
- if (this.targetObject && this.targetObject.input)
- {
- this.targetObject.input._releasedHandler(this);
- }
-
- this.targetObject = null;
-
- }
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {String} a string representation of the instance.
- **/
- public toString(): string {
-
- return "[{Pointer (id=" + this.id + " identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]";
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/input/Touch.ts b/wip/TS Source/input/Touch.ts
deleted file mode 100644
index e922110a..00000000
--- a/wip/TS Source/input/Touch.ts
+++ /dev/null
@@ -1,277 +0,0 @@
-///
-
-/**
-* Phaser - Touch
-*
-* The Touch class handles touch interactions with the game and the resulting Pointer objects.
-* http://www.w3.org/TR/touch-events/
-* https://developer.mozilla.org/en-US/docs/DOM/TouchList
-* http://www.html5rocks.com/en/mobile/touchandmouse/
-* Note: Android 2.x only supports 1 touch event at once, no multi-touch
-*/
-
-module Phaser {
-
- export class Touch {
-
- /**
- * Constructor
- * @param {Game} game.
- * @return {Touch} This object.
- */
- constructor(game: Game) {
-
- this.game = game;
- this.callbackContext = this.game;
-
- }
-
- /**
- * Local reference to game.
- * @property game
- * @type {Phaser.Game}
- **/
- public game: Phaser.Game;
-
- /**
- * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
- * @type {bool}
- */
- public disabled: bool = false;
-
- /**
- * Custom callback useful for hooking into a 3rd party library. Will be passed the touch event as the only parameter.
- * Callbacks are fired even if this component is disabled and before the event propogation is disabled.
- */
- public callbackContext;
- public touchStartCallback = null;
- public touchMoveCallback = null;
- public touchEndCallback = null;
- public touchEnterCallback = null;
- public touchLeaveCallback = null;
- public touchCancelCallback = null;
-
- /**
- * A reference to the event handlers to allow removeEventListener support
- */
- public _onTouchStart;
- public _onTouchMove;
- public _onTouchEnd;
- public _onTouchEnter;
- public _onTouchLeave;
- public _onTouchCancel;
- public _documentTouchMove;
-
- /**
- * Starts the event listeners running
- * @method start
- */
- public start() {
-
- if (this.game.device.touch)
- {
- this._onTouchStart = (event) => this.onTouchStart(event);
- this._onTouchMove = (event) => this.onTouchMove(event);
- this._onTouchEnd = (event) => this.onTouchEnd(event);
- this._onTouchEnter = (event) => this.onTouchEnter(event);
- this._onTouchLeave = (event) => this.onTouchLeave(event);
- this._onTouchCancel = (event) => this.onTouchCancel(event);
- this._documentTouchMove = (event) => this.consumeTouchMove(event);
-
- this.game.stage.canvas.addEventListener('touchstart', this._onTouchStart, false);
- this.game.stage.canvas.addEventListener('touchmove', this._onTouchMove, false);
- this.game.stage.canvas.addEventListener('touchend', this._onTouchEnd, false);
- this.game.stage.canvas.addEventListener('touchenter', this._onTouchEnter, false);
- this.game.stage.canvas.addEventListener('touchleave', this._onTouchLeave, false);
- this.game.stage.canvas.addEventListener('touchcancel', this._onTouchCancel, false);
-
- document.addEventListener('touchmove', this._documentTouchMove, false);
- }
-
- }
-
- /**
- * Prevent iOS bounce-back (doesn't work?)
- * @method consumeTouchMove
- * @param {Any} event
- **/
- private consumeTouchMove(event) {
- event.preventDefault();
- }
-
- /**
- *
- * @method onTouchStart
- * @param {Any} event
- **/
- private onTouchStart(event) {
-
- if (this.touchStartCallback)
- {
- this.touchStartCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
-
- // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
- // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
- // event.changedTouches = the touches that CHANGED in this event, not the total number of them
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.startPointer(event.changedTouches[i]);
- }
-
- }
-
- /**
- * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome)
- * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears
- * @method onTouchCancel
- * @param {Any} event
- **/
- private onTouchCancel(event) {
-
- if (this.touchCancelCallback)
- {
- this.touchCancelCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
-
- // Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome)
- // http://www.w3.org/TR/touch-events/#dfn-touchcancel
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.stopPointer(event.changedTouches[i]);
- }
-
- }
-
- /**
- * For touch enter and leave its a list of the touch points that have entered or left the target
- * Doesn't appear to be supported by most browsers yet
- * @method onTouchEnter
- * @param {Any} event
- **/
- private onTouchEnter(event) {
-
- if (this.touchEnterCallback)
- {
- this.touchEnterCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
-
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- //console.log('touch enter');
- }
-
- }
-
- /**
- * For touch enter and leave its a list of the touch points that have entered or left the target
- * Doesn't appear to be supported by most browsers yet
- * @method onTouchLeave
- * @param {Any} event
- **/
- private onTouchLeave(event) {
-
- if (this.touchLeaveCallback)
- {
- this.touchLeaveCallback.call(this.callbackContext, event);
- }
-
- event.preventDefault();
-
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- //console.log('touch leave');
- }
-
- }
-
- /**
- *
- * @method onTouchMove
- * @param {Any} event
- **/
- private onTouchMove(event) {
-
- if (this.touchMoveCallback)
- {
- this.touchMoveCallback.call(this.callbackContext, event);
- }
-
- event.preventDefault();
-
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.updatePointer(event.changedTouches[i]);
- }
-
- }
-
- /**
- *
- * @method onTouchEnd
- * @param {Any} event
- **/
- private onTouchEnd(event) {
-
- if (this.touchEndCallback)
- {
- this.touchEndCallback.call(this.callbackContext, event);
- }
-
- event.preventDefault();
-
- // For touch end its a list of the touch points that have been removed from the surface
- // https://developer.mozilla.org/en-US/docs/DOM/TouchList
-
- // event.changedTouches = the touches that CHANGED in this event, not the total number of them
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.stopPointer(event.changedTouches[i]);
- }
-
- }
-
- /**
- * Stop the event listeners
- * @method stop
- */
- public stop() {
-
- if (this.game.device.touch)
- {
- this.game.stage.canvas.removeEventListener('touchstart', this._onTouchStart);
- this.game.stage.canvas.removeEventListener('touchmove', this._onTouchMove);
- this.game.stage.canvas.removeEventListener('touchend', this._onTouchEnd);
- this.game.stage.canvas.removeEventListener('touchenter', this._onTouchEnter);
- this.game.stage.canvas.removeEventListener('touchleave', this._onTouchLeave);
- this.game.stage.canvas.removeEventListener('touchcancel', this._onTouchCancel);
-
- document.removeEventListener('touchmove', this._documentTouchMove);
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/loader/AnimationLoader.ts b/wip/TS Source/loader/AnimationLoader.ts
deleted file mode 100644
index cb08c032..00000000
--- a/wip/TS Source/loader/AnimationLoader.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-///
-
-/**
-* Phaser - AnimationLoader
-*
-* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
-*/
-
-module Phaser {
-
- export class AnimationLoader {
-
- /**
- * Parse a sprite sheet from asset data.
- * @param key {string} Asset key for the sprite sheet data.
- * @param frameWidth {number} Width of animation frame.
- * @param frameHeight {number} Height of animation frame.
- * @param frameMax {number} Number of animation frames.
- * @return {FrameData} Generated FrameData object.
- */
- public static parseSpriteSheet(game: Game, key: string, frameWidth: number, frameHeight: number, frameMax: number): FrameData {
-
- // How big is our image?
-
- var img = game.cache.getImage(key);
-
- if (img == null)
- {
- return null;
- }
-
- var width = img.width;
- var height = img.height;
-
- var row = Math.round(width / frameWidth);
- var column = Math.round(height / frameHeight);
- var total = row * column;
-
- if (frameMax !== -1)
- {
- total = frameMax;
- }
-
- // Zero or smaller than frame sizes?
- if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0)
- {
- throw new Error("AnimationLoader.parseSpriteSheet: width/height zero or width/height < given frameWidth/frameHeight");
- return null;
- }
-
- // Let's create some frames then
- var data: FrameData = new FrameData();
-
- var x = 0;
- var y = 0;
-
- for (var i = 0; i < total; i++)
- {
- data.addFrame(new Frame(x, y, frameWidth, frameHeight, ''));
-
- x += frameWidth;
-
- if (x === width)
- {
- x = 0;
- y += frameHeight;
- }
-
- }
-
- return data;
-
- }
-
- /**
- * Parse frame datas from json.
- * @param json {object} Json data you want to parse.
- * @return {FrameData} Generated FrameData object.
- */
- public static parseJSONData(game: Game, json): FrameData {
-
- // Malformed?
- if (!json['frames'])
- {
- console.log(json);
- throw new Error("Phaser.AnimationLoader.parseJSONData: Invalid Texture Atlas JSON given, missing 'frames' array");
- }
-
- // Let's create some frames then
- var data: FrameData = new FrameData();
-
- // By this stage frames is a fully parsed array
- var frames = json['frames'];
- var newFrame: Frame;
-
- for (var i = 0; i < frames.length; i++)
- {
- newFrame = data.addFrame(new Frame(
- frames[i].frame.x,
- frames[i].frame.y,
- frames[i].frame.w,
- frames[i].frame.h,
- frames[i].filename));
-
- newFrame.setTrim(
- frames[i].trimmed,
- frames[i].sourceSize.w,
- frames[i].sourceSize.h,
- frames[i].spriteSourceSize.x,
- frames[i].spriteSourceSize.y,
- frames[i].spriteSourceSize.w,
- frames[i].spriteSourceSize.h);
- }
-
- return data;
-
- }
-
- public static parseXMLData(game: Game, xml, format: number): FrameData {
-
- // Malformed?
- if (!xml.getElementsByTagName('TextureAtlas'))
- {
- throw new Error("Phaser.AnimationLoader.parseXMLData: Invalid Texture Atlas XML given, missing tag");
- }
-
- // Let's create some frames then
- var data: FrameData = new FrameData();
-
- var frames = xml.getElementsByTagName('SubTexture');
-
- var newFrame: Frame;
-
- for (var i = 0; i < frames.length; i++)
- {
- var frame = frames[i].attributes;
-
- newFrame = data.addFrame(new Frame(frame.x.nodeValue, frame.y.nodeValue, frame.width.nodeValue, frame.height.nodeValue, frame.name.nodeValue));
-
- // Trimmed?
- if (frame.frameX.nodeValue != '-0' || frame.frameY.nodeValue != '-0')
- {
- newFrame.setTrim(true, frame.width.nodeValue, frame.height.nodeValue, Math.abs(frame.frameX.nodeValue), Math.abs(frame.frameY.nodeValue), frame.frameWidth.nodeValue, frame.frameHeight.nodeValue);
- }
-
- }
-
- return data;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/loader/Cache.ts b/wip/TS Source/loader/Cache.ts
deleted file mode 100644
index b79956a6..00000000
--- a/wip/TS Source/loader/Cache.ts
+++ /dev/null
@@ -1,431 +0,0 @@
-///
-
-/**
-* Phaser - Cache
-*
-* A game only has one instance of a Cache and it is used to store all externally loaded assets such
-* as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
-*/
-
-module Phaser {
-
- export class Cache {
-
- /**
- * Cache constructor
- */
- constructor(game: Game) {
-
- this.game = game;
-
- this._canvases = {};
- this._images = {};
- this._sounds = {};
- this._text = {};
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Canvas key-value container.
- * @type {object}
- */
- private _canvases;
-
- /**
- * Image key-value container.
- * @type {object}
- */
- private _images;
-
- /**
- * Sound key-value container.
- * @type {object}
- */
- private _sounds;
-
- /**
- * Text key-value container.
- * @type {object}
- */
- private _text;
-
- /**
- * Add a new canvas.
- * @param key {string} Asset key for this canvas.
- * @param canvas {HTMLCanvasElement} Canvas DOM element.
- * @param context {CanvasRenderingContext2D} Render context of this canvas.
- */
- public addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D) {
-
- this._canvases[key] = { canvas: canvas, context: context };
-
- }
-
- /**
- * Add a new sprite sheet.
- * @param key {string} Asset key for the sprite sheet.
- * @param url {string} URL of this sprite sheet file.
- * @param data {object} Extra sprite sheet data.
- * @param frameWidth {number} Width of the sprite sheet.
- * @param frameHeight {number} Height of the sprite sheet.
- * @param frameMax {number} How many frames stored in the sprite sheet.
- */
- public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number) {
-
- this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight };
- this._images[key].frameData = AnimationLoader.parseSpriteSheet(this.game, key, frameWidth, frameHeight, frameMax);
-
- }
-
- /**
- * Add a new texture atlas.
- * @param key {string} Asset key for the texture atlas.
- * @param url {string} URL of this texture atlas file.
- * @param data {object} Extra texture atlas data.
- * @param atlasData {object} Texture atlas frames data.
- */
- public addTextureAtlas(key: string, url: string, data, atlasData, format: number) {
-
- this._images[key] = { url: url, data: data, spriteSheet: true };
-
- if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY)
- {
- this._images[key].frameData = AnimationLoader.parseJSONData(this.game, atlasData);
- }
- else if (format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
- {
- this._images[key].frameData = AnimationLoader.parseXMLData(this.game, atlasData, format);
- }
-
- }
-
- /**
- * Add a new image.
- * @param key {string} Asset key for the image.
- * @param url {string} URL of this image file.
- * @param data {object} Extra image data.
- */
- public addImage(key: string, url: string, data) {
-
- this._images[key] = { url: url, data: data, spriteSheet: false };
-
- }
-
- /**
- * Add a new sound.
- * @param key {string} Asset key for the sound.
- * @param url {string} URL of this sound file.
- * @param data {object} Extra sound data.
- */
- public addSound(key: string, url: string, data, webAudio: bool = true, audioTag: bool = false) {
-
- var locked: bool = this.game.sound.touchLocked;
- var decoded: bool = false;
-
- if (audioTag) {
- decoded = true;
- }
-
- this._sounds[key] = { url: url, data: data, locked: locked, isDecoding: false, decoded: decoded, webAudio: webAudio, audioTag: audioTag };
-
- }
-
- public reloadSound(key: string) {
-
- if (this._sounds[key])
- {
- this._sounds[key].data.src = this._sounds[key].url;
- this._sounds[key].data.addEventListener('canplaythrough', () => this.reloadSoundComplete(key), false);
- this._sounds[key].data.load();
- }
-
- }
-
- public onSoundUnlock: Phaser.Signal = new Phaser.Signal;
-
- public reloadSoundComplete(key: string) {
-
- if (this._sounds[key])
- {
- this._sounds[key].locked = false;
- this.onSoundUnlock.dispatch(key);
- }
-
- }
-
- public updateSound(key: string, property: string, value) {
-
- if (this._sounds[key])
- {
- this._sounds[key][property] = value;
- }
-
- }
-
- /**
- * Add a new decoded sound.
- * @param key {string} Asset key for the sound.
- * @param data {object} Extra sound data.
- */
- public decodedSound(key: string, data) {
-
- this._sounds[key].data = data;
- this._sounds[key].decoded = true;
- this._sounds[key].isDecoding = false;
-
- }
-
- /**
- * Add a new text data.
- * @param key {string} Asset key for the text data.
- * @param url {string} URL of this text data file.
- * @param data {object} Extra text data.
- */
- public addText(key: string, url: string, data) {
-
- this._text[key] = { url: url, data: data };
-
- }
-
- /**
- * Get canvas by key.
- * @param key Asset key of the canvas you want.
- * @return {object} The canvas you want.
- */
- public getCanvas(key: string) {
-
- if (this._canvases[key])
- {
- return this._canvases[key].canvas;
- }
-
- return null;
-
- }
-
- /**
- * Get image data by key.
- * @param key Asset key of the image you want.
- * @return {object} The image data you want.
- */
- public getImage(key: string) {
-
- if (this._images[key])
- {
- return this._images[key].data;
- }
-
- return null;
-
- }
-
- /**
- * Get frame data by key.
- * @param key Asset key of the frame data you want.
- * @return {object} The frame data you want.
- */
- public getFrameData(key: string): FrameData {
-
- if (this._images[key] && this._images[key].spriteSheet == true)
- {
- return this._images[key].frameData;
- }
-
- return null;
-
- }
-
- /**
- * Get sound by key.
- * @param key Asset key of the sound you want.
- * @return {object} The sound you want.
- */
- public getSound(key: string) {
-
- if (this._sounds[key])
- {
- return this._sounds[key];
- }
-
- return null;
-
- }
-
- /**
- * Get sound data by key.
- * @param key Asset key of the sound you want.
- * @return {object} The sound data you want.
- */
- public getSoundData(key: string) {
-
- if (this._sounds[key])
- {
- return this._sounds[key].data;
- }
-
- return null;
-
- }
-
- /**
- * Check whether an asset is decoded sound.
- * @param key Asset key of the sound you want.
- * @return {object} The sound data you want.
- */
- public isSoundDecoded(key: string): bool {
-
- if (this._sounds[key])
- {
- return this._sounds[key].decoded;
- }
-
- }
-
- /**
- * Check whether an asset is decoded sound.
- * @param key Asset key of the sound you want.
- * @return {object} The sound data you want.
- */
- public isSoundReady(key: string): bool {
-
- if (this._sounds[key] && this._sounds[key].decoded == true && this._sounds[key].locked == false)
- {
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Check whether an asset is sprite sheet.
- * @param key Asset key of the sprite sheet you want.
- * @return {object} The sprite sheet data you want.
- */
- public isSpriteSheet(key: string): bool {
-
- if (this._images[key])
- {
- return this._images[key].spriteSheet;
- }
-
- }
-
- /**
- * Get text data by key.
- * @param key Asset key of the text data you want.
- * @return {object} The text data you want.
- */
- public getText(key: string) {
-
- if (this._text[key])
- {
- return this._text[key].data;
- }
-
- return null;
-
- }
-
- /**
- * Returns an array containing all of the keys of Images in the Cache.
- * @return {Array} The string based keys in the Cache.
- */
- public getImageKeys() {
-
- var output = [];
-
- for (var item in this._images)
- {
- output.push(item);
- }
-
- return output;
-
- }
-
- /**
- * Returns an array containing all of the keys of Sounds in the Cache.
- * @return {Array} The string based keys in the Cache.
- */
- public getSoundKeys() {
-
- var output = [];
-
- for (var item in this._sounds)
- {
- output.push(item);
- }
-
- return output;
-
- }
-
- /**
- * Returns an array containing all of the keys of Text Files in the Cache.
- * @return {Array} The string based keys in the Cache.
- */
- public getTextKeys() {
-
- var output = [];
-
- for (var item in this._text)
- {
- output.push(item);
- }
-
- return output;
-
- }
-
- public removeCanvas(key: string) {
- delete this._canvases[key];
- }
-
- public removeImage(key: string) {
- delete this._images[key];
- }
-
- public removeSound(key: string) {
- delete this._sounds[key];
- }
-
- public removeText(key: string) {
- delete this._text[key];
- }
-
- /**
- * Clean up cache memory.
- */
- public destroy() {
-
- for (var item in this._canvases)
- {
- delete this._canvases[item['key']];
- }
-
- for (var item in this._images)
- {
- delete this._images[item['key']];
- }
-
- for (var item in this._sounds)
- {
- delete this._sounds[item['key']];
- }
-
- for (var item in this._text)
- {
- delete this._text[item['key']];
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/loader/Loader.ts b/wip/TS Source/loader/Loader.ts
deleted file mode 100644
index 95a14d36..00000000
--- a/wip/TS Source/loader/Loader.ts
+++ /dev/null
@@ -1,641 +0,0 @@
-///
-
-/**
-* Phaser - Loader
-*
-* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
-* It uses a combination of Image() loading and xhr and provides for progress and completion callbacks.
-*/
-
-module Phaser {
-
- export class Loader {
-
- /**
- * Loader constructor
- *
- * @param game {Phaser.Game} Current game instance.
- */
- constructor(game: Game) {
-
- this.game = game;
-
- this._keys = [];
- this._fileList = {};
- this._xhr = new XMLHttpRequest();
- this._queueSize = 0;
- this.isLoading = false;
-
- this.onFileComplete = new Phaser.Signal;
- this.onFileError = new Phaser.Signal;
- this.onLoadStart = new Phaser.Signal;
- this.onLoadComplete = new Phaser.Signal;
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Array stores assets keys. So you can get that asset by its unique key.
- */
- private _keys: string[];
-
- /**
- * Contains all the assets file infos.
- */
- private _fileList;
-
- /**
- * Indicates assets loading progress. (from 0 to 100)
- * @type {number}
- */
- private _progressChunk: number;
-
- private _xhr: XMLHttpRequest;
-
- /**
- * Length of assets queue.
- * @type {number}
- */
- private _queueSize: number;
-
- /**
- * True if the Loader is in the process of loading a queue.
- * @type {bool}
- */
- public isLoading: bool;
-
- /**
- * True if game is completely loaded.
- * @type {bool}
- */
- public hasLoaded: bool;
-
- /**
- * Loading progress (from 0 to 100)
- * @type {number}
- */
- public progress: number;
-
- /**
- * The crossOrigin value applied to loaded images
- * @type {string}
- */
- public crossOrigin: string = '';
-
- // If you want to append a URL before the path of any asset you can set this here.
- // Useful if you need to allow an asset url to be configured outside of the game code.
- // MUST have / on the end of it!
- public baseURL: string = '';
-
- public onFileComplete: Phaser.Signal;
- public onFileError: Phaser.Signal;
- public onLoadStart: Phaser.Signal;
- public onLoadComplete: Phaser.Signal;
-
- /**
- * TextureAtlas data format constants
- */
- public static TEXTURE_ATLAS_JSON_ARRAY: number = 0;
- public static TEXTURE_ATLAS_JSON_HASH: number = 1;
- public static TEXTURE_ATLAS_XML_STARLING: number = 2;
-
- /**
- * Reset loader, this will remove all loaded assets.
- */
- public reset() {
- this._queueSize = 0;
- this.isLoading = false;
- }
-
- public get queueSize(): number {
- return this._queueSize;
- }
-
- /**
- * Add a new image asset loading request with key and url.
- * @param key {string} Unique asset key of this image file.
- * @param url {string} URL of image file.
- */
- public image(key: string, url: string, overwrite: bool = false) {
-
- if (overwrite == true || this.checkKeyExists(key) == false)
- {
- this._queueSize++;
- this._fileList[key] = { type: 'image', key: key, url: url, data: null, error: false, loaded: false };
- this._keys.push(key);
- }
-
- }
-
- /**
- * Add a new sprite sheet loading request.
- * @param key {string} Unique asset key of the sheet file.
- * @param url {string} URL of sheet file.
- * @param frameWidth {number} Width of each single frame.
- * @param frameHeight {number} Height of each single frame.
- * @param frameMax {number} How many frames in this sprite sheet.
- */
- public spritesheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax: number = -1) {
-
- if (this.checkKeyExists(key) === false)
- {
- this._queueSize++;
- this._fileList[key] = { type: 'spritesheet', key: key, url: url, data: null, frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax, error: false, loaded: false };
- this._keys.push(key);
- }
-
- }
-
- /**
- * Add a new texture atlas loading request.
- * @param key {string} Unique asset key of the texture atlas file.
- * @param textureURL {string} The url of the texture atlas image file.
- * @param [atlasURL] {string} The url of the texture atlas data file (json/xml)
- * @param [atlasData] {object} A JSON or XML data object.
- * @param [format] {number} A value describing the format of the data.
- */
- public atlas(key: string, textureURL: string, atlasURL: string = null, atlasData = null, format:number = Loader.TEXTURE_ATLAS_JSON_ARRAY) {
-
- if (this.checkKeyExists(key) === false)
- {
- if (atlasURL !== null)
- {
- // A URL to a json/xml file has been given
- this._queueSize++;
- this._fileList[key] = { type: 'textureatlas', key: key, url: textureURL, atlasURL: atlasURL, data: null, format: format, error: false, loaded: false };
- this._keys.push(key);
- }
- else
- {
- if (format == Loader.TEXTURE_ATLAS_JSON_ARRAY)
- {
- // A json string or object has been given
- if (typeof atlasData === 'string')
- {
- atlasData = JSON.parse(atlasData);
- }
-
- this._queueSize++;
- this._fileList[key] = { type: 'textureatlas', key: key, url: textureURL, data: null, atlasURL: null, atlasData: atlasData, format: format, error: false, loaded: false };
- this._keys.push(key);
- }
- else if (format == Loader.TEXTURE_ATLAS_XML_STARLING)
- {
- // An xml string or object has been given
- if (typeof atlasData === 'string')
- {
- var xml;
-
- try
- {
- if (window['DOMParser'])
- {
- var domparser = new DOMParser();
- xml = domparser.parseFromString(atlasData, "text/xml");
- }
- else
- {
- xml = new ActiveXObject("Microsoft.XMLDOM");
- xml.async = 'false';
- xml.loadXML(atlasData);
- }
- }
- catch (e)
- {
- xml = undefined;
- }
-
- if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
- {
- throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
- }
- else
- {
- atlasData = xml;
- }
- }
-
- this._queueSize++;
- this._fileList[key] = { type: 'textureatlas', key: key, url: textureURL, data: null, atlasURL: null, atlasData: atlasData, format: format, error: false, loaded: false };
- this._keys.push(key);
- }
-
- }
-
- }
-
- }
-
- /**
- * Add a new audio file loading request.
- * @param key {string} Unique asset key of the audio file.
- * @param urls {Array} An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ]
- * @param autoDecode {bool} When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process.
- */
- public audio(key: string, urls: string[], autoDecode: bool = true) {
-
- if (this.checkKeyExists(key) === false)
- {
- this._queueSize++;
- this._fileList[key] = { type: 'audio', key: key, url: urls, data: null, buffer: null, error: false, loaded: false, autoDecode: autoDecode };
- this._keys.push(key);
- }
-
- }
-
- /**
- * Add a new text file loading request.
- * @param key {string} Unique asset key of the text file.
- * @param url {string} URL of text file.
- */
- public text(key: string, url: string) {
-
- if (this.checkKeyExists(key) === false)
- {
- this._queueSize++;
- this._fileList[key] = { type: 'text', key: key, url: url, data: null, error: false, loaded: false };
- this._keys.push(key);
- }
-
- }
-
- /**
- * Remove loading request of a file.
- * @param key {string} Key of the file you want to remove.
- */
- public removeFile(key: string) {
-
- delete this._fileList[key];
-
- }
-
- /**
- * Remove all file loading requests.
- */
- public removeAll() {
-
- this._fileList = {};
-
- }
-
- /**
- * Load assets.
- */
- public start() {
-
- if (this.isLoading)
- {
- return;
- }
-
- this.progress = 0;
- this.hasLoaded = false;
- this.isLoading = true;
-
- this.onLoadStart.dispatch(this.queueSize);
-
- if (this._keys.length > 0)
- {
- this._progressChunk = 100 / this._keys.length;
- this.loadFile();
- }
- else
- {
- this.progress = 100;
- this.hasLoaded = true;
- this.onLoadComplete.dispatch();
- }
-
- }
-
- /**
- * Load files. Private method ONLY used by loader.
- */
- private loadFile() {
-
- var file = this._fileList[this._keys.pop()];
-
- // Image or Data?
-
- switch (file.type)
- {
- case 'image':
- case 'spritesheet':
- case 'textureatlas':
- file.data = new Image();
- file.data.name = file.key;
- file.data.onload = () => this.fileComplete(file.key);
- file.data.onerror = () => this.fileError(file.key);
- file.data.crossOrigin = this.crossOrigin;
- file.data.src = this.baseURL + file.url;
- break;
-
- case 'audio':
-
- file.url = this.getAudioURL(file.url);
-
- if (file.url !== null)
- {
- // WebAudio or Audio Tag?
- if (this.game.sound.usingWebAudio)
- {
- this._xhr.open("GET", this.baseURL + file.url, true);
- this._xhr.responseType = "arraybuffer";
- this._xhr.onload = () => this.fileComplete(file.key);
- this._xhr.onerror = () => this.fileError(file.key);
- this._xhr.send();
- }
- else if (this.game.sound.usingAudioTag)
- {
- if (this.game.sound.touchLocked)
- {
- // If audio is locked we can't do this yet, so need to queue this load request somehow. Bum.
- file.data = new Audio();
- file.data.name = file.key;
- file.data.preload = 'auto';
- file.data.src = this.baseURL + file.url;
- this.fileComplete(file.key);
- }
- else
- {
- file.data = new Audio();
- file.data.name = file.key;
- file.data.onerror = () => this.fileError(file.key);
- file.data.preload = 'auto';
- file.data.src = this.baseURL + file.url;
- file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false);
- file.data.load();
- }
- }
- }
-
- break;
-
- case 'text':
- this._xhr.open("GET", this.baseURL + file.url, true);
- this._xhr.responseType = "text";
- this._xhr.onload = () => this.fileComplete(file.key);
- this._xhr.onerror = () => this.fileError(file.key);
- this._xhr.send();
- break;
- }
-
- }
-
- private getAudioURL(urls): string {
-
- var extension: string;
-
- for (var i = 0; i < urls.length; i++)
- {
- extension = urls[i].toLowerCase();
- extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1);
-
- if (this.game.device.canPlayAudio(extension))
- {
- return urls[i];
- }
-
- }
-
- return null;
-
- }
-
- /**
- * Error occured when load a file.
- * @param key {string} Key of the error loading file.
- */
- private fileError(key: string) {
-
- this._fileList[key].loaded = true;
- this._fileList[key].error = true;
-
- this.onFileError.dispatch(key);
-
- throw new Error("Phaser.Loader error loading file: " + key);
-
- this.nextFile(key, false);
-
- }
-
- /**
- * Called when a file is successfully loaded.
- * @param key {string} Key of the successfully loaded file.
- */
- private fileComplete(key: string) {
-
- if (!this._fileList[key])
- {
- throw new Error('Phaser.Loader fileComplete invalid key ' + key);
- return;
- }
-
- this._fileList[key].loaded = true;
-
- var file = this._fileList[key];
- var loadNext: bool = true;
-
- switch (file.type)
- {
- case 'image':
- this.game.cache.addImage(file.key, file.url, file.data);
- break;
-
- case 'spritesheet':
- this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax);
- break;
-
- case 'textureatlas':
- if (file.atlasURL == null)
- {
- this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format);
- }
- else
- {
- // Load the JSON or XML before carrying on with the next file
- loadNext = false;
- this._xhr.open("GET", this.baseURL + file.atlasURL, true);
- this._xhr.responseType = "text";
-
- if (file.format == Loader.TEXTURE_ATLAS_JSON_ARRAY)
- {
- this._xhr.onload = () => this.jsonLoadComplete(file.key);
- }
- else if (file.format == Loader.TEXTURE_ATLAS_XML_STARLING)
- {
- this._xhr.onload = () => this.xmlLoadComplete(file.key);
- }
-
- this._xhr.onerror = () => this.dataLoadError(file.key);
- this._xhr.send();
- }
- break;
-
- case 'audio':
-
- if (this.game.sound.usingWebAudio)
- {
- file.data = this._xhr.response;
-
- this.game.cache.addSound(file.key, file.url, file.data, true, false);
-
- if (file.autoDecode)
- {
- this.game.cache.updateSound(key, 'isDecoding', true);
-
- var that = this;
- var key = file.key;
-
- this.game.sound.context.decodeAudioData(file.data, function (buffer) {
- if (buffer)
- {
- that.game.cache.decodedSound(key, buffer);
- }
- });
- }
- }
- else
- {
- file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete);
- this.game.cache.addSound(file.key, file.url, file.data, false, true);
- }
- break;
-
- case 'text':
- file.data = this._xhr.response;
- this.game.cache.addText(file.key, file.url, file.data);
- break;
- }
-
- if (loadNext)
- {
- this.nextFile(key, true);
- }
-
- }
-
- /**
- * Successfully loaded a JSON file.
- * @param key {string} Key of the loaded JSON file.
- */
- private jsonLoadComplete(key: string) {
-
- var data = JSON.parse(this._xhr.response);
- var file = this._fileList[key];
-
- this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
-
- this.nextFile(key, true);
-
- }
-
- /**
- * Error occured when load a JSON.
- * @param key {string} Key of the error loading JSON file.
- */
- private dataLoadError(key: string) {
-
- var file = this._fileList[key];
-
- file.error = true;
-
- throw new Error("Phaser.Loader dataLoadError: " + key);
-
- this.nextFile(key, true);
-
- }
-
- private xmlLoadComplete(key: string) {
-
- var atlasData = this._xhr.response;
- var xml;
-
- try
- {
- if (window['DOMParser'])
- {
- var domparser = new DOMParser();
- xml = domparser.parseFromString(atlasData, "text/xml");
- }
- else
- {
- xml = new ActiveXObject("Microsoft.XMLDOM");
- xml.async = 'false';
- xml.loadXML(atlasData);
- }
- }
- catch (e)
- {
- xml = undefined;
- }
-
- if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
- {
- throw new Error("Phaser.Loader. Invalid XML given");
- }
-
- var file = this._fileList[key];
- this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
-
- this.nextFile(key, true);
-
- }
-
- /**
- * Handle loading next file.
- * @param previousKey {string} Key of previous loaded asset.
- * @param success {bool} Whether the previous asset loaded successfully or not.
- */
- private nextFile(previousKey: string, success: bool) {
-
- this.progress = Math.round(this.progress + this._progressChunk);
-
- if (this.progress > 100)
- {
- this.progress = 100;
- }
-
- this.onFileComplete.dispatch(this.progress, previousKey, success, this._queueSize - this._keys.length, this._queueSize);
-
- if (this._keys.length > 0)
- {
- this.loadFile();
- }
- else
- {
- this.hasLoaded = true;
- this.isLoading = false;
-
- this.removeAll();
-
- this.onLoadComplete.dispatch();
- }
-
- }
-
- /**
- * Check whether asset exists with a specific key.
- * @param key {string} Key of the asset you want to check.
- * @return {bool} Return true if exists, otherwise return false.
- */
- private checkKeyExists(key: string): bool {
-
- if (this._fileList[key])
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/GameMath.ts b/wip/TS Source/math/GameMath.ts
deleted file mode 100644
index 169e00cb..00000000
--- a/wip/TS Source/math/GameMath.ts
+++ /dev/null
@@ -1,1012 +0,0 @@
-///
-
-/**
-* Phaser - GameMath
-*
-* Adds a set of extra Math functions used through-out Phaser.
-* Includes methods written by Dylan Engelman and Adam Saltsman.
-*/
-
-module Phaser {
-
- export class GameMath {
-
- constructor(game: Game) {
-
- this.game = game;
-
- GameMath.sinA = [];
- GameMath.cosA = [];
-
- for (var i = 0; i < 360; i++)
- {
- GameMath.sinA.push(Math.sin(this.degreesToRadians(i)));
- GameMath.cosA.push(Math.cos(this.degreesToRadians(i)));
- }
- }
-
- public game: Phaser.Game;
-
- // Pre-calculated tables containing Math.sin(angle) and Math.cos(angle) from -180 to 180
- // So sinA[sprite.rotation] would be the same as Math.sin(sprite.rotation) without a call to Math.sin
- static sinA: number[];
- static cosA: number[];
-
- static PI: number = 3.141592653589793; //number pi
- static PI_2: number = 1.5707963267948965; //PI / 2 OR 90 deg
- static PI_4: number = 0.7853981633974483; //PI / 4 OR 45 deg
- static PI_8: number = 0.39269908169872413; //PI / 8 OR 22.5 deg
- static PI_16: number = 0.19634954084936206; //PI / 16 OR 11.25 deg
- static TWO_PI: number = 6.283185307179586; //2 * PI OR 180 deg
- static THREE_PI_2: number = 4.7123889803846895; //3 * PI_2 OR 270 deg
- static E: number = 2.71828182845905; //number e
- static LN10: number = 2.302585092994046; //ln(10)
- static LN2: number = 0.6931471805599453; //ln(2)
- static LOG10E: number = 0.4342944819032518; //logB10(e)
- static LOG2E: number = 1.442695040888963387; //logB2(e)
- static SQRT1_2: number = 0.7071067811865476; //sqrt( 1 / 2 )
- static SQRT2: number = 1.4142135623730951; //sqrt( 2 )
- static DEG_TO_RAD: number = 0.017453292519943294444444444444444; //PI / 180;
- static RAD_TO_DEG: number = 57.295779513082325225835265587527; // 180.0 / PI;
-
- static B_16: number = 65536;//2^16
- static B_31: number = 2147483648;//2^31
- static B_32: number = 4294967296;//2^32
- static B_48: number = 281474976710656;//2^48
- static B_53: number = 9007199254740992;//2^53 !!NOTE!! largest accurate double floating point whole value
- static B_64: number = 18446744073709551616;//2^64 !!NOTE!! Not accurate see B_53
-
- static ONE_THIRD: number = 0.333333333333333333333333333333333; // 1.0/3.0;
- static TWO_THIRDS: number = 0.666666666666666666666666666666666; // 2.0/3.0;
- static ONE_SIXTH: number = 0.166666666666666666666666666666666; // 1.0/6.0;
-
- static COS_PI_3: number = 0.86602540378443864676372317075294;//COS( PI / 3 )
- static SIN_2PI_3: number = 0.03654595;// SIN( 2*PI/3 )
-
- static CIRCLE_ALPHA: number = 0.5522847498307933984022516322796; //4*(Math.sqrt(2)-1)/3.0;
-
- static ON: bool = true;
- static OFF: bool = false;
-
- static SHORT_EPSILON: number = 0.1;//round integer epsilon
- static PERC_EPSILON: number = 0.001;//percentage epsilon
- static EPSILON: number = 0.0001;//single float average epsilon
- static LONG_EPSILON: number = 0.00000001;//arbitrary 8 digit epsilon
-
- public cosTable = [];
- public sinTable = [];
-
- public fuzzyEqual(a: number, b: number, epsilon: number = 0.0001): bool {
- return Math.abs(a - b) < epsilon;
- }
-
- public fuzzyLessThan(a: number, b: number, epsilon: number = 0.0001): bool {
- return a < b + epsilon;
- }
-
- public fuzzyGreaterThan(a: number, b: number, epsilon: number = 0.0001): bool {
- return a > b - epsilon;
- }
-
- public fuzzyCeil(val: number, epsilon: number = 0.0001): number {
- return Math.ceil(val - epsilon);
- }
-
- public fuzzyFloor(val: number, epsilon: number = 0.0001): number {
- return Math.floor(val + epsilon);
- }
-
- public average(...args: any[]): number {
- var avg: number = 0;
-
- for (var i = 0; i < args.length; i++)
- {
- avg += args[i];
- }
-
- return avg / args.length;
- }
-
- public slam(value: number, target: number, epsilon: number = 0.0001): number {
- return (Math.abs(value - target) < epsilon) ? target : value;
- }
-
- /**
- * ratio of value to a range
- */
- public percentageMinMax(val: number, max: number, min: number = 0): number {
- val -= min;
- max -= min;
-
- if (!max) return 0;
- else return val / max;
- }
-
- /**
- * a value representing the sign of the value.
- * -1 for negative, +1 for positive, 0 if value is 0
- */
- public sign(n: number): number {
- if (n) return n / Math.abs(n);
- else return 0;
- }
-
- public truncate(n: number): number {
- return (n > 0) ? Math.floor(n) : Math.ceil(n);
- }
-
- public shear(n: number): number {
- return n % 1;
- }
-
- /**
- * wrap a value around a range, similar to modulus with a floating minimum
- */
- public wrap(val: number, max: number, min: number = 0): number {
- val -= min;
- max -= min;
- if (max == 0) return min;
- val %= max;
- val += min;
- while (val < min)
- val += max;
-
- return val;
- }
-
- /**
- * arithmetic version of wrap... need to decide which is more efficient
- */
- public arithWrap(value: number, max: number, min: number = 0): number {
- max -= min;
- if (max == 0) return min;
- return value - max * Math.floor((value - min) / max);
- }
-
- /**
- * force a value within the boundaries of two values
- *
- * if max < min, min is returned
- */
- public clamp(input: number, max: number, min: number = 0): number {
- return Math.max(min, Math.min(max, input));
- }
-
- /**
- * Snap a value to nearest grid slice, using rounding.
- *
- * example if you have an interval gap of 5 and a position of 12... you will snap to 10. Where as 14 will snap to 15
- *
- * @param input - the value to snap
- * @param gap - the interval gap of the grid
- * @param [start] - optional starting offset for gap
- */
- public snapTo(input: number, gap: number, start: number = 0): number {
- if (gap == 0) return input;
-
- input -= start;
- input = gap * Math.round(input / gap);
- return start + input;
- }
-
- /**
- * Snap a value to nearest grid slice, using floor.
- *
- * example if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15
- *
- * @param input - the value to snap
- * @param gap - the interval gap of the grid
- * @param [start] - optional starting offset for gap
- */
- public snapToFloor(input: number, gap: number, start: number = 0): number {
- if (gap == 0) return input;
-
- input -= start;
- input = gap * Math.floor(input / gap);
- return start + input;
- }
-
- /**
- * Snap a value to nearest grid slice, using ceil.
- *
- * example if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20
- *
- * @param input - the value to snap
- * @param gap - the interval gap of the grid
- * @param [start] - optional starting offset for gap
- */
- public snapToCeil(input: number, gap: number, start: number = 0): number {
- if (gap == 0) return input;
-
- input -= start;
- input = gap * Math.ceil(input / gap);
- return start + input;
- }
-
- /**
- * Snaps a value to the nearest value in an array.
- */
- public snapToInArray(input: number, arr: number[], sort: bool = true): number {
-
- if (sort) arr.sort();
- if (input < arr[0]) return arr[0];
-
- var i: number = 1;
-
- while (arr[i] < input)
- i++;
-
- var low: number = arr[i - 1];
- var high: number = (i < arr.length) ? arr[i] : Number.POSITIVE_INFINITY;
-
- return ((high - input) <= (input - low)) ? high : low;
- }
-
- /**
- * roundTo some place comparative to a 'base', default is 10 for decimal place
- *
- * 'place' is represented by the power applied to 'base' to get that place
- *
- * @param value - the value to round
- * @param place - the place to round to
- * @param base - the base to round in... default is 10 for decimal
- *
- * e.g.
- *
- * 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011
- *
- * roundTo(2000/7,3) == 0
- * roundTo(2000/7,2) == 300
- * roundTo(2000/7,1) == 290
- * roundTo(2000/7,0) == 286
- * roundTo(2000/7,-1) == 285.7
- * roundTo(2000/7,-2) == 285.71
- * roundTo(2000/7,-3) == 285.714
- * roundTo(2000/7,-4) == 285.7143
- * roundTo(2000/7,-5) == 285.71429
- *
- * roundTo(2000/7,3,2) == 288 -- 100100000
- * roundTo(2000/7,2,2) == 284 -- 100011100
- * roundTo(2000/7,1,2) == 286 -- 100011110
- * roundTo(2000/7,0,2) == 286 -- 100011110
- * roundTo(2000/7,-1,2) == 285.5 -- 100011101.1
- * roundTo(2000/7,-2,2) == 285.75 -- 100011101.11
- * roundTo(2000/7,-3,2) == 285.75 -- 100011101.11
- * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011
- * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111
- *
- * note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
- * because we are rounding 100011.1011011011011011 which rounds up.
- */
- public roundTo(value: number, place: number = 0, base: number = 10): number {
- var p: number = Math.pow(base, -place);
- return Math.round(value * p) / p;
- }
-
- public floorTo(value: number, place: number = 0, base: number = 10): number {
- var p: number = Math.pow(base, -place);
- return Math.floor(value * p) / p;
- }
-
- public ceilTo(value: number, place: number = 0, base: number = 10): number {
- var p: number = Math.pow(base, -place);
- return Math.ceil(value * p) / p;
- }
-
- /**
- * a one dimensional linear interpolation of a value.
- */
- public interpolateFloat(a: number, b: number, weight: number): number {
- return (b - a) * weight + a;
- }
-
- /**
- * convert radians to degrees
- */
- public radiansToDegrees(angle: number): number {
- return angle * GameMath.RAD_TO_DEG;
- }
-
- /**
- * convert degrees to radians
- */
- public degreesToRadians(angle: number): number {
- return angle * GameMath.DEG_TO_RAD;
- }
-
- /**
- * Find the angle of a segment from (x1, y1) -> (x2, y2 )
- */
- public angleBetween(x1: number, y1: number, x2: number, y2: number): number {
- return Math.atan2(y2 - y1, x2 - x1);
- }
-
-
- /**
- * set an angle within the bounds of -PI to PI
- */
- public normalizeAngle(angle: number, radians: bool = true): number {
- var rd: number = (radians) ? GameMath.PI : 180;
- return this.wrap(angle, rd, -rd);
- }
-
- /**
- * closest angle between two angles from a1 to a2
- * absolute value the return for exact angle
- */
- public nearestAngleBetween(a1: number, a2: number, radians: bool = true): number {
-
- var rd: number = (radians) ? GameMath.PI : 180;
-
- a1 = this.normalizeAngle(a1, radians);
- a2 = this.normalizeAngle(a2, radians);
-
- if (a1 < -rd / 2 && a2 > rd / 2) a1 += rd * 2;
- if (a2 < -rd / 2 && a1 > rd / 2) a2 += rd * 2;
-
- return a2 - a1;
- }
-
- /**
- * normalizes independent and then sets dep to the nearest value respective to independent
- *
- * for instance if dep=-170 and ind=170 then 190 will be returned as an alternative to -170
- */
- public normalizeAngleToAnother(dep: number, ind: number, radians: bool = true): number {
- return ind + this.nearestAngleBetween(ind, dep, radians);
- }
-
- /**
- * normalize independent and dependent and then set dependent to an angle relative to 'after/clockwise' independent
- *
- * for instance dep=-170 and ind=170, then 190 will be reutrned as alternative to -170
- */
- public normalizeAngleAfterAnother(dep: number, ind: number, radians: bool = true): number {
-
- dep = this.normalizeAngle(dep - ind, radians);
- return ind + dep;
- }
-
- /**
- * normalizes indendent and dependent and then sets dependent to an angle relative to 'before/counterclockwise' independent
- *
- * for instance dep = 190 and ind = 170, then -170 will be returned as an alternative to 190
- */
- public normalizeAngleBeforeAnother(dep: number, ind: number, radians: bool = true): number {
-
- dep = this.normalizeAngle(ind - dep, radians);
- return ind - dep;
- }
-
- /**
- * interpolate across the shortest arc between two angles
- */
- public interpolateAngles(a1: number, a2: number, weight: number, radians: bool = true, ease = null): number {
-
- a1 = this.normalizeAngle(a1, radians);
- a2 = this.normalizeAngleToAnother(a2, a1, radians);
-
- return (typeof ease === 'function') ? ease(weight, a1, a2 - a1, 1) : this.interpolateFloat(a1, a2, weight);
- }
-
- /**
- * Compute the logarithm of any value of any base
- *
- * a logarithm is the exponent that some constant (base) would have to be raised to
- * to be equal to value.
- *
- * i.e.
- * 4 ^ x = 16
- * can be rewritten as to solve for x
- * logB4(16) = x
- * which with this function would be
- * LoDMath.logBaseOf(16,4)
- *
- * which would return 2, because 4^2 = 16
- */
- public logBaseOf(value: number, base: number): number {
- return Math.log(value) / Math.log(base);
- }
-
- /**
- * Greatest Common Denominator using Euclid's algorithm
- */
- public GCD(m: number, n: number): number {
- var r: number;
-
- //make sure positive, GCD is always positive
- m = Math.abs(m);
- n = Math.abs(n);
-
- //m must be >= n
- if (m < n)
- {
- r = m;
- m = n;
- n = r;
- }
-
- //now start loop
- while (true)
- {
- r = m % n;
- if (!r) return n;
- m = n;
- n = r;
- }
-
- return 1;
- }
-
- /**
- * Lowest Common Multiple
- */
- public LCM(m: number, n: number): number {
- return (m * n) / this.GCD(m, n);
- }
-
- /**
- * Factorial - N!
- *
- * simple product series
- *
- * by definition:
- * 0! == 1
- */
- public factorial(value: number): number {
- if (value == 0) return 1;
-
- var res: number = value;
-
- while (--value)
- {
- res *= value;
- }
-
- return res;
- }
-
- /**
- * gamma function
- *
- * defined: gamma(N) == (N - 1)!
- */
- public gammaFunction(value: number): number {
- return this.factorial(value - 1);
- }
-
- /**
- * falling factorial
- *
- * defined: (N)! / (N - x)!
- *
- * written subscript: (N)x OR (base)exp
- */
- public fallingFactorial(base: number, exp: number): number {
- return this.factorial(base) / this.factorial(base - exp);
- }
-
- /**
- * rising factorial
- *
- * defined: (N + x - 1)! / (N - 1)!
- *
- * written superscript N^(x) OR base^(exp)
- */
- public risingFactorial(base: number, exp: number): number {
- //expanded from gammaFunction for speed
- return this.factorial(base + exp - 1) / this.factorial(base - 1);
- }
-
- /**
- * binomial coefficient
- *
- * defined: N! / (k!(N-k)!)
- * reduced: N! / (N-k)! == (N)k (fallingfactorial)
- * reduced: (N)k / k!
- */
- public binCoef(n: number, k: number): number {
- return this.fallingFactorial(n, k) / this.factorial(k);
- }
-
- /**
- * rising binomial coefficient
- *
- * as one can notice in the analysis of binCoef(...) that
- * binCoef is the (N)k divided by k!. Similarly rising binCoef
- * is merely N^(k) / k!
- */
- public risingBinCoef(n: number, k: number): number {
- return this.risingFactorial(n, k) / this.factorial(k);
- }
-
- /**
- * Generate a random bool result based on the chance value
- *
- * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance
- * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.
- *
- * @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%)
- * @return true if the roll passed, or false
- */
- public chanceRoll(chance: number = 50): bool {
-
- if (chance <= 0)
- {
- return false;
- }
- else if (chance >= 100)
- {
- return true;
- }
- else
- {
- if (Math.random() * 100 >= chance)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- }
-
- /**
- * Adds the given amount to the value, but never lets the value go over the specified maximum
- *
- * @param value The value to add the amount to
- * @param amount The amount to add to the value
- * @param max The maximum the value is allowed to be
- * @return The new value
- */
- public maxAdd(value: number, amount: number, max: number): number {
-
- value += amount;
-
- if (value > max)
- {
- value = max;
- }
-
- return value;
-
- }
-
- /**
- * Subtracts the given amount from the value, but never lets the value go below the specified minimum
- *
- * @param value The base value
- * @param amount The amount to subtract from the base value
- * @param min The minimum the value is allowed to be
- * @return The new value
- */
- public minSub(value: number, amount: number, min: number): number {
-
- value -= amount;
-
- if (value < min)
- {
- value = min;
- }
-
- return value;
- }
-
- /**
- * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
- *
Values must be positive integers, and are passed through Math.abs
- *
- * @param value The value to add the amount to
- * @param amount The amount to add to the value
- * @param max The maximum the value is allowed to be
- * @return The wrapped value
- */
- public wrapValue(value: number, amount: number, max: number): number {
-
- var diff: number;
-
- value = Math.abs(value);
- amount = Math.abs(amount);
- max = Math.abs(max);
-
- diff = (value + amount) % max;
-
- return diff;
-
- }
-
- /**
- * Randomly returns either a 1 or -1
- *
- * @return 1 or -1
- */
- public randomSign(): number {
- return (Math.random() > 0.5) ? 1 : -1;
- }
-
- /**
- * Returns true if the number given is odd.
- *
- * @param n The number to check
- *
- * @return True if the given number is odd. False if the given number is even.
- */
- public isOdd(n: number): bool {
-
- if (n & 1)
- {
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- * Returns true if the number given is even.
- *
- * @param n The number to check
- *
- * @return True if the given number is even. False if the given number is odd.
- */
- public isEven(n: number): bool {
-
- if (n & 1)
- {
- return false;
- }
- else
- {
- return true;
- }
-
- }
-
- /**
- * Keeps an angle value between -180 and +180
- * Should be called whenever the angle is updated on the Sprite to stop it from going insane.
- *
- * @param angle The angle value to check
- *
- * @return The new angle value, returns the same as the input angle if it was within bounds
- */
- public wrapAngle(angle: number): number {
-
- var result: number = angle;
-
- // Nothing needs to change
- if (angle >= -180 && angle <= 180)
- {
- return angle;
- }
-
- // Else normalise it to -180, 180
- result = (angle + 180) % 360;
-
- if (result < 0)
- {
- result += 360;
- }
-
- return result - 180;
-
- }
-
- /**
- * Keeps an angle value between the given min and max values
- *
- * @param angle The angle value to check. Must be between -180 and +180
- * @param min The minimum angle that is allowed (must be -180 or greater)
- * @param max The maximum angle that is allowed (must be 180 or less)
- *
- * @return The new angle value, returns the same as the input angle if it was within bounds
- */
- public angleLimit(angle: number, min: number, max: number): number {
-
- var result: number = angle;
-
- if (angle > max)
- {
- result = max;
- }
- else if (angle < min)
- {
- result = min;
- }
-
- return result;
- }
-
- /**
- * @method linear
- * @param {Any} v
- * @param {Any} k
- * @public
- */
- public linearInterpolation(v, k) {
-
- var m = v.length - 1;
- var f = m * k;
- var i = Math.floor(f);
-
- if (k < 0) return this.linear(v[0], v[1], f);
- if (k > 1) return this.linear(v[m], v[m - 1], m - f);
-
- return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i);
-
- }
-
- /**
- * @method Bezier
- * @param {Any} v
- * @param {Any} k
- * @public
- */
- public bezierInterpolation(v, k) {
-
- var b = 0;
- var n = v.length - 1;
-
- for (var i = 0; i <= n; i++)
- {
- b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i);
- }
-
- return b;
-
- }
-
- /**
- * @method CatmullRom
- * @param {Any} v
- * @param {Any} k
- * @public
- */
- public catmullRomInterpolation(v, k) {
-
- var m = v.length - 1;
- var f = m * k;
- var i = Math.floor(f);
-
- if (v[0] === v[m])
- {
- if (k < 0) i = Math.floor(f = m * (1 + k));
-
- return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
-
- }
- else
- {
- if (k < 0) return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]);
-
- if (k > 1) return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
-
- return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
- }
-
- }
-
- /**
- * @method Linear
- * @param {Any} p0
- * @param {Any} p1
- * @param {Any} t
- * @public
- */
- public linear(p0, p1, t) {
-
- return (p1 - p0) * t + p0;
-
- }
-
- /**
- * @method Bernstein
- * @param {Any} n
- * @param {Any} i
- * @public
- */
- public bernstein(n, i) {
-
- return this.factorial(n) / this.factorial(i) / this.factorial(n - i);
-
- }
-
- /**
- * @method CatmullRom
- * @param {Any} p0
- * @param {Any} p1
- * @param {Any} p2
- * @param {Any} p3
- * @param {Any} t
- * @public
- */
- public catmullRom(p0, p1, p2, p3, t) {
-
- var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2;
- return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
-
- }
-
- public difference(a: number, b: number): number {
-
- return Math.abs(a - b);
-
- }
-
- /**
- * Fetch a random entry from the given array.
- * Will return null if random selection is missing, or array has no entries.
- *
- * @param objects An array of objects.
- * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
- * @param length Optional restriction on the number of values you want to randomly select from.
- *
- * @return The random object that was selected.
- */
- public getRandom(objects, startIndex: number = 0, length: number = 0) {
-
- if (objects != null)
- {
- var l: number = length;
-
- if ((l == 0) || (l > objects.length - startIndex))
- {
- l = objects.length - startIndex;
- }
-
- if (l > 0)
- {
- return objects[startIndex + Math.floor(Math.random() * l)];
- }
- }
-
- return null;
-
- }
-
- /**
- * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.
- *
- * @param Value Any number.
- *
- * @return The rounded value of that number.
- */
- public floor(value: number): number {
- var n: number = value | 0;
- return (value > 0) ? (n) : ((n != value) ? (n - 1) : (n));
- }
-
- /**
- * Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.
- *
- * @param Value Any number.
- *
- * @return The rounded value of that number.
- */
- public ceil(value: number): number {
- var n: number = value | 0;
- return (value > 0) ? ((n != value) ? (n + 1) : (n)) : (n);
- }
-
- /**
- * Generate a sine and cosine table simultaneously and extremely quickly. Based on research by Franky of scene.at
- *
- * The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function
- * you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time.
- *
- * @param length The length of the wave
- * @param sinAmplitude The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
- * @param cosAmplitude The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
- * @param frequency The frequency of the sine and cosine table data
- * @return Returns the sine table
- * @see getSinTable
- * @see getCosTable
- */
- public sinCosGenerator(length: number, sinAmplitude: number = 1.0, cosAmplitude: number = 1.0, frequency: number = 1.0) {
-
- var sin: number = sinAmplitude;
- var cos: number = cosAmplitude;
- var frq: number = frequency * Math.PI / length;
-
- this.cosTable = [];
- this.sinTable = [];
-
- for (var c: number = 0; c < length; c++)
- {
- cos -= sin * frq;
- sin += cos * frq;
-
- this.cosTable[c] = cos;
- this.sinTable[c] = sin;
- }
-
- return this.sinTable;
-
- }
-
- /**
- * Shifts through the sin table data by one value and returns it.
- * This effectively moves the position of the data from the start to the end of the table.
- * @return The sin value.
- */
- public shiftSinTable(): number {
-
- if (this.sinTable)
- {
- var s = this.sinTable.shift();
- this.sinTable.push(s);
- return s;
- }
-
- }
-
- /**
- * Shifts through the cos table data by one value and returns it.
- * This effectively moves the position of the data from the start to the end of the table.
- * @return The cos value.
- */
- public shiftCosTable(): number {
-
- if (this.cosTable)
- {
- var s = this.cosTable.shift();
- this.cosTable.push(s);
- return s;
- }
-
- }
-
- /**
- * Shuffles the data in the given array into a new order
- * @param array The array to shuffle
- * @return The array
- */
- public shuffleArray(array) {
-
- for (var i = array.length - 1; i > 0; i--)
- {
- var j = Math.floor(Math.random() * (i + 1));
- var temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
-
- return array;
-
- }
-
- /**
- * Returns the distance from this Point object to the given Point object.
- * @method distanceFrom
- * @param {Point} target - The destination Point object.
- * @param {bool} round - Round the distance to the nearest integer (default false)
- * @return {Number} The distance between this Point object and the destination Point object.
- **/
- public distanceBetween(x1: number, y1: number, x2: number, y2: number): number {
-
- var dx = x1 - x2;
- var dy = y1 - y2;
-
- return Math.sqrt(dx * dx + dy * dy);
-
- }
-
- /**
- * Finds the length of the given vector
- *
- * @param dx
- * @param dy
- *
- * @return
- */
- public vectorLength(dx: number, dy: number): number {
- return Math.sqrt(dx * dx + dy * dy);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/LinkedList.ts b/wip/TS Source/math/LinkedList.ts
deleted file mode 100644
index 4efc8815..00000000
--- a/wip/TS Source/math/LinkedList.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-///
-
-/**
-* Phaser - LinkedList
-*
-* A miniature linked list class. Useful for optimizing time-critical or highly repetitive tasks!
-*/
-
-module Phaser {
-
- export class LinkedList {
-
- /**
- * Creates a new link, and sets object and next to null.
- */
- constructor() {
-
- this.object = null;
- this.next = null;
-
- }
-
- /**
- * Stores a reference to an IGameObject.
- */
- //public object: IGameObject;
- public object;
-
- /**
- * Stores a reference to the next link in the list.
- */
- public next: LinkedList;
-
- /**
- * Clean up memory.
- */
- public destroy() {
-
- this.object = null;
-
- if (this.next != null)
- {
- this.next.destroy();
- }
-
- this.next = null;
-
- }
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/Mat3.ts b/wip/TS Source/math/Mat3.ts
deleted file mode 100644
index cafbaa02..00000000
--- a/wip/TS Source/math/Mat3.ts
+++ /dev/null
@@ -1,275 +0,0 @@
-///
-
-/**
-* Phaser - Mat3
-*
-* A 3x3 Matrix
-*/
-
-module Phaser {
-
- export class Mat3 {
-
- /**
- * Creates a new Mat3 object.
- * @class Mat3
- * @constructor
- * @return {Mat3} This object
- **/
- constructor() {
- this.data = [1, 0, 0, 0, 1, 0, 0, 0, 1];
- }
-
- // Temporary vars used for internal calculations
- private _a00: number;
- private _a01: number;
- private _a02: number;
- private _a10: number;
- private _a11: number;
- private _a12: number;
- private _a20: number;
- private _a21: number;
- private _a22: number;
-
- public data: number[];
-
- public get a00(): number {
- return this.data[0];
- }
-
- public set a00(value: number) {
- this.data[0] = value;
- }
-
- public get a01(): number {
- return this.data[1];
- }
-
- public set a01(value: number) {
- this.data[1] = value;
- }
-
- public get a02(): number {
- return this.data[2];
- }
-
- public set a02(value: number) {
- this.data[2] = value;
- }
-
- public get a10(): number {
- return this.data[3];
- }
-
- public set a10(value: number) {
- this.data[3] = value;
- }
-
- public get a11(): number {
- return this.data[4];
- }
-
- public set a11(value: number) {
- this.data[4] = value;
- }
-
- public get a12(): number {
- return this.data[5];
- }
-
- public set a12(value: number) {
- this.data[5] = value;
- }
-
- public get a20(): number {
- return this.data[6];
- }
-
- public set a20(value: number) {
- this.data[6] = value;
- }
-
- public get a21(): number {
- return this.data[7];
- }
-
- public set a21(value: number) {
- this.data[7] = value;
- }
-
- public get a22(): number {
- return this.data[8];
- }
-
- public set a22(value: number) {
- this.data[8] = value;
- }
-
- /**
- * Copies the values from one Mat3 into this Mat3.
- * @method copyFromMat3
- * @param {any} source - The object to copy from.
- * @return {Mat3} This Mat3 object.
- **/
- public copyFromMat3(source: Mat3): Mat3 {
-
- this.data[0] = source.data[0];
- this.data[1] = source.data[1];
- this.data[2] = source.data[2];
- this.data[3] = source.data[3];
- this.data[4] = source.data[4];
- this.data[5] = source.data[5];
- this.data[6] = source.data[6];
- this.data[7] = source.data[7];
- this.data[8] = source.data[8];
-
- return this;
- }
-
- /**
- * Copies the upper-left 3x3 values into this Mat3.
- * @method copyFromMat4
- * @param {any} source - The object to copy from.
- * @return {Mat3} This Mat3 object.
- **/
- public copyFromMat4(source: any): Mat3 {
-
- this.data[0] = source[0];
- this.data[1] = source[1];
- this.data[2] = source[2];
- this.data[3] = source[4];
- this.data[4] = source[5];
- this.data[5] = source[6];
- this.data[6] = source[8];
- this.data[7] = source[9];
- this.data[8] = source[10];
-
- return this;
- }
-
- /**
- * Clones this Mat3 into a new Mat3
- * @param {Mat3} out The output Mat3, if none is given a new Mat3 object will be created.
- * @return {Mat3} The new Mat3
- **/
- public clone(out:Mat3 = new Phaser.Mat3): Mat3 {
-
- out[0] = this.data[0];
- out[1] = this.data[1];
- out[2] = this.data[2];
- out[3] = this.data[3];
- out[4] = this.data[4];
- out[5] = this.data[5];
- out[6] = this.data[6];
- out[7] = this.data[7];
- out[8] = this.data[8];
-
- return out;
-
- }
-
- /**
- * Sets this Mat3 to the identity matrix.
- * @method identity
- * @param {any} source - The object to copy from.
- * @return {Mat3} This Mat3 object.
- **/
- public identity(): Mat3 {
- return this.setTo(1, 0, 0, 0, 1, 0, 0, 0, 1);
- }
-
- /**
- * Translates this Mat3 by the given vector
- **/
- public translate(v:Phaser.Vec2): Mat3 {
-
- this.a20 = v.x * this.a00 + v.y * this.a10 + this.a20;
- this.a21 = v.x * this.a01 + v.y * this.a11 + this.a21;
- this.a22 = v.x * this.a02 + v.y * this.a12 + this.a22;
-
- return this;
-
- }
-
- private setTemps() {
-
- this._a00 = this.data[0];
- this._a01 = this.data[1];
- this._a02 = this.data[2];
- this._a10 = this.data[3];
- this._a11 = this.data[4];
- this._a12 = this.data[5];
- this._a20 = this.data[6];
- this._a21 = this.data[7];
- this._a22 = this.data[8];
-
- }
-
- /**
- * Rotates this Mat3 by the given angle (given in radians)
- **/
- public rotate(rad:number): Mat3 {
-
- this.setTemps();
-
- var s = GameMath.sinA[rad];
- var c = GameMath.cosA[rad];
-
- this.data[0] = c * this._a00 + s * this._a10;
- this.data[1] = c * this._a01 + s * this._a10;
- this.data[2] = c * this._a02 + s * this._a12;
-
- this.data[3] = c * this._a10 - s * this._a00;
- this.data[4] = c * this._a11 - s * this._a01;
- this.data[5] = c * this._a12 - s * this._a02;
-
- return this;
-
- }
-
- /**
- * Scales this Mat3 by the given vector
- **/
- public scale(v: Vec2): Mat3 {
-
- this.data[0] = v.x * this.data[0];
- this.data[1] = v.x * this.data[1];
- this.data[2] = v.x * this.data[2];
-
- this.data[3] = v.y * this.data[3];
- this.data[4] = v.y * this.data[4];
- this.data[5] = v.y * this.data[5];
-
- return this;
-
- }
-
- public setTo(a00: number, a01: number, a02: number, a10: number, a11: number, a12: number, a20: number, a21: number, a22: number): Mat3 {
-
- this.data[0] = a00;
- this.data[1] = a01;
- this.data[2] = a02;
- this.data[3] = a10;
- this.data[4] = a11;
- this.data[5] = a12;
- this.data[6] = a20;
- this.data[7] = a21;
- this.data[8] = a22;
-
- return this;
-
- }
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {string} a string representation of the object.
- **/
- public toString(): string {
- return '';
- //return "[{Vec2 (x=" + this.x + " y=" + this.y + ")}]";
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/Mat3Utils.ts b/wip/TS Source/math/Mat3Utils.ts
deleted file mode 100644
index 79c88c6e..00000000
--- a/wip/TS Source/math/Mat3Utils.ts
+++ /dev/null
@@ -1,187 +0,0 @@
-///
-
-/**
-* Phaser - Mat3Utils
-*
-* A collection of methods useful for manipulating and performing operations on Mat3 objects.
-*
-*/
-
-module Phaser {
-
- export class Mat3Utils {
-
- /**
- * Transpose the values of a Mat3
- **/
- static transpose(source:Phaser.Mat3, dest:Phaser.Mat3 = null): Mat3 {
-
- if (dest === null)
- {
- // Transpose ourselves
- var a01 = source.data[1];
- var a02 = source.data[2];
- var a12 = source.data[5];
-
- source.data[1] = source.data[3];
- source.data[2] = source.data[6];
- source.data[3] = a01;
- source.data[5] = source.data[7];
- source.data[6] = a02;
- source.data[7] = a12;
- }
- else
- {
- source.data[0] = dest.data[0];
- source.data[1] = dest.data[3];
- source.data[2] = dest.data[6];
- source.data[3] = dest.data[1];
- source.data[4] = dest.data[4];
- source.data[5] = dest.data[7];
- source.data[6] = dest.data[2];
- source.data[7] = dest.data[5];
- source.data[8] = dest.data[8];
- }
-
- return source;
-
- }
-
- /**
- * Inverts a Mat3
- **/
- static invert(source:Phaser.Mat3): Mat3 {
-
- var a00 = source.data[0];
- var a01 = source.data[1];
- var a02 = source.data[2];
- var a10 = source.data[3];
- var a11 = source.data[4];
- var a12 = source.data[5];
- var a20 = source.data[6];
- var a21 = source.data[7];
- var a22 = source.data[8];
-
- var b01 = a22 * a11 - a12 * a21;
- var b11 = -a22 * a10 + a12 * a20;
- var b21 = a21 * a10 - a11 * a20;
-
- // Determinant
- var det = a00 * b01 + a01 * b11 + a02 * b21;
-
- if (!det) {
- return null;
- }
-
- det = 1.0 / det;
-
- source.data[0] = b01 * det;
- source.data[1] = (-a22 * a01 + a02 * a21) * det;
- source.data[2] = (a12 * a01 - a02 * a11) * det;
- source.data[3] = b11 * det;
- source.data[4] = (a22 * a00 - a02 * a20) * det;
- source.data[5] = (-a12 * a00 + a02 * a10) * det;
- source.data[6] = b21 * det;
- source.data[7] = (-a21 * a00 + a01 * a20) * det;
- source.data[8] = (a11 * a00 - a01 * a10) * det;
-
- return source;
-
- }
-
- /**
- * Calculates the adjugate of a Mat3
- **/
- static adjoint(source:Phaser.Mat3): Mat3 {
-
- var a00 = source.data[0];
- var a01 = source.data[1];
- var a02 = source.data[2];
- var a10 = source.data[3];
- var a11 = source.data[4];
- var a12 = source.data[5];
- var a20 = source.data[6];
- var a21 = source.data[7];
- var a22 = source.data[8];
-
- source.data[0] = (a11 * a22 - a12 * a21);
- source.data[1] = (a02 * a21 - a01 * a22);
- source.data[2] = (a01 * a12 - a02 * a11);
- source.data[3] = (a12 * a20 - a10 * a22);
- source.data[4] = (a00 * a22 - a02 * a20);
- source.data[5] = (a02 * a10 - a00 * a12);
- source.data[6] = (a10 * a21 - a11 * a20);
- source.data[7] = (a01 * a20 - a00 * a21);
- source.data[8] = (a00 * a11 - a01 * a10);
-
- return source;
-
- }
-
- /**
- * Calculates the adjugate of a Mat3
- **/
- static determinant(source:Phaser.Mat3): number {
-
- var a00 = source.data[0];
- var a01 = source.data[1];
- var a02 = source.data[2];
- var a10 = source.data[3];
- var a11 = source.data[4];
- var a12 = source.data[5];
- var a20 = source.data[6];
- var a21 = source.data[7];
- var a22 = source.data[8];
-
- return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
-
- }
-
- /**
- * Multiplies two Mat3s
- **/
- static multiply(source:Phaser.Mat3, b:Phaser.Mat3): Mat3 {
-
- var a00 = source.data[0];
- var a01 = source.data[1];
- var a02 = source.data[2];
- var a10 = source.data[3];
- var a11 = source.data[4];
- var a12 = source.data[5];
- var a20 = source.data[6];
- var a21 = source.data[7];
- var a22 = source.data[8];
-
- var b00 = b.data[0];
- var b01 = b.data[1];
- var b02 = b.data[2];
- var b10 = b.data[3];
- var b11 = b.data[4];
- var b12 = b.data[5];
- var b20 = b.data[6];
- var b21 = b.data[7];
- var b22 = b.data[8];
-
- source.data[0] = b00 * a00 + b01 * a10 + b02 * a20;
- source.data[1] = b00 * a01 + b01 * a11 + b02 * a21;
- source.data[2] = b00 * a02 + b01 * a12 + b02 * a22;
-
- source.data[3] = b10 * a00 + b11 * a10 + b12 * a20;
- source.data[4] = b10 * a01 + b11 * a11 + b12 * a21;
- source.data[5] = b10 * a02 + b11 * a12 + b12 * a22;
-
- source.data[6] = b20 * a00 + b21 * a10 + b22 * a20;
- source.data[7] = b20 * a01 + b21 * a11 + b22 * a21;
- source.data[8] = b20 * a02 + b21 * a12 + b22 * a22;
-
- return source;
-
- }
-
- static fromQuaternion() { }
- static normalFromMat4() { }
-
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/QuadTree.ts b/wip/TS Source/math/QuadTree.ts
deleted file mode 100644
index 8358fcc1..00000000
--- a/wip/TS Source/math/QuadTree.ts
+++ /dev/null
@@ -1,660 +0,0 @@
-///
-
-/**
-* Phaser - QuadTree
-*
-* A fairly generic quad tree structure for rapid overlap checks. QuadTree is also configured for single or dual list operation.
-* You can add items either to its A list or its B list. When you do an overlap check, you can compare the A list to itself,
-* or the A list against the B list. Handy for different things!
-*/
-
-module Phaser {
-
- export class QuadTree extends Rectangle {
-
- /**
- * Instantiate a new Quad Tree node.
- *
- * @param {Number} x The X-coordinate of the point in space.
- * @param {Number} y The Y-coordinate of the point in space.
- * @param {Number} width Desired width of this node.
- * @param {Number} height Desired height of this node.
- * @param {Number} parent The parent branch or node. Pass null to create a root.
- */
- //constructor(manager: Phaser.Physics.Manager, x: number, y: number, width: number, height: number, parent: QuadTree = null) {
- constructor(manager, x: number, y: number, width: number, height: number, parent: QuadTree = null) {
-
- super(x, y, width, height);
-
- QuadTree.physics = manager;
-
- this._headA = this._tailA = new Phaser.LinkedList();
- this._headB = this._tailB = new Phaser.LinkedList();
-
- //Copy the parent's children (if there are any)
- if (parent != null)
- {
- if (parent._headA.object != null)
- {
- this._iterator = parent._headA;
-
- while (this._iterator != null)
- {
- if (this._tailA.object != null)
- {
- this._ot = this._tailA;
- this._tailA = new Phaser.LinkedList();
- this._ot.next = this._tailA;
- }
-
- this._tailA.object = this._iterator.object;
- this._iterator = this._iterator.next;
- }
- }
-
- if (parent._headB.object != null)
- {
- this._iterator = parent._headB;
-
- while (this._iterator != null)
- {
- if (this._tailB.object != null)
- {
- this._ot = this._tailB;
- this._tailB = new Phaser.LinkedList();
- this._ot.next = this._tailB;
- }
-
- this._tailB.object = this._iterator.object;
- this._iterator = this._iterator.next;
- }
- }
- }
- else
- {
- QuadTree._min = (this.width + this.height) / (2 * QuadTree.divisions);
- }
-
- this._canSubdivide = (this.width > QuadTree._min) || (this.height > QuadTree._min);
-
- //Set up comparison/sort helpers
- this._northWestTree = null;
- this._northEastTree = null;
- this._southEastTree = null;
- this._southWestTree = null;
- this._leftEdge = this.x;
- this._rightEdge = this.x + this.width;
- this._halfWidth = this.width / 2;
- this._midpointX = this._leftEdge + this._halfWidth;
- this._topEdge = this.y;
- this._bottomEdge = this.y + this.height;
- this._halfHeight = this.height / 2;
- this._midpointY = this._topEdge + this._halfHeight;
-
- }
-
- // Reused temporary vars to help avoid gc spikes
- private _iterator: Phaser.LinkedList;
- private _ot: Phaser.LinkedList;
- private _i;
- private _basic;
- private _members;
- private _l: number;
- private _overlapProcessed: bool;
- private _checkObject;
-
- //public static physics: Phaser.Physics.Manager;
- public static physics;
-
- /**
- * Flag for specifying that you want to add an object to the A list.
- */
- public static A_LIST: number = 0;
-
- /**
- * Flag for specifying that you want to add an object to the B list.
- */
- public static B_LIST: number = 1;
-
- /**
- * Controls the granularity of the quad tree. Default is 6 (decent performance on large and small worlds).
- */
- public static divisions: number;
-
- /**
- * Whether this branch of the tree can be subdivided or not.
- */
- private _canSubdivide: bool;
-
- /**
- * Refers to the internal A and B linked lists,
- * which are used to store objects in the leaves.
- */
- private _headA: Phaser.LinkedList;
-
- /**
- * Refers to the internal A and B linked lists,
- * which are used to store objects in the leaves.
- */
- private _tailA: Phaser.LinkedList;
-
- /**
- * Refers to the internal A and B linked lists,
- * which are used to store objects in the leaves.
- */
- private _headB: Phaser.LinkedList;
-
- /**
- * Refers to the internal A and B linked lists,
- * which are used to store objects in the leaves.
- */
- private _tailB: Phaser.LinkedList;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private static _min: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _northWestTree: QuadTree;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _northEastTree: QuadTree;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _southEastTree: QuadTree;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _southWestTree: QuadTree;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _leftEdge: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _rightEdge: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _topEdge: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _bottomEdge: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _halfWidth: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _halfHeight: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _midpointX: number;
-
- /**
- * Internal, governs and assists with the formation of the tree.
- */
- private _midpointY: number;
-
- /**
- * Internal, used to reduce recursive method parameters during object placement and tree formation.
- */
- private static _object;
-
- /**
- * Internal, used during tree processing and overlap checks.
- */
- private static _list: number;
-
- /**
- * Internal, used during tree processing and overlap checks.
- */
- private static _useBothLists: bool;
-
- /**
- * Internal, used during tree processing and overlap checks.
- */
- private static _processingCallback;
-
- /**
- * Internal, used during tree processing and overlap checks.
- */
- private static _notifyCallback;
-
- /**
- * Internal, used during tree processing and overlap checks.
- */
- private static _callbackContext;
-
- /**
- * Internal, used during tree processing and overlap checks.
- */
- private static _iterator: Phaser.LinkedList;
-
- /**
- * Clean up memory.
- */
- public destroy() {
-
- this._tailA.destroy();
- this._tailB.destroy();
- this._headA.destroy();
- this._headB.destroy();
-
- this._tailA = null;
- this._tailB = null;
- this._headA = null;
- this._headB = null;
-
- if (this._northWestTree != null)
- {
- this._northWestTree.destroy();
- }
-
- if (this._northEastTree != null)
- {
- this._northEastTree.destroy();
- }
-
- if (this._southEastTree != null)
- {
- this._southEastTree.destroy();
- }
-
- if (this._southWestTree != null)
- {
- this._southWestTree.destroy();
- }
-
- this._northWestTree = null;
- this._northEastTree = null;
- this._southEastTree = null;
- this._southWestTree = null;
-
- QuadTree._object = null;
- QuadTree._processingCallback = null;
- QuadTree._notifyCallback = null;
-
- }
-
- /**
- * Load objects and/or groups into the quad tree, and register notify and processing callbacks.
- *
- * @param {} objectOrGroup1 Any object that is or extends IGameObject or Group.
- * @param {} objectOrGroup2 Any object that is or extends IGameObject or Group. If null, the first parameter will be checked against itself.
- * @param {Function} notifyCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject) that is called whenever two objects are found to overlap in world space, and either no processCallback is specified, or the processCallback returns true.
- * @param {Function} processCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject):bool that is called whenever two objects are found to overlap in world space. The notifyCallback is only called if this function returns true. See GameObject.separate().
- * @param context The context in which the callbacks will be called
- */
- public load(objectOrGroup1, objectOrGroup2 = null, notifyCallback = null, processCallback = null, context = null) {
-
- this.add(objectOrGroup1, QuadTree.A_LIST);
-
- if (objectOrGroup2 != null)
- {
- this.add(objectOrGroup2, QuadTree.B_LIST);
- QuadTree._useBothLists = true;
- }
- else
- {
- QuadTree._useBothLists = false;
- }
-
- QuadTree._notifyCallback = notifyCallback;
- QuadTree._processingCallback = processCallback;
- QuadTree._callbackContext = context;
-
- }
-
- /**
- * Call this function to add an object to the root of the tree.
- * This function will recursively add all group members, but
- * not the groups themselves.
- *
- * @param {} objectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly.
- * @param {Number} list A uint flag indicating the list to which you want to add the objects. Options are QuadTree.A_LIST and QuadTree.B_LIST.
- */
- public add(objectOrGroup, list: number) {
-
- QuadTree._list = list;
-
- if (objectOrGroup.type == Types.GROUP)
- {
- this._i = 0;
- this._members = objectOrGroup['members'];
- this._l = objectOrGroup['length'];
-
- while (this._i < this._l)
- {
- this._basic = this._members[this._i++];
-
- if (this._basic != null && this._basic.exists)
- {
- if (this._basic.type == Phaser.Types.GROUP)
- {
- this.add(this._basic, list);
- }
- else
- {
- QuadTree._object = this._basic;
-
- if (QuadTree._object.exists && QuadTree._object.body.allowCollisions)
- {
- this.addObject();
- }
- }
- }
- }
- }
- else
- {
- QuadTree._object = objectOrGroup;
-
- if (QuadTree._object.exists && QuadTree._object.body.allowCollisions)
- {
- this.addObject();
- }
- }
- }
-
- /**
- * Internal function for recursively navigating and creating the tree
- * while adding objects to the appropriate nodes.
- */
- private addObject() {
-
- //If this quad (not its children) lies entirely inside this object, add it here
- if (!this._canSubdivide || ((this._leftEdge >= QuadTree._object.body.bounds.x) && (this._rightEdge <= QuadTree._object.body.bounds.right) && (this._topEdge >= QuadTree._object.body.bounds.y) && (this._bottomEdge <= QuadTree._object.body.bounds.bottom)))
- {
- this.addToList();
- return;
- }
-
- //See if the selected object fits completely inside any of the quadrants
- if ((QuadTree._object.body.bounds.x > this._leftEdge) && (QuadTree._object.body.bounds.right < this._midpointX))
- {
- if ((QuadTree._object.body.bounds.y > this._topEdge) && (QuadTree._object.body.bounds.bottom < this._midpointY))
- {
- if (this._northWestTree == null)
- {
- this._northWestTree = new QuadTree(QuadTree.physics, this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
- }
-
- this._northWestTree.addObject();
- return;
- }
-
- if ((QuadTree._object.body.bounds.y > this._midpointY) && (QuadTree._object.body.bounds.bottom < this._bottomEdge))
- {
- if (this._southWestTree == null)
- {
- this._southWestTree = new QuadTree(QuadTree.physics, this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
- }
-
- this._southWestTree.addObject();
- return;
- }
- }
-
- if ((QuadTree._object.body.bounds.x > this._midpointX) && (QuadTree._object.body.bounds.right < this._rightEdge))
- {
- if ((QuadTree._object.body.bounds.y > this._topEdge) && (QuadTree._object.body.bounds.bottom < this._midpointY))
- {
- if (this._northEastTree == null)
- {
- this._northEastTree = new QuadTree(QuadTree.physics, this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
- }
-
- this._northEastTree.addObject();
- return;
- }
-
- if ((QuadTree._object.body.bounds.y > this._midpointY) && (QuadTree._object.body.bounds.bottom < this._bottomEdge))
- {
- if (this._southEastTree == null)
- {
- this._southEastTree = new QuadTree(QuadTree.physics, this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
- }
-
- this._southEastTree.addObject();
- return;
- }
- }
-
- //If it wasn't completely contained we have to check out the partial overlaps
- if ((QuadTree._object.body.bounds.right > this._leftEdge) && (QuadTree._object.body.bounds.x < this._midpointX) && (QuadTree._object.body.bounds.bottom > this._topEdge) && (QuadTree._object.body.bounds.y < this._midpointY))
- {
- if (this._northWestTree == null)
- {
- this._northWestTree = new QuadTree(QuadTree.physics, this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
- }
-
- this._northWestTree.addObject();
- }
-
- if ((QuadTree._object.body.bounds.right > this._midpointX) && (QuadTree._object.body.bounds.x < this._rightEdge) && (QuadTree._object.body.bounds.bottom > this._topEdge) && (QuadTree._object.body.bounds.y < this._midpointY))
- {
- if (this._northEastTree == null)
- {
- this._northEastTree = new QuadTree(QuadTree.physics, this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
- }
-
- this._northEastTree.addObject();
- }
-
- if ((QuadTree._object.body.bounds.right > this._midpointX) && (QuadTree._object.body.bounds.x < this._rightEdge) && (QuadTree._object.body.bounds.bottom > this._midpointY) && (QuadTree._object.body.bounds.y < this._bottomEdge))
- {
- if (this._southEastTree == null)
- {
- this._southEastTree = new QuadTree(QuadTree.physics, this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
- }
-
- this._southEastTree.addObject();
- }
-
- if ((QuadTree._object.body.bounds.right > this._leftEdge) && (QuadTree._object.body.bounds.x < this._midpointX) && (QuadTree._object.body.bounds.bottom > this._midpointY) && (QuadTree._object.body.bounds.y < this._bottomEdge))
- {
- if (this._southWestTree == null)
- {
- this._southWestTree = new QuadTree(QuadTree.physics, this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
- }
-
- this._southWestTree.addObject();
- }
-
- }
-
- /**
- * Internal function for recursively adding objects to leaf lists.
- */
- private addToList() {
-
- if (QuadTree._list == QuadTree.A_LIST)
- {
- if (this._tailA.object != null)
- {
- this._ot = this._tailA;
- this._tailA = new LinkedList();
- this._ot.next = this._tailA;
- }
-
- this._tailA.object = QuadTree._object;
- }
- else
- {
- if (this._tailB.object != null)
- {
- this._ot = this._tailB;
- this._tailB = new LinkedList();
- this._ot.next = this._tailB;
- }
-
- this._tailB.object = QuadTree._object;
- }
-
- if (!this._canSubdivide)
- {
- return;
- }
-
- if (this._northWestTree != null)
- {
- this._northWestTree.addToList();
- }
-
- if (this._northEastTree != null)
- {
- this._northEastTree.addToList();
- }
-
- if (this._southEastTree != null)
- {
- this._southEastTree.addToList();
- }
-
- if (this._southWestTree != null)
- {
- this._southWestTree.addToList();
- }
-
- }
-
- /**
- * QuadTree's other main function. Call this after adding objects
- * using QuadTree.load() to compare the objects that you loaded.
- *
- * @return {bool} Whether or not any overlaps were found.
- */
- public execute(): bool {
-
- this._overlapProcessed = false;
-
- if (this._headA.object != null)
- {
- this._iterator = this._headA;
-
- while (this._iterator != null)
- {
- QuadTree._object = this._iterator.object;
-
- if (QuadTree._useBothLists)
- {
- QuadTree._iterator = this._headB;
- }
- else
- {
- QuadTree._iterator = this._iterator.next;
- }
-
- if (QuadTree._object.exists && (QuadTree._object.body.allowCollisions > 0) && (QuadTree._iterator != null) && (QuadTree._iterator.object != null) && QuadTree._iterator.object.exists && this.overlapNode())
- {
- this._overlapProcessed = true;
- }
-
- this._iterator = this._iterator.next;
-
- }
- }
-
- //Advance through the tree by calling overlap on each child
- if ((this._northWestTree != null) && this._northWestTree.execute())
- {
- this._overlapProcessed = true;
- }
-
- if ((this._northEastTree != null) && this._northEastTree.execute())
- {
- this._overlapProcessed = true;
- }
-
- if ((this._southEastTree != null) && this._southEastTree.execute())
- {
- this._overlapProcessed = true;
- }
-
- if ((this._southWestTree != null) && this._southWestTree.execute())
- {
- this._overlapProcessed = true;
- }
-
- return this._overlapProcessed;
-
- }
-
- /**
- * A private for comparing an object against the contents of a node.
- *
- * @return {bool} Whether or not any overlaps were found.
- */
- private overlapNode(): bool {
-
- //Walk the list and check for overlaps
- this._overlapProcessed = false;
-
- while (QuadTree._iterator != null)
- {
- if (!QuadTree._object.exists || (QuadTree._object.body.allowCollisions <= 0))
- {
- break;
- }
-
- this._checkObject = QuadTree._iterator.object;
-
- if ((QuadTree._object === this._checkObject) || !this._checkObject.exists || (this._checkObject.body.allowCollisions <= 0))
- {
- QuadTree._iterator = QuadTree._iterator.next;
- continue;
- }
-
- /*
- if (QuadTree.physics.checkHullIntersection(QuadTree._object.body, this._checkObject.body))
- {
- //Execute callback functions if they exist
- if ((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, this._checkObject))
- {
- this._overlapProcessed = true;
- }
-
- if (this._overlapProcessed && (QuadTree._notifyCallback != null))
- {
- if (QuadTree._callbackContext !== null)
- {
- QuadTree._notifyCallback.call(QuadTree._callbackContext, QuadTree._object, this._checkObject);
- }
- else
- {
- QuadTree._notifyCallback(QuadTree._object, this._checkObject);
- }
- }
- }
- */
-
- QuadTree._iterator = QuadTree._iterator.next;
-
- }
-
- return this._overlapProcessed;
-
- }
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/RandomDataGenerator.ts b/wip/TS Source/math/RandomDataGenerator.ts
deleted file mode 100644
index befe1217..00000000
--- a/wip/TS Source/math/RandomDataGenerator.ts
+++ /dev/null
@@ -1,284 +0,0 @@
-///
-
-/**
-* Phaser - RandomDataGenerator
-*
-* An extremely useful repeatable random data generator. Access it via Game.rnd
-* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense
-* Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
-*/
-
-module Phaser {
-
- export class RandomDataGenerator {
-
- /**
- * @constructor
- * @param {Array} seeds
- * @return {Phaser.RandomDataGenerator}
- */
- constructor(seeds: string[]= []) {
-
- this.sow(seeds);
-
- }
-
- /**
- * @property s0
- * @type Any
- * @private
- */
- private s0;
-
- /**
- * @property s1
- * @type Any
- * @private
- */
- private s1;
-
- /**
- * @property s2
- * @type Any
- * @private
- */
- private s2;
-
- /**
- * @property c
- * @type Number
- * @private
- */
- private c: number = 1;
-
- /**
- * @method uint32
- * @private
- */
- private uint32(): number {
-
- return this.rnd.apply(this) * 0x100000000; // 2^32
-
- }
-
- /**
- * @method fract32
- * @private
- */
- private fract32(): number {
-
- return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
-
- }
-
- // private random helper
- /**
- * @method rnd
- * @private
- */
- private rnd(): number {
-
- var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32
-
- this.c = t | 0;
- this.s0 = this.s1;
- this.s1 = this.s2;
- this.s2 = t - this.c;
-
- return this.s2;
- }
-
- /**
- * @method hash
- * @param {Any} data
- * @private
- */
- private hash(data) {
-
- var h, i, n;
-
- n = 0xefc8249d;
-
- data = data.toString();
-
- for (i = 0; i < data.length; i++)
- {
- n += data.charCodeAt(i);
- h = 0.02519603282416938 * n;
- n = h >>> 0;
- h -= n;
- h *= n;
- n = h >>> 0;
- h -= n;
- n += h * 0x100000000; // 2^32
- }
-
- return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
-
- }
-
- /**
- * Reset the seed of the random data generator
- * @method sow
- * @param {Array} seeds
- */
- public sow(seeds: string[]= []) {
-
- this.s0 = this.hash(' ');
- this.s1 = this.hash(this.s0);
- this.s2 = this.hash(this.s1);
-
- var seed;
-
- for (var i = 0; seed = seeds[i++];)
- {
- this.s0 -= this.hash(seed);
- this.s0 += ~~(this.s0 < 0);
-
- this.s1 -= this.hash(seed);
- this.s1 += ~~(this.s1 < 0);
-
- this.s2 -= this.hash(seed);
- this.s2 += ~~(this.s2 < 0);
- }
-
- }
-
- /**
- * Returns a random integer between 0 and 2^32
- * @method integer
- * @return {Number}
- */
- public get integer(): number {
-
- return this.uint32();
-
- }
-
- /**
- * Returns a random real number between 0 and 1
- * @method frac
- * @return {Number}
- */
- public get frac(): number {
-
- return this.fract32();
-
- }
-
- /**
- * Returns a random real number between 0 and 2^32
- * @method real
- * @return {Number}
- */
- public get real(): number {
-
- return this.uint32() + this.fract32();
-
- }
-
- /**
- * Returns a random integer between min and max
- * @method integerInRange
- * @param {Number} min
- * @param {Number} max
- * @return {Number}
- */
- public integerInRange(min: number, max: number): number {
-
- return Math.floor(this.realInRange(min, max));
-
- }
-
- /**
- * Returns a random real number between min and max
- * @method realInRange
- * @param {Number} min
- * @param {Number} max
- * @return {Number}
- */
- public realInRange(min: number, max: number): number {
-
- min = min || 0;
- max = max || 0;
-
- return this.frac * (max - min) + min;
-
- }
-
- /**
- * Returns a random real number between -1 and 1
- * @method normal
- * @return {Number}
- */
- public get normal(): number {
-
- return 1 - 2 * this.frac;
-
- }
-
- /**
- * Returns a valid v4 UUID hex string (from https://gist.github.com/1308368)
- * @method uuid
- * @return {String}
- */
- public get uuid(): string {
-
- var a, b;
-
- for (
- b = a = '';
- a++ < 36;
- b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-'
- );
-
- return b;
- }
-
- /**
- * Returns a random member of `array`
- * @method pick
- * @param {Any} array
- */
- public pick(array) {
-
- return array[this.integerInRange(0, array.length)];
-
- }
-
- /**
- * Returns a random member of `array`, favoring the earlier entries
- * @method weightedPick
- * @param {Any} array
- */
- public weightedPick(array) {
-
- return array[~~(Math.pow(this.frac, 2) * array.length)];
-
- }
-
- /**
- * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified
- * @method timestamp
- * @param {Number} min
- * @param {Number} max
- */
- public timestamp(min: number = 946684800000, max: number = 1577862000000): number {
-
- return this.realInRange(min, max);
-
- }
-
- /**
- * Returns a random angle between -180 and 180
- * @method angle
- */
- public get angle(): number {
-
- return this.integerInRange(-180, 180);
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/Vec2.ts b/wip/TS Source/math/Vec2.ts
deleted file mode 100644
index 7b296cd5..00000000
--- a/wip/TS Source/math/Vec2.ts
+++ /dev/null
@@ -1,298 +0,0 @@
-///
-
-/**
-* Phaser - Vec2
-*
-* A Vector 2
-*/
-
-module Phaser {
-
- export class Vec2 {
-
- /**
- * Creates a new Vec2 object.
- * @class Vec2
- * @constructor
- * @param {Number} x The x position of the vector
- * @param {Number} y The y position of the vector
- * @return {Vec2} This object
- **/
- constructor(x: number = 0, y: number = 0) {
-
- this.x = x;
- this.y = y;
-
- return this;
-
- }
-
- /**
- * The x coordinate of the vector
- * @property x
- * @type Number
- **/
- public x: number;
-
- /**
- * The y coordinate of the vector
- * @property y
- * @type Number
- **/
- public y: number;
-
- /**
- * Copies the x and y properties from any given object to this Vec2.
- * @method copyFrom
- * @param {any} source - The object to copy from.
- * @return {Vec2} This Vec2 object.
- **/
- public copyFrom(source: any): Phaser.Vec2 {
- return this.setTo(source.x, source.y);
- }
-
- /**
- * Sets the x and y properties of the Vector.
- * @param {Number} x The x position of the vector
- * @param {Number} y The y position of the vector
- * @return {Vec2} This object
- **/
- public setTo(x: number, y: number): Phaser.Vec2 {
-
- this.x = x;
- this.y = y;
- return this;
-
- }
-
- /**
- * Add another vector to this one.
- *
- * @param {Vec2} other The other Vector.
- * @return {Vec2} This for chaining.
- */
- public add(a: Phaser.Vec2): Phaser.Vec2 {
-
- this.x += a.x;
- this.y += a.y;
- return this;
-
- }
-
- /**
- * Subtract another vector from this one.
- *
- * @param {Vec2} other The other Vector.
- * @return {Vec2} This for chaining.
- */
- public subtract(v: Phaser.Vec2): Phaser.Vec2 {
-
- this.x -= v.x;
- this.y -= v.y;
- return this;
-
- }
-
- /**
- * Multiply another vector with this one.
- *
- * @param {Vec2} other The other Vector.
- * @return {Vec2} This for chaining.
- */
- public multiply(v: Phaser.Vec2): Phaser.Vec2 {
-
- this.x *= v.x;
- this.y *= v.y;
- return this;
-
- }
-
- /**
- * Divide this vector by another one.
- *
- * @param {Vec2} other The other Vector.
- * @return {Vec2} This for chaining.
- */
- public divide(v: Phaser.Vec2): Phaser.Vec2 {
-
- this.x /= v.x;
- this.y /= v.y;
- return this;
-
- }
-
- /**
- * Get the length of this vector.
- *
- * @return {number} The length of this vector.
- */
- public length(): number {
- return Math.sqrt((this.x * this.x) + (this.y * this.y));
- }
-
- /**
- * Get the length squared of this vector.
- *
- * @return {number} The length^2 of this vector.
- */
- public lengthSq(): number {
- return (this.x * this.x) + (this.y * this.y);
- }
-
- /**
- * Normalize this vector.
- *
- * @return {Vec2} This for chaining.
- */
- public normalize(): Phaser.Vec2 {
-
- var inv = (this.x != 0 || this.y != 0) ? 1 / Math.sqrt(this.x * this.x + this.y * this.y) : 0;
- this.x *= inv;
- this.y *= inv;
- return this;
-
- }
-
- /**
- * The dot product of two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @return {Number}
- */
- public dot(a: Phaser.Vec2): number {
- return ((this.x * a.x) + (this.y * a.y));
- }
-
- /**
- * The cross product of two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @return {Number}
- */
- public cross(a: Phaser.Vec2): number {
- return ((this.x * a.y) - (this.y * a.x));
- }
-
- /**
- * The projection magnitude of two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @return {Number}
- */
- public projectionLength(a: Phaser.Vec2): number {
-
- var den: number = a.dot(a);
-
- if (den == 0)
- {
- return 0;
- }
- else
- {
- return Math.abs(this.dot(a) / den);
- }
-
- }
-
- /**
- * The angle between two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @return {Number}
- */
- public angle(a: Phaser.Vec2): number {
- return Math.atan2(a.x * this.y - a.y * this.x, a.x * this.x + a.y * this.y);
- }
-
- /**
- * Scale this vector.
- *
- * @param {number} x The scaling factor in the x direction.
- * @param {?number=} y The scaling factor in the y direction. If this is not specified, the x scaling factor will be used.
- * @return {Vec2} This for chaining.
- */
- public scale(x: number, y: number): Phaser.Vec2 {
-
- this.x *= x;
- this.y *= y || x;
- return this;
-
- }
-
- /**
- * Multiply this vector by the given scalar.
- *
- * @param {number} scalar
- * @return {Vec2} This for chaining.
- */
- public multiplyByScalar(scalar: number): Phaser.Vec2 {
-
- this.x *= scalar;
- this.y *= scalar;
- return this;
-
- }
-
- /**
- * Adds the given vector to this vector then multiplies by the given scalar.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {number} scalar
- * @return {Vec2} This for chaining.
- */
- public multiplyAddByScalar(a: Phaser.Vec2, scalar: number): Phaser.Vec2 {
-
- this.x += a.x * scalar;
- this.y += a.y * scalar;
- return this;
-
- }
-
- /**
- * Divide this vector by the given scalar.
- *
- * @param {number} scalar
- * @return {Vec2} This for chaining.
- */
- public divideByScalar(scalar: number): Phaser.Vec2 {
-
- this.x /= scalar;
- this.y /= scalar;
- return this;
-
- }
-
- /**
- * Reverse this vector.
- *
- * @return {Vec2} This for chaining.
- */
- public reverse(): Phaser.Vec2 {
-
- this.x = -this.x;
- this.y = -this.y;
- return this;
-
- }
-
- /**
- * Check if both the x and y of this vector equal the given value.
- *
- * @return {bool}
- */
- public equals(value): bool {
- return (this.x == value && this.y == value);
- }
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {string} a string representation of the object.
- **/
- public toString(): string {
- return "[{Vec2 (x=" + this.x + " y=" + this.y + ")}]";
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/math/Vec2Utils.ts b/wip/TS Source/math/Vec2Utils.ts
deleted file mode 100644
index 134f57a7..00000000
--- a/wip/TS Source/math/Vec2Utils.ts
+++ /dev/null
@@ -1,371 +0,0 @@
-///
-
-/**
-* Phaser - Vec2Utils
-*
-* A collection of methods useful for manipulating and performing operations on 2D vectors.
-*
-*/
-
-module Phaser {
-
- export class Vec2Utils {
-
- /**
- * Adds two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the sum of the two vectors.
- */
- static add(a: Vec2, b: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.x + b.x, a.y + b.y);
- }
-
- /**
- * Subtracts two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the difference of the two vectors.
- */
- static subtract(a: Vec2, b: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.x - b.x, a.y - b.y);
- }
-
- /**
- * Multiplies two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the sum of the two vectors multiplied.
- */
- static multiply(a: Vec2, b: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.x * b.x, a.y * b.y);
- }
-
- /**
- * Divides two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the sum of the two vectors divided.
- */
- static divide(a: Vec2, b: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.x / b.x, a.y / b.y);
- }
-
- /**
- * Scales a 2D vector.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {number} s Scaling value.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the scaled vector.
- */
- static scale(a: Phaser.Vec2, s: number, out: Phaser.Vec2 = new Phaser.Vec2): Phaser.Vec2 {
- return out.setTo(a.x * s, a.y * s);
- }
-
- /**
- * Adds two 2D vectors together and multiplies the result by the given scalar.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {number} s Scaling value.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the sum of the two vectors added and multiplied.
- */
- static multiplyAdd(a: Vec2, b: Vec2, s: number, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.x + b.x * s, a.y + b.y * s);
- }
-
- /**
- * Return a negative vector.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the negative vector.
- */
- static negative(a: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(-a.x, -a.y);
- }
-
- /**
- * Return a perpendicular vector (90 degrees rotation)
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the scaled vector.
- */
- static perp(a: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(-a.y, a.x);
- }
-
- /**
- * Return a perpendicular vector (-90 degrees rotation)
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is the scaled vector.
- */
- static rperp(a: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.y, -a.x);
- }
-
- /**
- * Checks if two 2D vectors are equal.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @return {bool}
- */
- static equals(a: Vec2, b: Vec2): bool {
- return a.x == b.x && a.y == b.y;
- }
-
- /**
- *
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Vec2} epsilon
- * @return {bool}
- */
- static epsilonEquals(a: Vec2, b: Vec2, epsilon: number): bool {
- return Math.abs(a.x - b.x) <= epsilon && Math.abs(a.y - b.y) <= epsilon;
- }
-
- /**
- * Get the distance between two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @return {Number}
- */
- static distance(a: Vec2, b: Vec2): number {
- return Math.sqrt(Vec2Utils.distanceSq(a, b));
- }
-
- /**
- * Get the distance squared between two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @return {Number}
- */
- static distanceSq(a: Vec2, b: Vec2): number {
- return ((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y));
- }
-
- /**
- * Project two 2D vectors onto another vector.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2.
- */
- static project(a: Vec2, b: Vec2, out: Vec2 = new Vec2): Vec2 {
-
- var amt = a.dot(b) / b.lengthSq();
-
- if (amt != 0)
- {
- out.setTo(amt * b.x, amt * b.y);
- }
-
- return out;
-
- }
-
- /**
- * Project this vector onto a vector of unit length.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2.
- */
- static projectUnit(a: Vec2, b: Vec2, out: Vec2 = new Vec2): Vec2 {
-
- var amt = a.dot(b);
-
- if (amt != 0)
- {
- out.setTo(amt * b.x, amt * b.y);
- }
-
- return out;
-
- }
-
- /**
- * Right-hand normalize (make unit length) a 2D vector.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2.
- */
- static normalRightHand(a: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.y * -1, a.x);
- }
-
- /**
- * Normalize (make unit length) a 2D vector.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2.
- */
- static normalize(a: Vec2, out: Vec2 = new Vec2): Vec2 {
-
- var m = a.length();
-
- if (m != 0)
- {
- out.setTo(a.x / m, a.y / m);
- }
-
- return out;
- }
-
- /**
- * The dot product of two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @return {Number}
- */
- static dot(a: Vec2, b: Vec2): number {
- return ((a.x * b.x) + (a.y * b.y));
- }
-
- /**
- * The cross product of two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @return {Number}
- */
- static cross(a: Vec2, b: Vec2): number {
- return ((a.x * b.y) - (a.y * b.x));
- }
-
- /**
- * The angle between two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @return {Number}
- */
- static angle(a: Vec2, b: Vec2): number {
- return Math.atan2(a.x * b.y - a.y * b.x, a.x * b.x + a.y * b.y);
- }
-
- /**
- * The angle squared between two 2D vectors.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @return {Number}
- */
- static angleSq(a: Vec2, b: Vec2): number {
- return a.subtract(b).angle(b.subtract(a));
- }
-
- /**
- * Rotate a 2D vector around the origin to the given angle (theta).
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Number} theta The angle of rotation in radians.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2.
- */
- static rotateAroundOrigin(a: Vec2, b: Vec2, theta: number, out: Vec2 = new Vec2): Vec2 {
- var x = a.x - b.x;
- var y = a.y - b.y;
- return out.setTo(x * Math.cos(theta) - y * Math.sin(theta) + b.x, x * Math.sin(theta) + y * Math.cos(theta) + b.y);
- }
-
- /**
- * Rotate a 2D vector to the given angle (theta).
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} b Reference to a source Vec2 object.
- * @param {Number} theta The angle of rotation in radians.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2.
- */
- static rotate(a: Vec2, theta: number, out: Vec2 = new Vec2): Vec2 {
-
- var c = Math.cos(theta);
- var s = Math.sin(theta);
-
- return out.setTo(a.x * c - a.y * s, a.x * s + a.y * c);
-
- }
-
- /**
- * Clone a 2D vector.
- *
- * @param {Vec2} a Reference to a source Vec2 object.
- * @param {Vec2} out The output Vec2 that is the result of the operation.
- * @return {Vec2} A Vec2 that is a copy of the source Vec2.
- */
- static clone(a: Vec2, out: Vec2 = new Vec2): Vec2 {
- return out.setTo(a.x, a.y);
- }
-
- /**
- * Reflect this vector on an arbitrary axis.
- *
- * @param {Vec2} axis The vector representing the axis.
- * @return {Vec2} This for chaining.
- */
- /*
- static reflect(axis): Vec2 {
-
- var x = this.x;
- var y = this.y;
- this.project(axis).scale(2);
- this.x -= x;
- this.y -= y;
-
- return this;
-
- }
- */
-
- /**
- * Reflect this vector on an arbitrary axis (represented by a unit vector)
- *
- * @param {Vec2} axis The unit vector representing the axis.
- * @return {Vec2} This for chaining.
- */
- /*
- static reflectN(axis): Vec2 {
-
- var x = this.x;
- var y = this.y;
- this.projectN(axis).scale(2);
- this.x -= x;
- this.y -= y;
-
- return this;
-
- }
-
- static getMagnitude(): number {
- return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
- }
- */
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/net/Net.ts b/wip/TS Source/net/Net.ts
deleted file mode 100644
index 5162cbfe..00000000
--- a/wip/TS Source/net/Net.ts
+++ /dev/null
@@ -1,135 +0,0 @@
-///
-
-/**
-* Phaser - Net
-*
-*
-*/
-
-module Phaser {
-
- export class Net {
-
- /**
- * Net constructor
- */
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- }
-
- /**
- * Local reference to the current Phaser.Game.
- */
- public game: Phaser.Game;
-
- /**
- * Compares the given domain name against the hostname of the browser containing the game.
- * If the domain name is found it returns true.
- * You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc.
- * Do not include 'http://' at the start.
- */
- public checkDomainName(domain: string): bool {
- return window.location.hostname.indexOf(domain) !== -1;
- }
-
- /**
- * Updates a value on the Query String and returns it in full.
- * If the value doesn't already exist it is set.
- * If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string.
- * Optionally you can redirect to the new url, or just return it as a string.
- */
- public updateQueryString(key: string, value: string, redirect:bool = false, url: string = ''):string {
-
- if (url == '')
- {
- url = window.location.href;
- }
-
- var output: string = '';
-
- var re:RegExp = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi");
-
- if (re.test(url))
- {
- if (typeof value !== 'undefined' && value !== null)
- {
- output = url.replace(re, '$1' + key + "=" + value + '$2$3');
- }
- else
- {
- output = url.replace(re, '$1$3').replace(/(&|\?)$/, '');
- }
- }
- else
- {
- if (typeof value !== 'undefined' && value !== null)
- {
- var separator = url.indexOf('?') !== -1 ? '&' : '?';
- var hash = url.split('#');
-
- url = hash[0] + separator + key + '=' + value;
-
- if (hash[1])
- {
- url += '#' + hash[1];
- }
-
- output = url;
- }
- else
- {
- output = url;
- }
- }
-
- if (redirect)
- {
- window.location.href = output;
- }
- else
- {
- return output;
- }
-
- }
-
- /**
- * Returns the Query String as an object.
- * If you specify a parameter it will return just the value of that parameter, should it exist.
- */
- public getQueryString(parameter: string = '') {
-
- var output = {};
- var keyValues = location.search.substring(1).split('&');
-
- for (var i in keyValues)
- {
- var key = keyValues[i].split('=');
-
- if (key.length > 1)
- {
- if (parameter && parameter == this.decodeURI(key[0]))
- {
- return this.decodeURI(key[1]);
- }
- else
- {
- output[this.decodeURI(key[0])] = this.decodeURI(key[1]);
- }
- }
- }
-
- return output;
-
- }
-
- private decodeURI(value: string): string {
- return decodeURIComponent(value.replace(/\+/g, " "));
- }
-
-
- }
-
-}
diff --git a/wip/TS Source/particles/Emitter.js b/wip/TS Source/particles/Emitter.js
deleted file mode 100644
index 050537d8..00000000
--- a/wip/TS Source/particles/Emitter.js
+++ /dev/null
@@ -1,288 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var Emitter = (function () {
- /**
- * You can use this emit particles.
- *
- * It will dispatch follow events:
- * Proton.PARTICLE_CREATED
- * Proton.PARTICLE_UPDATA
- * Proton.PARTICLE_DEAD
- *
- * @class Proton.Emitter
- * @constructor
- * @param {Object} pObj the parameters object;
- * for example {damping:0.01,bindEmitter:false}
- */
- function Emitter(pObj) {
- this.initializes = [];
- this.particles = [];
- this.behaviours = [];
- this.emitTime = 0;
- this.emitTotalTimes = -1;
- this.initializes = [];
- this.particles = [];
- this.behaviours = [];
- this.emitTime = 0;
- this.emitTotalTimes = -1;
- /**
- * The friction coefficient for all particle emit by This;
- * @property damping
- * @type {Number}
- * @default 0.006
- */
- this.damping = .006;
- /**
- * If bindEmitter the particles can bind this emitter's property;
- * @property bindEmitter
- * @type {bool}
- * @default true
- */
- this.bindEmitter = true;
- /**
- * The number of particles per second emit (a [particle]/b [s]);
- * @property rate
- * @type {Proton.Rate}
- * @default Proton.Rate(1, .1)
- */
- this.rate = new Phaser.Particles.Initializers.Rate(1, .1);
- //Emitter._super_.call(this, pObj);
- /**
- * The emitter's id;
- * @property id
- * @type {String} id
- */
- this.id = 'emitter_' + Emitter.ID++;
- }
- Emitter.ID = 0;
- Emitter.prototype.emit = /**
- * start emit particle
- * @method emit
- * @param {Number} emitTime begin emit time;
- * @param {String} life the life of this emitter
- */
- function (emitTime, life) {
- this.emitTime = 0;
- this.emitTotalTimes = Particles.ParticleUtils.initValue(emitTime, Infinity);
- if(life == true || life == 'life' || life == 'destroy') {
- if(emitTime == 'once') {
- this.life = 1;
- } else {
- this.life = this.emitTotalTimes;
- }
- } else if(!isNaN(life)) {
- this.life = life;
- }
- this.rate.init();
- };
- Emitter.prototype.stopEmit = /**
- * stop emiting
- * @method stopEmit
- */
- function () {
- this.emitTotalTimes = -1;
- this.emitTime = 0;
- };
- Emitter.prototype.removeAllParticles = /**
- * remove current all particles
- * @method removeAllParticles
- */
- function () {
- for(var i = 0; i < this.particles.length; i++) {
- this.particles[i].dead = true;
- }
- };
- Emitter.prototype.createParticle = /**
- * create single particle;
- *
- * can use emit({x:10},new Gravity(10),{'particleUpdate',fun}) or emit([{x:10},new Initialize],new Gravity(10),{'particleUpdate',fun})
- * @method removeAllParticles
- */
- function (initialize, behaviour) {
- if (typeof initialize === "undefined") { initialize = null; }
- if (typeof behaviour === "undefined") { behaviour = null; }
- var particle = Particles.ParticleManager.pool.get();
- this.setupParticle(particle, initialize, behaviour);
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PARTICLE_CREATED,
- // particle: particle
- //}));
- return particle;
- };
- Emitter.prototype.addSelfInitialize = /**
- * add initialize to this emitter
- * @method addSelfInitialize
- */
- function (pObj) {
- if(pObj['init']) {
- pObj.init(this);
- } else {
- //this.initAll();
- }
- };
- Emitter.prototype.addInitialize = /**
- * add the Initialize to particles;
- *
- * you can use initializes array:for example emitter.addInitialize(initialize1,initialize2,initialize3);
- * @method addInitialize
- * @param {Proton.Initialize} initialize like this new Proton.Radius(1, 12)
- */
- function () {
- var length = arguments.length, i;
- for(i = 0; i < length; i++) {
- this.initializes.push(arguments[i]);
- }
- };
- Emitter.prototype.removeInitialize = /**
- * remove the Initialize
- * @method removeInitialize
- * @param {Proton.Initialize} initialize a initialize
- */
- function (initializer) {
- var index = this.initializes.indexOf(initializer);
- if(index > -1) {
- this.initializes.splice(index, 1);
- }
- };
- Emitter.prototype.removeInitializers = /**
- * remove all Initializes
- * @method removeInitializers
- */
- function () {
- Particles.ParticleUtils.destroyArray(this.initializes);
- };
- Emitter.prototype.addBehaviour = /**
- * add the Behaviour to particles;
- *
- * you can use Behaviours array:emitter.addBehaviour(Behaviour1,Behaviour2,Behaviour3);
- * @method addBehaviour
- * @param {Proton.Behaviour} behaviour like this new Proton.Color('random')
- */
- function () {
- var length = arguments.length, i;
- for(i = 0; i < length; i++) {
- this.behaviours.push(arguments[i]);
- if(arguments[i].hasOwnProperty("parents")) {
- arguments[i].parents.push(this);
- }
- }
- };
- Emitter.prototype.removeBehaviour = /**
- * remove the Behaviour
- * @method removeBehaviour
- * @param {Proton.Behaviour} behaviour a behaviour
- */
- function (behaviour) {
- var index = this.behaviours.indexOf(behaviour);
- if(index > -1) {
- this.behaviours.splice(index, 1);
- }
- };
- Emitter.prototype.removeAllBehaviours = /**
- * remove all behaviours
- * @method removeAllBehaviours
- */
- function () {
- Particles.ParticleUtils.destroyArray(this.behaviours);
- };
- Emitter.prototype.integrate = function (time) {
- var damping = 1 - this.damping;
- Particles.ParticleManager.integrator.integrate(this, time, damping);
- var length = this.particles.length, i;
- for(i = 0; i < length; i++) {
- var particle = this.particles[i];
- particle.update(time, i);
- Particles.ParticleManager.integrator.integrate(particle, time, damping);
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PARTICLE_UPDATE,
- // particle: particle
- //}));
- }
- };
- Emitter.prototype.emitting = function (time) {
- if(this.emitTotalTimes == 1) {
- var length = this.rate.getValue(99999), i;
- for(i = 0; i < length; i++) {
- this.createParticle();
- }
- this.emitTotalTimes = 0;
- } else if(!isNaN(this.emitTotalTimes)) {
- this.emitTime += time;
- if(this.emitTime < this.emitTotalTimes) {
- var length = this.rate.getValue(time), i;
- for(i = 0; i < length; i++) {
- this.createParticle();
- }
- }
- }
- };
- Emitter.prototype.update = function (time) {
- this.age += time;
- if(this.age >= this.life || this.dead) {
- this.destroy();
- }
- this.emitting(time);
- this.integrate(time);
- var particle;
- var length = this.particles.length, k;
- for(k = length - 1; k >= 0; k--) {
- particle = this.particles[k];
- if(particle.dead) {
- Particles.ParticleManager.pool.set(particle);
- this.particles.splice(k, 1);
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PARTICLE_DEAD,
- // particle: particle
- //}));
- }
- }
- };
- Emitter.prototype.setupParticle = function (particle, initialize, behaviour) {
- var initializes = this.initializes;
- var behaviours = this.behaviours;
- if(initialize) {
- if(initialize instanceof Array) {
- initializes = initialize;
- } else {
- initializes = [
- initialize
- ];
- }
- }
- if(behaviour) {
- if(behaviour instanceof Array) {
- behaviours = behaviour;
- } else {
- behaviours = [
- behaviour
- ];
- }
- }
- //Proton.InitializeUtil.initialize(this, particle, initializes);
- particle.addBehaviours(behaviours);
- particle.parent = this;
- this.particles.push(particle);
- };
- Emitter.prototype.destroy = /**
- * Destory this Emitter
- * @method destory
- */
- function () {
- this.dead = true;
- this.emitTotalTimes = -1;
- if(this.particles.length == 0) {
- this.removeInitializers();
- this.removeAllBehaviours();
- if(this.parent) {
- this.parent.removeEmitter(this);
- }
- }
- };
- return Emitter;
- })();
- Particles.Emitter = Emitter;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/Emitter.js.map b/wip/TS Source/particles/Emitter.js.map
deleted file mode 100644
index 0dba2d8e..00000000
--- a/wip/TS Source/particles/Emitter.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Emitter.js","sources":["Emitter.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Emitter","Phaser.Particles.Emitter.constructor","Phaser.Particles.Emitter.emit","Phaser.Particles.Emitter.stopEmit","Phaser.Particles.Emitter.removeAllParticles","Phaser.Particles.Emitter.createParticle","Phaser.Particles.Emitter.addSelfInitialize","Phaser.Particles.Emitter.addInitialize","Phaser.Particles.Emitter.removeInitialize","Phaser.Particles.Emitter.removeInitializers","Phaser.Particles.Emitter.addBehaviour","Phaser.Particles.Emitter.removeBehaviour","Phaser.Particles.Emitter.removeAllBehaviours","Phaser.Particles.Emitter.integrate","Phaser.Particles.Emitter.emitting","Phaser.Particles.Emitter.update","Phaser.Particles.Emitter.setupParticle","Phaser.Particles.Emitter.destroy"],"mappings":"AAEA,IAAO,MAAM;AA0UZ,CA1UD,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAgBIC;;;;;;;;;;;;cAFGA;YAEHA,SAhBSA,OAAOA,CAgBJA,IAAIA;gBAuChBC,KAAAA,WAAWA,GAAGA,EAAEA,CAAAA;gBAChBA,KAAAA,SAASA,GAAGA,EAAEA,CAAAA;gBACdA,KAAAA,UAAUA,GAAGA,EAAEA,CAAAA;gBACfA,KAAAA,QAAQA,GAAGA,CAACA,CAAAA;gBACZA,KAAAA,cAAcA,GAAGA,CAACA,CAACA,CAAAA;gBAzCfA,IAAIA,CAACA,WAAWA,GAAGA,EAAEA;gBACrBA,IAAIA,CAACA,SAASA,GAAGA,EAAEA;gBACnBA,IAAIA,CAACA,UAAUA,GAAGA,EAAEA;gBACpBA,IAAIA,CAACA,QAAQA,GAAGA,CAACA;gBACjBA,IAAIA,CAACA,cAAcA,GAAGA,CAACA,CAACA;gBACxBA;;;;;kBAKGA;gBACHA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA;gBACnBA;;;;;kBAKGA;gBACHA,IAAIA,CAACA,WAAWA,GAAGA,IAAIA;gBACvBA;;;;;kBAKGA;gBACHA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,MAAMA,CAACA,SAASA,CAACA,YAAYA,CAACA,IAAIA,CAACA,CAACA,EAAEA,EAAEA,CAACA;gBACzDA,mCAAmCA;gBACnCA;;;;kBAIGA;gBACHA,IAAIA,CAACA,EAAEA,GAAGA,UAAUA,GAAGA,OAAOA,CAACA,EAAEA,EAAEA;YACvCA,CAACA;YAEDD,aAAYA,CAACA;AAAAA,YAqBbA,yBANAA;;;;;cAKGA;YACHA,UAAKA,QAAQA,EAAEA,IAAIA;gBACfE,IAAIA,CAACA,QAAQA,GAAGA,CAACA;gBACjBA,IAAIA,CAACA,cAAcA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,QAAQA,EAAEA,QAAQA,CAACA;gBAEjEA,GAAIA,IAAIA,IAAIA,IAAIA,IAAIA,IAAIA,IAAIA,MAAMA,IAAIA,IAAIA,IAAIA,SAASA,CAACA;oBAEpDA,GAAIA,QAAQA,IAAIA,MAAMA,CAACA;wBACnBA,IAAIA,CAACA,IAAIA,GAAGA,CAACA;qBAACA,KAEdA;wBAAAA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,cAAcA;qBAACA;iBAEvCA,MAAMA,GAAIA,CAACA,KAAKA,CAACA,IAAIA,CAACA,CAACA;oBAEpBA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;iBACnBA;gBAEDA,IAAIA,CAACA,IAAIA,CAACA,IAAIA,EAAEA;YACpBA,CAACA;YAMDF,6BAJAA;;;cAGGA;YACHA;gBACIG,IAAIA,CAACA,cAAcA,GAAGA,CAACA,CAACA;gBACxBA,IAAIA,CAACA,QAAQA,GAAGA,CAACA;YACrBA,CAACA;YAMDH,uCAJAA;;;cAGGA;YACHA;gBACII,IAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,SAASA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAC1CA;oBAAAA,IAAIA,CAACA,SAASA,CAACA,CAACA,CAACA,CAACA,IAAIA,GAAGA,IAAIA;iBAACA;YACtCA,CAACA;YAQDJ,mCANAA;;;;;cAKGA;YACHA,UAAeA,UAAeA,EAAEA,SAAcA;gBAA/BK,yCAAAA,UAAUA,GAACA,IAAIA;AAAAA,gBAAEA,wCAAAA,SAASA,GAACA,IAAIA;AAAAA,gBAC1CA,IAAIA,QAAQA,GAAGA,yBAAeA,CAACA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;gBAC1CA,IAAIA,CAACA,aAAaA,CAACA,QAAQA,EAAEA,UAAUA,EAAEA,SAASA,CAACA;gBACnDA,uCAAuCA;gBACvCA,oCAAoCA;gBACpCA,wBAAwBA;gBACxBA,MAAMA;gBACNA,OAAOA,QAAQA,CAACA;YACpBA,CAACA;YAMDL,sCAJAA;;;cAGGA;YACHA,UAAkBA,IAAIA;gBAClBM,GAAIA,IAAIA,CAACA,MAAMA,CAACA,CAACA;oBAEbA,IAAIA,CAACA,IAAIA,CAACA,IAAIA,CAACA;iBAClBA,KACDA;oBACIA,iBAAiBA;qCACpBA;YACLA,CAACA;YASDN,kCAPAA;;;;;;cAMGA;YACHA;AACIO,gBAAAA,IAAIA,MAAMA,GAAGA,SAASA,CAACA,MAAMA,EAAAA,CAAGA,CAACA;AAAAA,gBACjCA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;oBACIA,IAAIA,CAACA,WAAWA,CAACA,IAAIA,CAACA,SAASA,CAACA,CAACA,CAACA,CAACA;iBACtCA;YACLA,CAACA;YAODP,qCALAA;;;;cAIGA;YACHA,UAAiBA,WAAWA;gBACxBQ,IAAIA,KAAKA,GAAGA,IAAIA,CAACA,WAAWA,CAACA,OAAOA,CAACA,WAAWA,CAACA,CAACA;gBAClDA,GAAIA,KAAKA,GAAGA,CAACA,CAACA,CAACA;oBAEXA,IAAIA,CAACA,WAAWA,CAACA,MAAMA,CAACA,KAAKA,EAAEA,CAACA,CAACA;iBACpCA;YACLA,CAACA;YAMDR,uCAJAA;;;cAGGA;YACHA;gBACIS,uBAAaA,CAACA,YAAYA,CAACA,IAAIA,CAACA,WAAWA,CAACA;YAChDA,CAACA;YASDT,iCAPAA;;;;;;cAMGA;YACHA;AACIU,gBAAAA,IAAIA,MAAMA,GAAGA,SAASA,CAACA,MAAMA,EAAAA,CAAGA,CAACA;AAAAA,gBACjCA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;oBACIA,IAAIA,CAACA,UAAUA,CAACA,IAAIA,CAACA,SAASA,CAACA,CAACA,CAACA,CAACA;oBAClCA,GAAIA,SAASA,CAACA,CAACA,CAACA,CAACA,cAAcA,CAACA,SAASA,CAACA,CAACA;wBACvCA,SAASA,CAACA,CAACA,CAACA,CAACA,OAAOA,CAACA,IAAIA,CAACA,IAAIA,CAACA;qBAACA;iBACvCA;YACLA,CAACA;YAODV,oCALAA;;;;cAIGA;YACHA,UAAgBA,SAASA;gBACrBW,IAAIA,KAAKA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,OAAOA,CAACA,SAASA,CAACA,CAACA;gBAC/CA,GAAIA,KAAKA,GAAGA,CAACA,CAACA,CAACA;oBACXA,IAAIA,CAACA,UAAUA,CAACA,MAAMA,CAACA,KAAKA,EAAEA,CAACA,CAACA;iBAACA;YACzCA,CAACA;YAMDX,wCAJAA;;;cAGGA;YACHA;gBACIY,uBAAaA,CAACA,YAAYA,CAACA,IAAIA,CAACA,UAAUA,CAACA;YAC/CA,CAACA;YAEDZ,8BAAAA,UAAUA,IAAIA;gBACVa,IAAIA,OAAOA,GAAGA,CAACA,GAAGA,IAAIA,CAACA,OAAOA,CAACA;gBAC/BA,yBAAeA,CAACA,UAAUA,CAACA,SAASA,CAACA,IAAIA,EAAEA,IAAIA,EAAEA,OAAOA,CAACA;AACzDA,gBAAAA,IAAIA,MAAMA,GAAGA,IAAIA,CAACA,SAASA,CAACA,MAAMA,EAAAA,CAAGA,CAACA;AAAAA,gBACtCA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;oBACIA,IAAIA,QAAQA,GAAGA,IAAIA,CAACA,SAASA,CAACA,CAACA,CAACA,CAACA;oBACjCA,QAAQA,CAACA,MAAMA,CAACA,IAAIA,EAAEA,CAACA,CAACA;oBACxBA,yBAAeA,CAACA,UAAUA,CAACA,SAASA,CAACA,QAAQA,EAAEA,IAAIA,EAAEA,OAAOA,CAACA;oBAE7DA,uCAAuCA;oBACvCA,mCAAmCA;oBACnCA,wBAAwBA;oBACxBA,MAAMA;qCACTA;YACLA,CAACA;YAEDb,6BAAAA,UAASA,IAAIA;gBACTc,GAAIA,IAAIA,CAACA,cAAcA,IAAIA,CAACA,CAACA;AAEzBA,oBAAAA,IAAIA,MAAMA,GAAGA,IAAIA,CAACA,IAAIA,CAACA,QAAQA,CAACA,KAAKA,CAACA,EAAAA,CAAGA,CAACA;AAAAA,oBAC1CA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;wBACIA,IAAIA,CAACA,cAAcA,EAAEA;qBACxBA;oBAEDA,IAAIA,CAACA,cAAcA,GAAGA,CAACA;iBAC1BA,MAAMA,GAAIA,CAACA,KAAKA,CAACA,IAAIA,CAACA,cAAcA,CAACA,CAACA;oBAEnCA,IAAIA,CAACA,QAAQA,IAAIA,IAAIA;oBACrBA,GAAIA,IAAIA,CAACA,QAAQA,GAAGA,IAAIA,CAACA,cAAcA,CAACA;AAEpCA,wBAAAA,IAAIA,MAAMA,GAAGA,IAAIA,CAACA,IAAIA,CAACA,QAAQA,CAACA,IAAIA,CAACA,EAAAA,CAAGA,CAACA;AAAAA,wBACzCA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;4BACIA,IAAIA,CAACA,cAAcA,EAAEA;yBACxBA;qBACJA;iBACJA;YACLA,CAACA;YAGDd,2BAAAA,UAAOA,IAAIA;gBACPe,IAAIA,CAACA,GAAGA,IAAIA,IAAIA;gBAChBA,GAAIA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,IAAIA,IAAIA,CAACA,IAAIA,CAACA;oBAEnCA,IAAIA,CAACA,OAAOA,EAAEA;iBACjBA;gBAEDA,IAAIA,CAACA,QAAQA,CAACA,IAAIA,CAACA;gBACnBA,IAAIA,CAACA,SAASA,CAACA,IAAIA,CAACA;gBACpBA,IAAIA,QAAQA,CAACA;AACbA,gBAAAA,IAAIA,MAAMA,GAAGA,IAAIA,CAACA,SAASA,CAACA,MAAMA,EAAAA,CAAGA,CAACA;AAAAA,gBACtCA,IAAKA,CAACA,GAAGA,MAAMA,GAAGA,CAACA,EAAEA,CAACA,IAAIA,CAACA,EAAEA,CAACA,EAAEA,CAChCA;oBACIA,QAAQA,GAAGA,IAAIA,CAACA,SAASA,CAACA,CAACA,CAACA;oBAC5BA,GAAIA,QAAQA,CAACA,IAAIA,CAACA;wBAEdA,yBAAeA,CAACA,IAAIA,CAACA,GAAGA,CAACA,QAAQA,CAACA;wBAClCA,IAAIA,CAACA,SAASA,CAACA,MAAMA,CAACA,CAACA,EAAEA,CAACA,CAACA;wBAC3BA,uCAAuCA;wBACvCA,iCAAiCA;wBACjCA,wBAAwBA;wBACxBA,MAAMA;6CACTA;iBACJA;YACLA,CAACA;YAEDf,kCAAAA,UAAcA,QAAQA,EAAEA,UAAUA,EAAEA,SAASA;gBAEzCgB,IAAIA,WAAWA,GAAGA,IAAIA,CAACA,WAAWA,CAACA;gBACnCA,IAAIA,UAAUA,GAAGA,IAAIA,CAACA,UAAUA,CAACA;gBAEjCA,GAAIA,UAAUA,CAACA;oBAEXA,GAAIA,UAAUA,YAAYA,KAAKA,CAACA;wBAC5BA,WAAWA,GAAGA,UAAUA;qBAACA,KAEzBA;wBAAAA,WAAWA,GAAGA;4BAACA,UAAUA;yBAACA;qBAACA;iBAClCA;gBAEDA,GAAIA,SAASA,CAACA;oBAEVA,GAAIA,SAASA,YAAYA,KAAKA,CAACA;wBAC3BA,UAAUA,GAAGA,SAASA;qBAACA,KAEvBA;wBAAAA,UAAUA,GAAGA;4BAACA,SAASA;yBAACA;qBAACA;iBAChCA;gBAEDA,gEAAgEA;gBAChEA,QAAQA,CAACA,aAAaA,CAACA,UAAUA,CAACA;gBAClCA,QAAQA,CAACA,MAAMA,GAAGA,IAAIA;gBACtBA,IAAIA,CAACA,SAASA,CAACA,IAAIA,CAACA,QAAQA,CAACA;YACjCA,CAACA;YAMDhB,4BAJAA;;;cAGGA;YACHA;gBACIiB,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;gBAChBA,IAAIA,CAACA,cAAcA,GAAGA,CAACA,CAACA;gBACxBA,GAAIA,IAAIA,CAACA,SAASA,CAACA,MAAMA,IAAIA,CAACA,CAACA;oBAE3BA,IAAIA,CAACA,kBAAkBA,EAAEA;oBACzBA,IAAIA,CAACA,mBAAmBA,EAAEA;oBAE1BA,GAAIA,IAAIA,CAACA,MAAMA,CAACA;wBACZA,IAAIA,CAACA,MAAMA,CAACA,aAAaA,CAACA,IAAIA,CAACA;qBAACA;iBACvCA;YACLA,CAACA;YAGLjB;AAACA,QAADA,CAACA,IAAAD;QAtUDA,4BAsUCA,QAAAA;IAELA,CAACA,+CAAAD;IA1UMA;AA0UNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/Emitter.ts b/wip/TS Source/particles/Emitter.ts
deleted file mode 100644
index 7bc09188..00000000
--- a/wip/TS Source/particles/Emitter.ts
+++ /dev/null
@@ -1,333 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class Emitter {
-
- /**
- * You can use this emit particles.
- *
- * It will dispatch follow events:
- * Proton.PARTICLE_CREATED
- * Proton.PARTICLE_UPDATA
- * Proton.PARTICLE_DEAD
- *
- * @class Proton.Emitter
- * @constructor
- * @param {Object} pObj the parameters object;
- * for example {damping:0.01,bindEmitter:false}
- */
-
- constructor(pObj) {
-
- this.initializes = [];
- this.particles = [];
- this.behaviours = [];
- this.emitTime = 0;
- this.emitTotalTimes = -1;
- /**
- * The friction coefficient for all particle emit by This;
- * @property damping
- * @type {Number}
- * @default 0.006
- */
- this.damping = .006;
- /**
- * If bindEmitter the particles can bind this emitter's property;
- * @property bindEmitter
- * @type {bool}
- * @default true
- */
- this.bindEmitter = true;
- /**
- * The number of particles per second emit (a [particle]/b [s]);
- * @property rate
- * @type {Proton.Rate}
- * @default Proton.Rate(1, .1)
- */
- this.rate = new Phaser.Particles.Initializers.Rate(1, .1);
- //Emitter._super_.call(this, pObj);
- /**
- * The emitter's id;
- * @property id
- * @type {String} id
- */
- this.id = 'emitter_' + Emitter.ID++;
- }
-
- static ID = 0;
- id;
- initializes = [];
- particles = [];
- behaviours = [];
- emitTime = 0;
- emitTotalTimes = -1;
- damping;
- bindEmitter;
- rate;
- life;
- age;
- dead;
- parent;
-
- /**
- * start emit particle
- * @method emit
- * @param {Number} emitTime begin emit time;
- * @param {String} life the life of this emitter
- */
- emit(emitTime, life) {
- this.emitTime = 0;
- this.emitTotalTimes = ParticleUtils.initValue(emitTime, Infinity);
-
- if (life == true || life == 'life' || life == 'destroy')
- {
- if (emitTime == 'once')
- this.life = 1;
- else
- this.life = this.emitTotalTimes;
-
- } else if (!isNaN(life))
- {
- this.life = life;
- }
-
- this.rate.init();
- }
-
- /**
- * stop emiting
- * @method stopEmit
- */
- stopEmit() {
- this.emitTotalTimes = -1;
- this.emitTime = 0;
- }
-
- /**
- * remove current all particles
- * @method removeAllParticles
- */
- removeAllParticles() {
- for (var i = 0; i < this.particles.length; i++)
- this.particles[i].dead = true;
- }
-
- /**
- * create single particle;
- *
- * can use emit({x:10},new Gravity(10),{'particleUpdate',fun}) or emit([{x:10},new Initialize],new Gravity(10),{'particleUpdate',fun})
- * @method removeAllParticles
- */
- createParticle(initialize=null, behaviour=null) {
- var particle = ParticleManager.pool.get();
- this.setupParticle(particle, initialize, behaviour);
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PARTICLE_CREATED,
- // particle: particle
- //}));
- return particle;
- }
-
- /**
- * add initialize to this emitter
- * @method addSelfInitialize
- */
- addSelfInitialize(pObj) {
- if (pObj['init'])
- {
- pObj.init(this);
- } else
- {
- //this.initAll();
- }
- }
-
- /**
- * add the Initialize to particles;
- *
- * you can use initializes array:for example emitter.addInitialize(initialize1,initialize2,initialize3);
- * @method addInitialize
- * @param {Proton.Initialize} initialize like this new Proton.Radius(1, 12)
- */
- addInitialize() {
- var length = arguments.length, i;
- for (i = 0; i < length; i++)
- {
- this.initializes.push(arguments[i]);
- }
- }
-
- /**
- * remove the Initialize
- * @method removeInitialize
- * @param {Proton.Initialize} initialize a initialize
- */
- removeInitialize(initializer) {
- var index = this.initializes.indexOf(initializer);
- if (index > -1)
- {
- this.initializes.splice(index, 1);
- }
- }
-
- /**
- * remove all Initializes
- * @method removeInitializers
- */
- removeInitializers() {
- ParticleUtils.destroyArray(this.initializes);
- }
-
- /**
- * add the Behaviour to particles;
- *
- * you can use Behaviours array:emitter.addBehaviour(Behaviour1,Behaviour2,Behaviour3);
- * @method addBehaviour
- * @param {Proton.Behaviour} behaviour like this new Proton.Color('random')
- */
- addBehaviour() {
- var length = arguments.length, i;
- for (i = 0; i < length; i++)
- {
- this.behaviours.push(arguments[i]);
- if (arguments[i].hasOwnProperty("parents"))
- arguments[i].parents.push(this);
- }
- }
-
- /**
- * remove the Behaviour
- * @method removeBehaviour
- * @param {Proton.Behaviour} behaviour a behaviour
- */
- removeBehaviour(behaviour) {
- var index = this.behaviours.indexOf(behaviour);
- if (index > -1)
- this.behaviours.splice(index, 1);
- }
-
- /**
- * remove all behaviours
- * @method removeAllBehaviours
- */
- removeAllBehaviours() {
- ParticleUtils.destroyArray(this.behaviours);
- }
-
- integrate(time) {
- var damping = 1 - this.damping;
- ParticleManager.integrator.integrate(this, time, damping);
- var length = this.particles.length, i;
- for (i = 0; i < length; i++)
- {
- var particle = this.particles[i];
- particle.update(time, i);
- ParticleManager.integrator.integrate(particle, time, damping);
-
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PARTICLE_UPDATE,
- // particle: particle
- //}));
- }
- }
-
- emitting(time) {
- if (this.emitTotalTimes == 1)
- {
- var length = this.rate.getValue(99999), i;
- for (i = 0; i < length; i++)
- {
- this.createParticle();
- }
-
- this.emitTotalTimes = 0;
- } else if (!isNaN(this.emitTotalTimes))
- {
- this.emitTime += time;
- if (this.emitTime < this.emitTotalTimes)
- {
- var length = this.rate.getValue(time), i;
- for (i = 0; i < length; i++)
- {
- this.createParticle();
- }
- }
- }
- }
-
-
- update(time) {
- this.age += time;
- if (this.age >= this.life || this.dead)
- {
- this.destroy();
- }
-
- this.emitting(time);
- this.integrate(time);
- var particle;
- var length = this.particles.length, k;
- for (k = length - 1; k >= 0; k--)
- {
- particle = this.particles[k];
- if (particle.dead)
- {
- ParticleManager.pool.set(particle);
- this.particles.splice(k, 1);
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PARTICLE_DEAD,
- // particle: particle
- //}));
- }
- }
- }
-
- setupParticle(particle, initialize, behaviour) {
-
- var initializes = this.initializes;
- var behaviours = this.behaviours;
-
- if (initialize)
- {
- if (initialize instanceof Array)
- initializes = initialize;
- else
- initializes = [initialize];
- }
-
- if (behaviour)
- {
- if (behaviour instanceof Array)
- behaviours = behaviour;
- else
- behaviours = [behaviour];
- }
-
- //Proton.InitializeUtil.initialize(this, particle, initializes);
- particle.addBehaviours(behaviours);
- particle.parent = this;
- this.particles.push(particle);
- }
-
- /**
- * Destory this Emitter
- * @method destory
- */
- destroy() {
- this.dead = true;
- this.emitTotalTimes = -1;
- if (this.particles.length == 0)
- {
- this.removeInitializers();
- this.removeAllBehaviours();
-
- if (this.parent)
- this.parent.removeEmitter(this);
- }
- }
-
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/particles/NumericalIntegration.js b/wip/TS Source/particles/NumericalIntegration.js
deleted file mode 100644
index dd5129e6..00000000
--- a/wip/TS Source/particles/NumericalIntegration.js
+++ /dev/null
@@ -1,30 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var NumericalIntegration = (function () {
- function NumericalIntegration(type) {
- this.type = Particles.ParticleUtils.initValue(type, Particles.ParticleManager.EULER);
- }
- NumericalIntegration.prototype.integrate = function (particles, time, damping) {
- this.eulerIntegrate(particles, time, damping);
- };
- NumericalIntegration.prototype.eulerIntegrate = function (particle, time, damping) {
- if(!particle.sleep) {
- particle.old.p.copy(particle.p);
- particle.old.v.copy(particle.v);
- particle.a.multiplyScalar(1 / particle.mass);
- particle.v.add(particle.a.multiplyScalar(time));
- particle.p.add(particle.old.v.multiplyScalar(time));
- if(damping) {
- particle.v.multiplyScalar(damping);
- }
- particle.a.clear();
- }
- };
- return NumericalIntegration;
- })();
- Particles.NumericalIntegration = NumericalIntegration;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/NumericalIntegration.js.map b/wip/TS Source/particles/NumericalIntegration.js.map
deleted file mode 100644
index 5b649e49..00000000
--- a/wip/TS Source/particles/NumericalIntegration.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"NumericalIntegration.js","sources":["NumericalIntegration.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.NumericalIntegration","Phaser.Particles.NumericalIntegration.constructor","Phaser.Particles.NumericalIntegration.integrate","Phaser.Particles.NumericalIntegration.eulerIntegrate"],"mappings":"AAEA,IAAO,MAAM;AA8BZ,CA9BD,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAEIC,SAFSA,oBAAoBA,CAEjBA,IAAIA;gBACZC,IAAIA,CAACA,IAAIA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,IAAIA,EAAEA,yBAAeA,CAACA,KAAKA,CAACA;YACpEA,CAACA;YAIDD,2CAAAA,UAAUA,SAASA,EAAEA,IAAIA,EAAEA,OAAOA;gBAC9BE,IAAIA,CAACA,cAAcA,CAACA,SAASA,EAAEA,IAAIA,EAAEA,OAAOA,CAACA;YACjDA,CAACA;YAEDF,gDAAAA,UAAeA,QAAQA,EAAEA,IAAIA,EAAEA,OAAOA;gBAClCG,GAAIA,CAACA,QAAQA,CAACA,KAAKA,CAACA;oBAEhBA,QAAQA,CAACA,GAAGA,CAACA,CAACA,CAACA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA;oBAC/BA,QAAQA,CAACA,GAAGA,CAACA,CAACA,CAACA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA;oBAC/BA,QAAQA,CAACA,CAACA,CAACA,cAAcA,CAACA,CAACA,GAAGA,QAAQA,CAACA,IAAIA,CAACA;oBAC5CA,QAAQA,CAACA,CAACA,CAACA,GAAGA,CAACA,QAAQA,CAACA,CAACA,CAACA,cAAcA,CAACA,IAAIA,CAACA,CAACA;oBAC/CA,QAAQA,CAACA,CAACA,CAACA,GAAGA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,CAACA,cAAcA,CAACA,IAAIA,CAACA,CAACA;oBACnDA,GAAIA,OAAOA,CAACA;wBACRA,QAAQA,CAACA,CAACA,CAACA,cAAcA,CAACA,OAAOA,CAACA;qBAACA;oBACvCA,QAAQA,CAACA,CAACA,CAACA,KAAKA,EAAEA;iBACrBA;YACLA,CAACA;YAELH;AAACA,QAADA,CAACA,IAAAD;QA1BDA,sDA0BCA,QAAAA;IAELA,CAACA,+CAAAD;IA9BMA;AA8BNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/NumericalIntegration.ts b/wip/TS Source/particles/NumericalIntegration.ts
deleted file mode 100644
index 53a556b1..00000000
--- a/wip/TS Source/particles/NumericalIntegration.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class NumericalIntegration {
-
- constructor(type) {
- this.type = ParticleUtils.initValue(type, ParticleManager.EULER);
- }
-
- type;
-
- integrate(particles, time, damping) {
- this.eulerIntegrate(particles, time, damping);
- }
-
- eulerIntegrate(particle, time, damping) {
- if (!particle.sleep)
- {
- particle.old.p.copy(particle.p);
- particle.old.v.copy(particle.v);
- particle.a.multiplyScalar(1 / particle.mass);
- particle.v.add(particle.a.multiplyScalar(time));
- particle.p.add(particle.old.v.multiplyScalar(time));
- if (damping)
- particle.v.multiplyScalar(damping);
- particle.a.clear();
- }
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/Particle.js b/wip/TS Source/particles/Particle.js
deleted file mode 100644
index d882cccc..00000000
--- a/wip/TS Source/particles/Particle.js
+++ /dev/null
@@ -1,151 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var Particle = (function () {
- /**
- * the Particle class
- *
- * @class Proton.Particle
- * @constructor
- * @param {Object} pObj the parameters object;
- * for example {life:3,dead:false}
- */
- function Particle() {
- this.life = Infinity;
- this.age = 0;
- this.energy = 1;
- this.dead = false;
- this.sleep = false;
- this.target = null;
- this.sprite = null;
- this.parent = null;
- this.mass = 1;
- this.radius = 10;
- this.alpha = 1;
- this.scale = 1;
- this.rotation = 0;
- this.color = null;
- this.easing = Phaser.Easing.Linear.None;
- this.p = new Phaser.Vec2();
- this.v = new Phaser.Vec2();
- this.a = new Phaser.Vec2();
- this.old = {
- p: new Phaser.Vec2(),
- v: new Phaser.Vec2(),
- a: new Phaser.Vec2()
- };
- this.behaviours = [];
- /**
- * The particle's id;
- * @property id
- * @type {String} id
- */
- this.id = 'particle_' + Particle.ID++;
- this.reset(true);
- }
- Particle.ID = 0;
- Particle.prototype.getDirection = function () {
- return Math.atan2(this.v.x, -this.v.y) * (180 / Math.PI);
- };
- Particle.prototype.reset = function (init) {
- this.life = Infinity;
- this.age = 0;
- this.energy = 1;
- this.dead = false;
- this.sleep = false;
- this.target = null;
- this.sprite = null;
- this.parent = null;
- this.mass = 1;
- this.radius = 10;
- this.alpha = 1;
- this.scale = 1;
- this.rotation = 0;
- this.color = null;
- this.easing = Phaser.Easing.Linear.None;
- if(init) {
- this.transform = {
- };
- this.p = new Phaser.Vec2();
- this.v = new Phaser.Vec2();
- this.a = new Phaser.Vec2();
- this.old = {
- p: new Phaser.Vec2(),
- v: new Phaser.Vec2(),
- a: new Phaser.Vec2()
- };
- this.behaviours = [];
- } else {
- Particles.ParticleUtils.destroyObject(this.transform);
- this.p.setTo(0, 0);
- this.v.setTo(0, 0);
- this.a.setTo(0, 0);
- this.old.p.setTo(0, 0);
- this.old.v.setTo(0, 0);
- this.old.a.setTo(0, 0);
- this.removeAllBehaviours();
- }
- this.transform.rgb = {
- r: 255,
- g: 255,
- b: 255
- };
- return this;
- };
- Particle.prototype.update = function (time, index) {
- if(!this.sleep) {
- this.age += time;
- var length = this.behaviours.length, i;
- for(i = 0; i < length; i++) {
- if(this.behaviours[i]) {
- this.behaviours[i].applyBehaviour(this, time, index);
- }
- }
- }
- if(this.age >= this.life) {
- this.destroy();
- } else {
- var scale = this.easing(this.age / this.life);
- this.energy = Math.max(1 - scale, 0);
- }
- };
- Particle.prototype.addBehaviour = function (behaviour) {
- this.behaviours.push(behaviour);
- if(behaviour.hasOwnProperty('parents')) {
- behaviour.parents.push(this);
- }
- behaviour.initialize(this);
- };
- Particle.prototype.addBehaviours = function (behaviours) {
- var length = behaviours.length, i;
- for(i = 0; i < length; i++) {
- this.addBehaviour(behaviours[i]);
- }
- };
- Particle.prototype.removeBehaviour = function (behaviour) {
- var index = this.behaviours.indexOf(behaviour);
- if(index > -1) {
- var outBehaviour = this.behaviours.splice(index, 1);
- //outBehaviour.parents = null;
- }
- };
- Particle.prototype.removeAllBehaviours = function () {
- Particles.ParticleUtils.destroyArray(this.behaviours);
- };
- Particle.prototype.destroy = /**
- * Destory this particle
- * @method destory
- */
- function () {
- this.removeAllBehaviours();
- this.energy = 0;
- this.dead = true;
- this.parent = null;
- };
- return Particle;
- })();
- Particles.Particle = Particle;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/Particle.js.map b/wip/TS Source/particles/Particle.js.map
deleted file mode 100644
index adf4aefc..00000000
--- a/wip/TS Source/particles/Particle.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Particle.js","sources":["Particle.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Particle","Phaser.Particles.Particle.constructor","Phaser.Particles.Particle.getDirection","Phaser.Particles.Particle.reset","Phaser.Particles.Particle.update","Phaser.Particles.Particle.addBehaviour","Phaser.Particles.Particle.addBehaviours","Phaser.Particles.Particle.removeBehaviour","Phaser.Particles.Particle.removeAllBehaviours","Phaser.Particles.Particle.destroy"],"mappings":"AAEA,IAAO,MAAM;AA0KZ,CA1KD,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAUIC;;;;;;;cADGA;YACHA,SAVSA,QAAQA;gBAuBjBC,KAAAA,IAAIA,GAAGA,QAAQA,CAAAA;gBACfA,KAAAA,GAAGA,GAAGA,CAACA,CAAAA;gBACPA,KAAAA,MAAMA,GAAGA,CAACA,CAAAA;gBACVA,KAAAA,IAAIA,GAAGA,KAAKA,CAAAA;gBACZA,KAAAA,KAAKA,GAAGA,KAAKA,CAAAA;gBACbA,KAAAA,MAAMA,GAAGA,IAAIA,CAAAA;gBACbA,KAAAA,MAAMA,GAAGA,IAAIA,CAAAA;gBACbA,KAAAA,MAAMA,GAAGA,IAAIA,CAAAA;gBACbA,KAAAA,IAAIA,GAAGA,CAACA,CAAAA;gBACRA,KAAAA,MAAMA,GAAGA,EAAEA,CAAAA;gBACXA,KAAAA,KAAKA,GAAGA,CAACA,CAAAA;gBACTA,KAAAA,KAAKA,GAAGA,CAACA,CAAAA;gBACTA,KAAAA,QAAQA,GAAGA,CAACA,CAAAA;gBACZA,KAAAA,KAAKA,GAAGA,IAAIA,CAAAA;gBACZA,KAAAA,MAAMA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAAAA;gBAElCA,KAAAA,CAACA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA,CAAAA;gBACrBA,KAAAA,CAACA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA,CAAAA;gBACrBA,KAAAA,CAACA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA,CAAAA;gBACrBA,KAAAA,GAAGA,GAAGA;oBACFA,CAACA,EAAEA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;oBACpBA,CAACA,EAAEA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;oBACpBA,CAACA,EAAEA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;iBACvBA,CAAAA;gBACDA,KAAAA,UAAUA,GAAGA,EAAEA,CAAAA;gBApCXA;;;;kBAIGA;gBACHA,IAAIA,CAACA,EAAEA,GAAGA,WAAWA,GAAGA,QAAQA,CAACA,EAAEA,EAAEA;gBACrCA,IAAIA,CAACA,KAAKA,CAACA,IAAIA,CAACA;YACpBA,CAACA;YAEDD,cAAYA,CAACA;AAAAA,YA6BbA,kCAAAA;gBACIE,OAAOA,IAAIA,CAACA,KAAKA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,EAAEA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA,IAAGA,GAAIA,GAAGA,IAAIA,CAACA,EAAEA,CAACA,CAACA;YAC7DA,CAACA;YAEDF,2BAAAA,UAAMA,IAAIA;gBACNG,IAAIA,CAACA,IAAIA,GAAGA,QAAQA;gBACpBA,IAAIA,CAACA,GAAGA,GAAGA,CAACA;gBACZA,IAAIA,CAACA,MAAMA,GAAGA,CAACA;gBACfA,IAAIA,CAACA,IAAIA,GAAGA,KAAKA;gBACjBA,IAAIA,CAACA,KAAKA,GAAGA,KAAKA;gBAClBA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA;gBAClBA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA;gBAClBA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA;gBAClBA,IAAIA,CAACA,IAAIA,GAAGA,CAACA;gBACbA,IAAIA,CAACA,MAAMA,GAAGA,EAAEA;gBAChBA,IAAIA,CAACA,KAAKA,GAAGA,CAACA;gBACdA,IAAIA,CAACA,KAAKA,GAAGA,CAACA;gBACdA,IAAIA,CAACA,QAAQA,GAAGA,CAACA;gBACjBA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA;gBACjBA,IAAIA,CAACA,MAAMA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA,IAAIA;gBACvCA,GAAIA,IAAIA,CAACA;oBAELA,IAAIA,CAACA,SAASA,GAAGA;qBAAEA;oBAC/BA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;oBACdA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;oBAC1BA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;oBAC1BA,IAAIA,CAACA,GAAGA,GAAGA;wBACPA,CAACA,EAAEA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;wBACpBA,CAACA,EAAEA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;wBACpBA,CAACA,EAAEA,IAAIA,MAAMA,CAACA,IAAIA,EAAEA;qBACvBA;oBACDA,IAAIA,CAACA,UAAUA,GAAGA,EAAEA;iBACvBA,KACDA;oBACIA,uBAAaA,CAACA,aAAaA,CAACA,IAAIA,CAACA,SAASA,CAACA;oBAC3CA,IAAIA,CAACA,CAACA,CAACA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA;oBAClBA,IAAIA,CAACA,CAACA,CAACA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA;oBAClBA,IAAIA,CAACA,CAACA,CAACA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA;oBAClBA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA;oBACtBA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA;oBACtBA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA;oBACtBA,IAAIA,CAACA,mBAAmBA,EAAEA;iBAC7BA;gBAEDA,IAAIA,CAACA,SAASA,CAACA,GAAGA,GAAGA;oBACjBA,CAACA,EAAEA,GAAGA;oBACNA,CAACA,EAAEA,GAAGA;oBACNA,CAACA,EAAEA,GAAGA;iBACTA;gBACVA,OAAOA,IAAIA,CAACA;YACPA,CAACA;YAEDH,4BAAAA,UAAOA,IAAIA,EAAEA,KAAKA;gBACdI,GAAIA,CAACA,IAAIA,CAACA,KAAKA,CAACA;oBAEZA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA;AAChBA,oBAAAA,IAAIA,MAAMA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,MAAMA,EAAAA,CAAGA,CAACA;AAAAA,oBACvCA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;wBACIA,GAAIA,IAAIA,CAACA,UAAUA,CAACA,CAACA,CAACA,CAACA;4BACnBA,IAAIA,CAACA,UAAUA,CAACA,CAACA,CAACA,CAACA,cAAcA,CAACA,IAAIA,EAAEA,IAAIA,EAAEA,KAAKA,CAACA;yBAAAA;qBACvEA;iBACQA;gBAEDA,GAAIA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,CAACA;oBAEtBA,IAAIA,CAACA,OAAOA,EAAEA;iBACjBA,KACDA;oBACIA,IAAIA,KAAKA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,IAAIA,CAACA,GAAGA,GAAGA,IAAIA,CAACA,IAAIA,CAACA,CAACA;oBAC9CA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,EAAEA,CAACA,CAACA;iBACvCA;YAELA,CAACA;YAEDJ,kCAAAA,UAAaA,SAASA;gBAClBK,IAAIA,CAACA,UAAUA,CAACA,IAAIA,CAACA,SAASA,CAACA;gBAC/BA,GAAIA,SAASA,CAACA,cAAcA,CAACA,SAASA,CAACA,CAACA;oBACpCA,SAASA,CAACA,OAAOA,CAACA,IAAIA,CAACA,IAAIA,CAACA;iBAACA;gBACjCA,SAASA,CAACA,UAAUA,CAACA,IAAIA,CAACA;YAC9BA,CAACA;YAEDL,mCAAAA,UAAcA,UAAUA;AACpBM,gBAAAA,IAAIA,MAAMA,GAAGA,UAAUA,CAACA,MAAMA,EAAAA,CAAGA,CAACA;AAAAA,gBAClCA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;oBACIA,IAAIA,CAACA,YAAYA,CAACA,UAAUA,CAACA,CAACA,CAACA,CAACA;iBACnCA;YACLA,CAACA;YAEDN,qCAAAA,UAAgBA,SAASA;gBAErBO,IAAIA,KAAKA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,OAAOA,CAACA,SAASA,CAACA,CAACA;gBAE/CA,GAAIA,KAAKA,GAAGA,CAACA,CAACA,CAACA;oBAEXA,IAAIA,YAAYA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,MAAMA,CAACA,KAAKA,EAAEA,CAACA,CAACA,CAACA;oBACpDA,8BAA8BA;qCACjCA;YACLA,CAACA;YAEDP,yCAAAA;gBACIQ,uBAAaA,CAACA,YAAYA,CAACA,IAAIA,CAACA,UAAUA,CAACA;YAC/CA,CAACA;YAMDR,6BAJAA;;;cAGGA;YACHA;gBACIS,IAAIA,CAACA,mBAAmBA,EAAEA;gBAC1BA,IAAIA,CAACA,MAAMA,GAAGA,CAACA;gBACfA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;gBAChBA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA;YACtBA,CAACA;YAGLT;AAACA,QAADA,CAACA,IAAAD;QAtKDA,8BAsKCA,QAAAA;IAELA,CAACA,+CAAAD;IA1KMA;AA0KNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/Particle.ts b/wip/TS Source/particles/Particle.ts
deleted file mode 100644
index 32e22cdc..00000000
--- a/wip/TS Source/particles/Particle.ts
+++ /dev/null
@@ -1,173 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class Particle {
-
- /**
- * the Particle class
- *
- * @class Proton.Particle
- * @constructor
- * @param {Object} pObj the parameters object;
- * for example {life:3,dead:false}
- */
- constructor() {
- /**
- * The particle's id;
- * @property id
- * @type {String} id
- */
- this.id = 'particle_' + Particle.ID++;
- this.reset(true);
- }
-
- static ID = 0;
-
- id;
- life = Infinity;
- age = 0;
- energy = 1;
- dead = false;
- sleep = false;
- target = null;
- sprite = null;
- parent = null;
- mass = 1;
- radius = 10;
- alpha = 1;
- scale = 1;
- rotation = 0;
- color = null;
- easing = Phaser.Easing.Linear.None;
- transform;
- p = new Phaser.Vec2();
- v = new Phaser.Vec2();
- a = new Phaser.Vec2();
- old = {
- p: new Phaser.Vec2(),
- v: new Phaser.Vec2(),
- a: new Phaser.Vec2()
- };
- behaviours = [];
-
- getDirection() {
- return Math.atan2(this.v.x, -this.v.y) * (180 / Math.PI);
- }
-
- reset(init) {
- this.life = Infinity;
- this.age = 0;
- this.energy = 1;
- this.dead = false;
- this.sleep = false;
- this.target = null;
- this.sprite = null;
- this.parent = null;
- this.mass = 1;
- this.radius = 10;
- this.alpha = 1;
- this.scale = 1;
- this.rotation = 0;
- this.color = null;
- this.easing = Phaser.Easing.Linear.None;
- if (init)
- {
- this.transform = {}
- this.p = new Phaser.Vec2();
- this.v = new Phaser.Vec2();
- this.a = new Phaser.Vec2();
- this.old = {
- p: new Phaser.Vec2(),
- v: new Phaser.Vec2(),
- a: new Phaser.Vec2()
- };
- this.behaviours = [];
- } else
- {
- ParticleUtils.destroyObject(this.transform);
- this.p.setTo(0, 0);
- this.v.setTo(0, 0);
- this.a.setTo(0, 0);
- this.old.p.setTo(0, 0);
- this.old.v.setTo(0, 0);
- this.old.a.setTo(0, 0);
- this.removeAllBehaviours();
- }
-
- this.transform.rgb = {
- r: 255,
- g: 255,
- b: 255
- }
- return this;
- }
-
- update(time, index) {
- if (!this.sleep)
- {
- this.age += time;
- var length = this.behaviours.length, i;
- for (i = 0; i < length; i++)
- {
- if (this.behaviours[i])
- this.behaviours[i].applyBehaviour(this, time, index)
- }
- }
-
- if (this.age >= this.life)
- {
- this.destroy();
- } else
- {
- var scale = this.easing(this.age / this.life);
- this.energy = Math.max(1 - scale, 0);
- }
-
- }
-
- addBehaviour(behaviour) {
- this.behaviours.push(behaviour);
- if (behaviour.hasOwnProperty('parents'))
- behaviour.parents.push(this);
- behaviour.initialize(this);
- }
-
- addBehaviours(behaviours) {
- var length = behaviours.length, i;
- for (i = 0; i < length; i++)
- {
- this.addBehaviour(behaviours[i]);
- }
- }
-
- removeBehaviour(behaviour) {
-
- var index = this.behaviours.indexOf(behaviour);
-
- if (index > -1)
- {
- var outBehaviour = this.behaviours.splice(index, 1);
- //outBehaviour.parents = null;
- }
- }
-
- removeAllBehaviours() {
- ParticleUtils.destroyArray(this.behaviours);
- }
-
- /**
- * Destory this particle
- * @method destory
- */
- destroy() {
- this.removeAllBehaviours();
- this.energy = 0;
- this.dead = true;
- this.parent = null;
- }
-
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/particles/ParticleManager.js b/wip/TS Source/particles/ParticleManager.js
deleted file mode 100644
index e443755f..00000000
--- a/wip/TS Source/particles/ParticleManager.js
+++ /dev/null
@@ -1,122 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var ParticleManager = (function () {
- function ParticleManager(proParticleCount, integrationType) {
- this.PARTICLE_CREATED = 'partilcleCreated';
- this.PARTICLE_UPDATE = 'partilcleUpdate';
- this.PARTICLE_SLEEP = 'particleSleep';
- this.PARTICLE_DEAD = 'partilcleDead';
- this.PROTON_UPDATE = 'protonUpdate';
- this.PROTON_UPDATE_AFTER = 'protonUpdateAfter';
- this.EMITTER_ADDED = 'emitterAdded';
- this.EMITTER_REMOVED = 'emitterRemoved';
- this.emitters = [];
- this.renderers = [];
- this.time = 0;
- this.oldTime = 0;
- this.amendChangeTabsBug = true;
- this.TextureBuffer = {
- };
- this.TextureCanvasBuffer = {
- };
- this.proParticleCount = Particles.ParticleUtils.initValue(proParticleCount, ParticleManager.POOL_MAX);
- this.integrationType = Particles.ParticleUtils.initValue(integrationType, ParticleManager.EULER);
- this.emitters = [];
- this.renderers = [];
- this.time = 0;
- this.oldTime = 0;
- ParticleManager.pool = new Phaser.Particles.ParticlePool(proParticleCount);
- ParticleManager.integrator = new Phaser.Particles.NumericalIntegration(this.integrationType);
- }
- ParticleManager.POOL_MAX = 1000;
- ParticleManager.TIME_STEP = 60;
- ParticleManager.MEASURE = 100;
- ParticleManager.EULER = 'euler';
- ParticleManager.RK2 = 'runge-kutta2';
- ParticleManager.RK4 = 'runge-kutta4';
- ParticleManager.VERLET = 'verlet';
- ParticleManager.prototype.addRender = /**
- * add a type of Renderer
- *
- * @method addRender
- * @param {Renderer} render
- */
- function (render) {
- render.proton = this;
- this.renderers.push(render.proton);
- };
- ParticleManager.prototype.addEmitter = /**
- * add the Emitter
- *
- * @method addEmitter
- * @param {Emitter} emitter
- */
- function (emitter) {
- this.emitters.push(emitter);
- emitter.parent = this;
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.EMITTER_ADDED,
- // emitter: emitter
- //}));
- };
- ParticleManager.prototype.removeEmitter = function (emitter) {
- var index = this.emitters.indexOf(emitter);
- this.emitters.splice(index, 1);
- emitter.parent = null;
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.EMITTER_REMOVED,
- // emitter: emitter
- //}));
- };
- ParticleManager.prototype.update = function () {
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PROTON_UPDATE
- //}));
- if(!this.oldTime) {
- this.oldTime = new Date().getTime();
- }
- var time = new Date().getTime();
- this.elapsed = (time - this.oldTime) / 1000;
- //if (ParticleUtils.amendChangeTabsBug)
- // this.amendChangeTabsBugHandler();
- this.oldTime = time;
- if(this.elapsed > 0) {
- for(var i = 0; i < this.emitters.length; i++) {
- this.emitters[i].update(this.elapsed);
- }
- }
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PROTON_UPDATE_AFTER
- //}));
- };
- ParticleManager.prototype.amendChangeTabsBugHandler = function () {
- if(this.elapsed > .5) {
- this.oldTime = new Date().getTime();
- this.elapsed = 0;
- }
- };
- ParticleManager.prototype.getParticleNumber = function () {
- var total = 0;
- for(var i = 0; i < this.emitters.length; i++) {
- total += this.emitters[i].particles.length;
- }
- return total;
- };
- ParticleManager.prototype.destroy = function () {
- for(var i = 0; i < this.emitters.length; i++) {
- this.emitters[i].destory();
- delete this.emitters[i];
- }
- this.emitters = [];
- this.time = 0;
- this.oldTime = 0;
- ParticleManager.pool.release();
- };
- return ParticleManager;
- })();
- Particles.ParticleManager = ParticleManager;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/ParticleManager.js.map b/wip/TS Source/particles/ParticleManager.js.map
deleted file mode 100644
index 6371201e..00000000
--- a/wip/TS Source/particles/ParticleManager.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ParticleManager.js","sources":["ParticleManager.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.ParticleManager","Phaser.Particles.ParticleManager.constructor","Phaser.Particles.ParticleManager.addRender","Phaser.Particles.ParticleManager.addEmitter","Phaser.Particles.ParticleManager.removeEmitter","Phaser.Particles.ParticleManager.update","Phaser.Particles.ParticleManager.amendChangeTabsBugHandler","Phaser.Particles.ParticleManager.getParticleNumber","Phaser.Particles.ParticleManager.destroy"],"mappings":"AAEA,IAAO,MAAM;AAoJZ,CApJD,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAEIC,SAFSA,eAAeA,CAEZA,gBAAgBA,EAAEA,eAAeA;gBAwB7CC,KAAAA,gBAAgBA,GAAGA,kBAAkBA,CAAAA;gBACrCA,KAAAA,eAAeA,GAAGA,iBAAiBA,CAAAA;gBACnCA,KAAAA,cAAcA,GAAGA,eAAeA,CAAAA;gBAChCA,KAAAA,aAAaA,GAAGA,eAAeA,CAAAA;gBAC/BA,KAAAA,aAAaA,GAAGA,cAAcA,CAAAA;gBAC9BA,KAAAA,mBAAmBA,GAAGA,mBAAmBA,CAAAA;gBACzCA,KAAAA,aAAaA,GAAGA,cAAcA,CAAAA;gBAC9BA,KAAAA,eAAeA,GAAGA,gBAAgBA,CAAAA;gBAIlCA,KAAAA,QAAQA,GAAGA,EAAEA,CAAAA;gBACbA,KAAAA,SAASA,GAAGA,EAAEA,CAAAA;gBACdA,KAAAA,IAAIA,GAAGA,CAACA,CAAAA;gBACRA,KAAAA,OAAOA,GAAGA,CAACA,CAAAA;gBAIXA,KAAAA,kBAAkBA,GAAGA,IAAIA,CAAAA;gBACzBA,KAAAA,aAAaA,GAAGA;iBAAEA,CAAAA;gBAClBA,KAAAA,mBAAmBA,GAAGA;iBAAEA,CAAAA;gBA1CpBA,IAAIA,CAACA,gBAAgBA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,gBAAgBA,EAAEA,eAAeA,CAACA,QAAQA,CAACA;gBAC3FA,IAAIA,CAACA,eAAeA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,eAAeA,EAAEA,eAAeA,CAACA,KAAKA,CAACA;gBACtFA,IAAIA,CAACA,QAAQA,GAAGA,EAAEA;gBAClBA,IAAIA,CAACA,SAASA,GAAGA,EAAEA;gBACnBA,IAAIA,CAACA,IAAIA,GAAGA,CAACA;gBACbA,IAAIA,CAACA,OAAOA,GAAGA,CAACA;gBAEhBA,eAAeA,CAACA,IAAIA,GAAGA,IAAIA,MAAMA,CAACA,SAASA,CAACA,YAAYA,CAACA,gBAAgBA,CAACA;gBAC1EA,eAAeA,CAACA,UAAUA,GAAGA,IAAIA,MAAMA,CAACA,SAASA,CAACA,oBAAoBA,CAACA,IAAIA,CAACA,eAAeA,CAACA;YAEhGA,CAACA;YAGDD,2BAAkBA,IAAIA;AAAAA,YACtBA,4BAAmBA,EAAEA;AAAAA,YAErBA,0BAAiBA,GAAGA;AAAAA,YACpBA,wBAAeA,OAAOA;AAAAA,YACtBA,sBAAaA,cAAcA;AAAAA,YAC3BA,sBAAaA,cAAcA;AAAAA,YAC3BA,yBAAgBA,QAAQA;AAAAA,YA+BxBA,sCANAA;;;;;cAKGA;YACHA,UAAUA,MAAMA;gBACZE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA;gBACpBA,IAAIA,CAACA,SAASA,CAACA,IAAIA,CAACA,MAAMA,CAACA,MAAMA,CAACA;YACtCA,CAACA;YAQDF,uCANAA;;;;;cAKGA;YACHA,UAAWA,OAAOA;gBACdG,IAAIA,CAACA,QAAQA,CAACA,IAAIA,CAACA,OAAOA,CAACA;gBAC3BA,OAAOA,CAACA,MAAMA,GAAGA,IAAIA;gBAErBA,uCAAuCA;gBACvCA,iCAAiCA;gBACjCA,sBAAsBA;gBACtBA,MAAMA;4BACVA,CAACA;YAEDH,0CAAAA,UAAcA,OAAOA;gBACjBI,IAAIA,KAAKA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,OAAOA,CAACA,OAAOA,CAACA,CAACA;gBAC3CA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,CAACA,KAAKA,EAAEA,CAACA,CAACA;gBAC9BA,OAAOA,CAACA,MAAMA,GAAGA,IAAIA;gBAErBA,uCAAuCA;gBACvCA,mCAAmCA;gBACnCA,sBAAsBA;gBACtBA,MAAMA;4BACVA,CAACA;YAEDJ,mCAAAA;gBACIK,uCAAuCA;gBACvCA,gCAAgCA;gBAChCA,MAAMA;gBAENA,GAAIA,CAACA,IAAIA,CAACA,OAAOA,CAACA;oBACdA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA,IAAIA,EAAEA,CAACA,OAAOA,EAAEA;iBAACA;gBAExCA,IAAIA,IAAIA,GAAGA,IAAIA,IAAIA,EAAEA,CAACA,OAAOA,EAAEA,CAACA;gBAChCA,IAAIA,CAACA,OAAOA,GAAGA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,OAAOA,IAAIA,IAAIA;gBAC3CA,uCAAuCA;gBACvCA,uCAAuCA;gBACvCA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA;gBACnBA,GAAIA,IAAIA,CAACA,OAAOA,GAAGA,CAACA,CAACA;oBAEjBA,IAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAC7CA;wBACIA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA,MAAMA,CAACA,IAAIA,CAACA,OAAOA,CAACA;qBACxCA;iBACJA;gBAEDA,uCAAuCA;gBACvCA,sCAAsCA;gBACtCA,MAAMA;4BACVA,CAACA;YAEDL,sDAAAA;gBAEIM,GAAIA,IAAIA,CAACA,OAAOA,GAAGA,EAAEA,CAACA;oBAElBA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA,IAAIA,EAAEA,CAACA,OAAOA,EAAEA;oBACnCA,IAAIA,CAACA,OAAOA,GAAGA,CAACA;iBACnBA;YACLA,CAACA;YAEDN,8CAAAA;gBACIO,IAAIA,KAAKA,GAAGA,CAACA,CAACA;gBACdA,IAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAC7CA;oBACIA,KAAKA,IAAIA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA,SAASA,CAACA,MAAMA;iBAC7CA;gBACDA,OAAOA,KAAKA,CAACA;YACjBA,CAACA;YAEDP,oCAAAA;gBACIQ,IAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAC7CA;oBACIA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA,OAAOA,EAAEA;oBAC1BA,OAAOA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA;iBAC1BA;gBAEDA,IAAIA,CAACA,QAAQA,GAAGA,EAAEA;gBAClBA,IAAIA,CAACA,IAAIA,GAAGA,CAACA;gBACbA,IAAIA,CAACA,OAAOA,GAAGA,CAACA;gBAChBA,eAAeA,CAACA,IAAIA,CAACA,OAAOA,EAAEA;YAClCA,CAACA;YAELR;AAACA,QAADA,CAACA,IAAAD;QAhJDA,4CAgJCA,QAAAA;IAELA,CAACA,+CAAAD;IApJMA;AAoJNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/ParticleManager.ts b/wip/TS Source/particles/ParticleManager.ts
deleted file mode 100644
index 9a7fdbf9..00000000
--- a/wip/TS Source/particles/ParticleManager.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class ParticleManager {
-
- constructor(proParticleCount, integrationType) {
-
- this.proParticleCount = ParticleUtils.initValue(proParticleCount, ParticleManager.POOL_MAX);
- this.integrationType = ParticleUtils.initValue(integrationType, ParticleManager.EULER);
- this.emitters = [];
- this.renderers = [];
- this.time = 0;
- this.oldTime = 0;
-
- ParticleManager.pool = new Phaser.Particles.ParticlePool(proParticleCount);
- ParticleManager.integrator = new Phaser.Particles.NumericalIntegration(this.integrationType);
-
- }
-
- //the max particle number in pool
- static POOL_MAX = 1000;
- static TIME_STEP = 60;
- //1:100
- static MEASURE = 100;
- static EULER = 'euler';
- static RK2 = 'runge-kutta2';
- static RK4 = 'runge-kutta4';
- static VERLET = 'verlet';
-
- PARTICLE_CREATED = 'partilcleCreated';
- PARTICLE_UPDATE = 'partilcleUpdate';
- PARTICLE_SLEEP = 'particleSleep';
- PARTICLE_DEAD = 'partilcleDead';
- PROTON_UPDATE = 'protonUpdate';
- PROTON_UPDATE_AFTER = 'protonUpdateAfter';
- EMITTER_ADDED = 'emitterAdded';
- EMITTER_REMOVED = 'emitterRemoved';
-
- proParticleCount;
- integrationType;
- emitters = [];
- renderers = [];
- time = 0;
- oldTime = 0;
- static pool;
- static integrator;
-
- amendChangeTabsBug = true;
- TextureBuffer = {};
- TextureCanvasBuffer = {};
- elapsed;
-
- /**
- * add a type of Renderer
- *
- * @method addRender
- * @param {Renderer} render
- */
- addRender(render) {
- render.proton = this;
- this.renderers.push(render.proton);
- }
-
- /**
- * add the Emitter
- *
- * @method addEmitter
- * @param {Emitter} emitter
- */
- addEmitter(emitter) {
- this.emitters.push(emitter);
- emitter.parent = this;
-
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.EMITTER_ADDED,
- // emitter: emitter
- //}));
- }
-
- removeEmitter(emitter) {
- var index = this.emitters.indexOf(emitter);
- this.emitters.splice(index, 1);
- emitter.parent = null;
-
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.EMITTER_REMOVED,
- // emitter: emitter
- //}));
- }
-
- update() {
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PROTON_UPDATE
- //}));
-
- if (!this.oldTime)
- this.oldTime = new Date().getTime();
-
- var time = new Date().getTime();
- this.elapsed = (time - this.oldTime) / 1000;
- //if (ParticleUtils.amendChangeTabsBug)
- // this.amendChangeTabsBugHandler();
- this.oldTime = time;
- if (this.elapsed > 0)
- {
- for (var i = 0; i < this.emitters.length; i++)
- {
- this.emitters[i].update(this.elapsed);
- }
- }
-
- //this.dispatchEvent(new Proton.Event({
- // type: Proton.PROTON_UPDATE_AFTER
- //}));
- }
-
- amendChangeTabsBugHandler() {
-
- if (this.elapsed > .5)
- {
- this.oldTime = new Date().getTime();
- this.elapsed = 0;
- }
- }
-
- getParticleNumber() {
- var total = 0;
- for (var i = 0; i < this.emitters.length; i++)
- {
- total += this.emitters[i].particles.length;
- }
- return total;
- }
-
- destroy() {
- for (var i = 0; i < this.emitters.length; i++)
- {
- this.emitters[i].destory();
- delete this.emitters[i];
- }
-
- this.emitters = [];
- this.time = 0;
- this.oldTime = 0;
- ParticleManager.pool.release();
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/ParticlePool.js b/wip/TS Source/particles/ParticlePool.js
deleted file mode 100644
index 303f137d..00000000
--- a/wip/TS Source/particles/ParticlePool.js
+++ /dev/null
@@ -1,62 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var ParticlePool = (function () {
- function ParticlePool(num, releaseTime) {
- if (typeof releaseTime === "undefined") { releaseTime = 0; }
- this.poolList = [];
- this.timeoutID = 0;
- this.proParticleCount = Particles.ParticleUtils.initValue(num, 0);
- this.releaseTime = Particles.ParticleUtils.initValue(releaseTime, -1);
- this.poolList = [];
- this.timeoutID = 0;
- for(var i = 0; i < this.proParticleCount; i++) {
- this.add();
- }
- if(this.releaseTime > 0) {
- // TODO - Hook to game clock so Pause works
- this.timeoutID = setTimeout(this.release, this.releaseTime / 1000);
- }
- }
- ParticlePool.prototype.create = function (newTypeParticleClass) {
- if (typeof newTypeParticleClass === "undefined") { newTypeParticleClass = null; }
- if(newTypeParticleClass) {
- return new newTypeParticleClass();
- } else {
- return new Phaser.Particles.Particle();
- }
- };
- ParticlePool.prototype.getCount = function () {
- return this.poolList.length;
- };
- ParticlePool.prototype.add = function () {
- return this.poolList.push(this.create());
- };
- ParticlePool.prototype.get = function () {
- if(this.poolList.length === 0) {
- return this.create();
- } else {
- return this.poolList.pop().reset();
- }
- };
- ParticlePool.prototype.set = function (particle) {
- if(this.poolList.length < Particles.ParticleManager.POOL_MAX) {
- return this.poolList.push(particle);
- }
- };
- ParticlePool.prototype.release = function () {
- for(var i = 0; i < this.poolList.length; i++) {
- if(this.poolList[i]['destroy']) {
- this.poolList[i].destroy();
- }
- delete this.poolList[i];
- }
- this.poolList = [];
- };
- return ParticlePool;
- })();
- Particles.ParticlePool = ParticlePool;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/ParticlePool.js.map b/wip/TS Source/particles/ParticlePool.js.map
deleted file mode 100644
index 1c5f3eb7..00000000
--- a/wip/TS Source/particles/ParticlePool.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ParticlePool.js","sources":["ParticlePool.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.ParticlePool","Phaser.Particles.ParticlePool.constructor","Phaser.Particles.ParticlePool.create","Phaser.Particles.ParticlePool.getCount","Phaser.Particles.ParticlePool.add","Phaser.Particles.ParticlePool.get","Phaser.Particles.ParticlePool.set","Phaser.Particles.ParticlePool.release"],"mappings":"AAEA,IAAO,MAAM;AAyFZ,CAzFD,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAEIC,SAFSA,YAAYA,CAETA,GAAGA,EAAEA,WAAeA;gBAAfC,0CAAAA,WAAWA,GAAGA,CAACA;AAAAA,gBAsBhCA,KAAAA,QAAQA,GAAGA,EAAEA,CAAAA;gBACbA,KAAAA,SAASA,GAAWA,CAACA,CAAAA;gBArBjBA,IAAIA,CAACA,gBAAgBA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,GAAGA,EAAEA,CAACA,CAACA;gBACvDA,IAAIA,CAACA,WAAWA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,WAAWA,EAAEA,CAACA,CAACA,CAACA;gBAC3DA,IAAIA,CAACA,QAAQA,GAAGA,EAAEA;gBAClBA,IAAIA,CAACA,SAASA,GAAGA,CAACA;gBAElBA,IAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,gBAAgBA,EAAEA,CAACA,EAAEA,CAC9CA;oBACIA,IAAIA,CAACA,GAAGA,EAAEA;iBACbA;gBAEDA,GAAIA,IAAIA,CAACA,WAAWA,GAAGA,CAACA,CAACA;oBAErBA,4CAA4CA;oBAC5CA,IAAIA,CAACA,SAASA,GAAGA,UAAUA,CAACA,IAAIA,CAACA,OAAOA,EAAEA,IAAIA,CAACA,WAAWA,GAAGA,IAAIA,CAACA;iBACrEA;YAELA,CAACA;YAODD,gCAAAA,UAAOA,oBAA2BA;gBAA3BE,mDAAAA,oBAAoBA,GAAGA,IAAIA;AAAAA,gBAE9BA,GAAIA,oBAAoBA,CAACA;oBAErBA,OAAOA,IAAIA,oBAAoBA,EAAAA,CAACA;iBACnCA,KAEDA;oBACIA,OAAOA,IAAIA,MAAMA,CAACA,SAASA,CAACA,QAAQA,EAAEA,CAACA;iBAC1CA;YAELA,CAACA;YAEDF,kCAAAA;gBACIG,OAAOA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,CAACA;YAChCA,CAACA;YAEDH,6BAAAA;gBACII,OAAOA,IAAIA,CAACA,QAAQA,CAACA,IAAIA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,CAACA,CAACA;YAC7CA,CAACA;YAEDJ,6BAAAA;gBAEIK,GAAIA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,KAAKA,CAACA,CAACA;oBAE3BA,OAAOA,IAAIA,CAACA,MAAMA,EAAEA,CAACA;iBACxBA,KAEDA;oBACIA,OAAOA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,EAAEA,CAACA,KAAKA,EAAEA,CAACA;iBACtCA;YAELA,CAACA;YAEDL,6BAAAA,UAAIA,QAAQA;gBAERM,GAAIA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,GAAGA,yBAAeA,CAACA,QAAQA,CAACA;oBAEhDA,OAAOA,IAAIA,CAACA,QAAQA,CAACA,IAAIA,CAACA,QAAQA,CAACA,CAACA;iBACvCA;YAELA,CAACA;YAEDN,iCAAAA;gBAEIO,IAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAC7CA;oBACIA,GAAIA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA,SAASA,CAACA,CAACA;wBAE5BA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA,OAAOA,EAAEA;qBAC7BA;oBAEDA,OAAOA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA;iBAC1BA;gBAEDA,IAAIA,CAACA,QAAQA,GAAGA,EAAEA;YACtBA,CAACA;YAELP;AAACA,QAADA,CAACA,IAAAD;QArFDA,sCAqFCA,QAAAA;IAELA,CAACA,+CAAAD;IAzFMA;AAyFNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/ParticlePool.ts b/wip/TS Source/particles/ParticlePool.ts
deleted file mode 100644
index 557860f3..00000000
--- a/wip/TS Source/particles/ParticlePool.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class ParticlePool {
-
- constructor(num, releaseTime = 0) {
-
- this.proParticleCount = ParticleUtils.initValue(num, 0);
- this.releaseTime = ParticleUtils.initValue(releaseTime, -1);
- this.poolList = [];
- this.timeoutID = 0;
-
- for (var i = 0; i < this.proParticleCount; i++)
- {
- this.add();
- }
-
- if (this.releaseTime > 0)
- {
- // TODO - Hook to game clock so Pause works
- this.timeoutID = setTimeout(this.release, this.releaseTime / 1000);
- }
-
- }
-
- proParticleCount: number;
- releaseTime: number;
- poolList = [];
- timeoutID: number = 0;
-
- create(newTypeParticleClass = null) {
-
- if (newTypeParticleClass)
- {
- return new newTypeParticleClass;
- }
- else
- {
- return new Phaser.Particles.Particle();
- }
-
- }
-
- getCount() {
- return this.poolList.length;
- }
-
- add() {
- return this.poolList.push(this.create());
- }
-
- get() {
-
- if (this.poolList.length === 0)
- {
- return this.create();
- }
- else
- {
- return this.poolList.pop().reset();
- }
-
- }
-
- set(particle) {
-
- if (this.poolList.length < ParticleManager.POOL_MAX)
- {
- return this.poolList.push(particle);
- }
-
- }
-
- release() {
-
- for (var i = 0; i < this.poolList.length; i++)
- {
- if (this.poolList[i]['destroy'])
- {
- this.poolList[i].destroy();
- }
-
- delete this.poolList[i];
- }
-
- this.poolList = [];
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/ParticleUtils.js b/wip/TS Source/particles/ParticleUtils.js
deleted file mode 100644
index d9c12f04..00000000
--- a/wip/TS Source/particles/ParticleUtils.js
+++ /dev/null
@@ -1,146 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var ParticleUtils = (function () {
- function ParticleUtils() { }
- ParticleUtils.initValue = function initValue(value, defaults) {
- var value = (value != null && value != undefined) ? value : defaults;
- return value;
- };
- ParticleUtils.isArray = function isArray(value) {
- return typeof value === 'object' && value.hasOwnProperty('length');
- };
- ParticleUtils.destroyArray = function destroyArray(array) {
- array.length = 0;
- };
- ParticleUtils.destroyObject = function destroyObject(obj) {
- for(var o in obj) {
- delete obj[o];
- }
- };
- ParticleUtils.setSpanValue = function setSpanValue(a, b, c) {
- if (typeof b === "undefined") { b = null; }
- if (typeof c === "undefined") { c = null; }
- if(a instanceof Phaser.Particles.Span) {
- return a;
- } else {
- if(!b) {
- return new Phaser.Particles.Span(a);
- } else {
- if(!c) {
- return new Phaser.Particles.Span(a, b);
- } else {
- return new Phaser.Particles.Span(a, b, c);
- }
- }
- }
- };
- ParticleUtils.getSpanValue = function getSpanValue(pan) {
- if(pan instanceof Phaser.Particles.Span) {
- return pan.getValue();
- } else {
- return pan;
- }
- };
- ParticleUtils.randomAToB = function randomAToB(a, b, INT) {
- if (typeof INT === "undefined") { INT = null; }
- if(!INT) {
- return a + Math.random() * (b - a);
- } else {
- return Math.floor(Math.random() * (b - a)) + a;
- }
- };
- ParticleUtils.randomFloating = function randomFloating(center, f, INT) {
- return ParticleUtils.randomAToB(center - f, center + f, INT);
- };
- ParticleUtils.randomZone = function randomZone(display) {
- };
- ParticleUtils.degreeTransform = function degreeTransform(a) {
- return a * Math.PI / 180;
- };
- ParticleUtils.randomColor = //static toColor16 getRGB(num) {
- // return "#" + num.toString(16);
- //}
- function randomColor() {
- return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);
- };
- ParticleUtils.setEasingByName = function setEasingByName(name) {
- switch(name) {
- case 'easeLinear':
- return Phaser.Easing.Linear.None;
- break;
- case 'easeInQuad':
- return Phaser.Easing.Quadratic.In;
- break;
- case 'easeOutQuad':
- return Phaser.Easing.Quadratic.Out;
- break;
- case 'easeInOutQuad':
- return Phaser.Easing.Quadratic.InOut;
- break;
- case 'easeInCubic':
- return Phaser.Easing.Cubic.In;
- break;
- case 'easeOutCubic':
- return Phaser.Easing.Cubic.Out;
- break;
- case 'easeInOutCubic':
- return Phaser.Easing.Cubic.InOut;
- break;
- case 'easeInQuart':
- return Phaser.Easing.Quartic.In;
- break;
- case 'easeOutQuart':
- return Phaser.Easing.Quartic.Out;
- break;
- case 'easeInOutQuart':
- return Phaser.Easing.Quartic.InOut;
- break;
- case 'easeInSine':
- return Phaser.Easing.Sinusoidal.In;
- break;
- case 'easeOutSine':
- return Phaser.Easing.Sinusoidal.Out;
- break;
- case 'easeInOutSine':
- return Phaser.Easing.Sinusoidal.InOut;
- break;
- case 'easeInExpo':
- return Phaser.Easing.Exponential.In;
- break;
- case 'easeOutExpo':
- return Phaser.Easing.Exponential.Out;
- break;
- case 'easeInOutExpo':
- return Phaser.Easing.Exponential.InOut;
- break;
- case 'easeInCirc':
- return Phaser.Easing.Circular.In;
- break;
- case 'easeOutCirc':
- return Phaser.Easing.Circular.Out;
- break;
- case 'easeInOutCirc':
- return Phaser.Easing.Circular.InOut;
- break;
- case 'easeInBack':
- return Phaser.Easing.Back.In;
- break;
- case 'easeOutBack':
- return Phaser.Easing.Back.Out;
- break;
- case 'easeInOutBack':
- return Phaser.Easing.Back.InOut;
- break;
- default:
- return Phaser.Easing.Linear.None;
- break;
- }
- };
- return ParticleUtils;
- })();
- Particles.ParticleUtils = ParticleUtils;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/ParticleUtils.js.map b/wip/TS Source/particles/ParticleUtils.js.map
deleted file mode 100644
index 163678ef..00000000
--- a/wip/TS Source/particles/ParticleUtils.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ParticleUtils.js","sources":["ParticleUtils.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.ParticleUtils","Phaser.Particles.ParticleUtils.constructor","Phaser.Particles.ParticleUtils.initValue","Phaser.Particles.ParticleUtils.isArray","Phaser.Particles.ParticleUtils.destroyArray","Phaser.Particles.ParticleUtils.destroyObject","Phaser.Particles.ParticleUtils.setSpanValue","Phaser.Particles.ParticleUtils.getSpanValue","Phaser.Particles.ParticleUtils.randomAToB","Phaser.Particles.ParticleUtils.randomFloating","Phaser.Particles.ParticleUtils.randomZone","Phaser.Particles.ParticleUtils.degreeTransform","Phaser.Particles.ParticleUtils.randomColor","Phaser.Particles.ParticleUtils.setEasingByName"],"mappings":"AAEA,IAAO,MAAM;AAsMZ,CAtMD,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAAAC;AAkMCA,YAhMGA,0BAAAA,SAAOA,SAASA,CAACA,KAAKA,EAAEA,QAAQA;gBAC5BE,IAAIA,KAAKA,GAAGA,CAACA,KAAKA,IAAIA,IAAIA,IAAIA,KAAKA,IAAIA,SAASA,IAAIA,KAAKA,GAAGA,QAAQA,CAACA;gBACrEA,OAAOA,KAAKA,CAACA;YACjBA,CAACA;YAEDF,wBAAAA,SAAOA,OAAOA,CAACA,KAAKA;gBAChBG,OAAOA,OAAOA,KAAKA,KAAKA,QAAQA,IAAIA,KAAKA,CAACA,cAAcA,CAACA,QAAQA,CAACA,CAACA;YACvEA,CAACA;YAEDH,6BAAAA,SAAOA,YAAYA,CAACA,KAAKA;gBACrBI,KAAKA,CAACA,MAAMA,GAAGA,CAACA;YACpBA,CAACA;YAEDJ,8BAAAA,SAAOA,aAAaA,CAACA,GAAGA;gBAEpBK,IAAKA,IAAIA,CAACA,IAAIA,GAAGA,CAACA;oBAEdA,OAAOA,GAAGA,CAACA,CAACA,CAACA;iBAChBA;YAELA,CAACA;YAEDL,6BAAAA,SAAOA,YAAYA,CAACA,CAACA,EAAEA,CAAOA,EAAEA,CAAOA;gBAAhBM,gCAAAA,CAACA,GAAEA,IAAIA;AAAAA,gBAAEA,gCAAAA,CAACA,GAAEA,IAAIA;AAAAA,gBAEnCA,GAAIA,CAACA,YAAYA,MAAMA,CAACA,SAASA,CAACA,IAAIA,CAACA;oBAEnCA,OAAOA,CAACA,CAACA;iBACZA,KAEDA;oBACIA,GAAIA,CAACA,CAACA,CAACA;wBAEHA,OAAOA,IAAIA,MAAMA,CAACA,SAASA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;qBACvCA,KAEDA;wBACIA,GAAIA,CAACA,CAACA,CAACA;4BAEHA,OAAOA,IAAIA,MAAMA,CAACA,SAASA,CAACA,IAAIA,CAACA,CAACA,EAAEA,CAACA,CAACA,CAACA;yBAC1CA,KAEDA;4BACIA,OAAOA,IAAIA,MAAMA,CAACA,SAASA,CAACA,IAAIA,CAACA,CAACA,EAAEA,CAACA,EAAEA,CAACA,CAACA,CAACA;yBAC7CA;qBACJA;iBACJA;YACLA,CAACA;YAEDN,6BAAAA,SAAOA,YAAYA,CAACA,GAAGA;gBAEnBO,GAAIA,GAAGA,YAAYA,MAAMA,CAACA,SAASA,CAACA,IAAIA,CAACA;oBAErCA,OAAOA,GAAGA,CAACA,QAAQA,EAAEA,CAACA;iBACzBA,KAEDA;oBACIA,OAAOA,GAAGA,CAACA;iBACdA;YAELA,CAACA;YAEDP,2BAAAA,SAAOA,UAAUA,CAACA,CAACA,EAAEA,CAACA,EAAEA,GAAUA;gBAAVQ,kCAAAA,GAAGA,GAAGA,IAAIA;AAAAA,gBAE9BA,GAAIA,CAACA,GAAGA,CAACA;oBAELA,OAAOA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,EAAEA,IAAGA,CAAEA,GAAGA,CAACA,CAACA,CAACA;iBACtCA,KAEDA;oBACIA,OAAOA,IAAIA,CAACA,KAAKA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,IAAGA,CAAEA,GAAGA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA;iBAClDA;YAELA,CAACA;YAEDR,+BAAAA,SAAOA,cAAcA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,GAAGA;gBAChCS,OAAOA,aAAaA,CAACA,UAAUA,CAACA,MAAMA,GAAGA,CAACA,EAAEA,MAAMA,GAAGA,CAACA,EAAEA,GAAGA,CAACA,CAACA;YACjEA,CAACA;YAEDT,2BAAAA,SAAOA,UAAUA,CAACA,OAAOA;YAEzBU,CAACA;YAEDV,gCAAAA,SAAOA,eAAeA,CAACA,CAACA;gBACpBW,OAAOA,CAACA,GAAGA,IAAIA,CAACA,EAAEA,GAAGA,GAAGA,CAACA;YAC7BA,CAACA;YAMDX,4BAJAA,gCAAgCA;YAChCA,oCAAoCA;YACpCA,GAAGA;YAEHA,SAAOA,WAAWA;gBACdY,OAAOA,GAAGA,GAAGA,CAACA,OAAOA,GAAGA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,GAAGA,SAASA,IAAIA,CAACA,EAAEA,QAAQA,CAACA,EAAEA,CAACA,EAAEA,KAAKA,CAACA,CAACA,CAACA,CAACA,CAACA;YACrFA,CAACA;YAEDZ,gCAAAA,SAAOA,eAAeA,CAACA,IAAIA;gBAEvBa,OAAQA,IAAIA,CAACA;oBAETA,KAAKA,YAAYA,CAACA;wBACdA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA;wBACjCA,KAAMA;AAAAA,oBAEVA,KAAKA,YAAYA,CAACA;wBACdA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,EAAEA,CAACA;wBAClCA,KAAMA;AAAAA,oBAEVA,KAAKA,aAAaA,CAACA;wBACfA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,GAAGA,CAACA;wBACnCA,KAAMA;AAAAA,oBAEVA,KAAKA,eAAeA,CAACA;wBACjBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,KAAKA,CAACA;wBACrCA,KAAMA;AAAAA,oBAEVA,KAAKA,aAAaA,CAACA;wBACfA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,KAAKA,CAACA,EAAEA,CAACA;wBAC9BA,KAAMA;AAAAA,oBAEVA,KAAKA,cAAcA,CAACA;wBAChBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,KAAKA,CAACA,GAAGA,CAACA;wBAC/BA,KAAMA;AAAAA,oBAEVA,KAAKA,gBAAgBA,CAACA;wBAClBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,KAAKA,CAACA,KAAKA,CAACA;wBACjCA,KAAMA;AAAAA,oBAEVA,KAAKA,aAAaA,CAACA;wBACfA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,OAAOA,CAACA,EAAEA,CAACA;wBAChCA,KAAMA;AAAAA,oBAEVA,KAAKA,cAAcA,CAACA;wBAChBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,OAAOA,CAACA,GAAGA,CAACA;wBACjCA,KAAMA;AAAAA,oBAEVA,KAAKA,gBAAgBA,CAACA;wBAClBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,OAAOA,CAACA,KAAKA,CAACA;wBACnCA,KAAMA;AAAAA,oBAEVA,KAAKA,YAAYA,CAACA;wBACdA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,UAAUA,CAACA,EAAEA,CAACA;wBACnCA,KAAMA;AAAAA,oBAEVA,KAAKA,aAAaA,CAACA;wBACfA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,UAAUA,CAACA,GAAGA,CAACA;wBACpCA,KAAMA;AAAAA,oBAEVA,KAAKA,eAAeA,CAACA;wBACjBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,UAAUA,CAACA,KAAKA,CAACA;wBACtCA,KAAMA;AAAAA,oBAEVA,KAAKA,YAAYA,CAACA;wBACdA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,WAAWA,CAACA,EAAEA,CAACA;wBACpCA,KAAMA;AAAAA,oBAEVA,KAAKA,aAAaA,CAACA;wBACfA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,WAAWA,CAACA,GAAGA,CAACA;wBACrCA,KAAMA;AAAAA,oBAEVA,KAAKA,eAAeA,CAACA;wBACjBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,WAAWA,CAACA,KAAKA,CAACA;wBACvCA,KAAMA;AAAAA,oBAEVA,KAAKA,YAAYA,CAACA;wBACdA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,QAAQA,CAACA,EAAEA,CAACA;wBACjCA,KAAMA;AAAAA,oBAEVA,KAAKA,aAAaA,CAACA;wBACfA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,QAAQA,CAACA,GAAGA,CAACA;wBAClCA,KAAMA;AAAAA,oBAEVA,KAAKA,eAAeA,CAACA;wBACjBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,QAAQA,CAACA,KAAKA,CAACA;wBACpCA,KAAMA;AAAAA,oBAEVA,KAAKA,YAAYA,CAACA;wBACdA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,EAAEA,CAACA;wBAC7BA,KAAMA;AAAAA,oBAEVA,KAAKA,aAAaA,CAACA;wBACfA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,GAAGA,CAACA;wBAC9BA,KAAMA;AAAAA,oBAEVA,KAAKA,eAAeA,CAACA;wBACjBA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,KAAKA,CAACA;wBAChCA,KAAMA;AAAAA,oBAEVA,OAAOA,CAACA;wBACJA,OAAOA,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA;wBACjCA,KAAMA;AAAAA,iBACbA;YACLA,CAACA;YAELb;AAACA,QAADA,CAACA,IAAAD;QAlMDA,wCAkMCA,QAAAA;IAELA,CAACA,+CAAAD;IAtMMA;AAsMNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/ParticleUtils.ts b/wip/TS Source/particles/ParticleUtils.ts
deleted file mode 100644
index a1333c9d..00000000
--- a/wip/TS Source/particles/ParticleUtils.ts
+++ /dev/null
@@ -1,201 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class ParticleUtils {
-
- static initValue(value, defaults) {
- var value = (value != null && value != undefined) ? value : defaults;
- return value;
- }
-
- static isArray(value) {
- return typeof value === 'object' && value.hasOwnProperty('length');
- }
-
- static destroyArray(array) {
- array.length = 0;
- }
-
- static destroyObject(obj) {
-
- for (var o in obj)
- {
- delete obj[o];
- }
-
- }
-
- static setSpanValue(a, b= null, c= null) {
-
- if (a instanceof Phaser.Particles.Span)
- {
- return a;
- }
- else
- {
- if (!b)
- {
- return new Phaser.Particles.Span(a);
- }
- else
- {
- if (!c)
- {
- return new Phaser.Particles.Span(a, b);
- }
- else
- {
- return new Phaser.Particles.Span(a, b, c);
- }
- }
- }
- }
-
- static getSpanValue(pan) {
-
- if (pan instanceof Phaser.Particles.Span)
- {
- return pan.getValue();
- }
- else
- {
- return pan;
- }
-
- }
-
- static randomAToB(a, b, INT = null) {
-
- if (!INT)
- {
- return a + Math.random() * (b - a);
- }
- else
- {
- return Math.floor(Math.random() * (b - a)) + a;
- }
-
- }
-
- static randomFloating(center, f, INT) {
- return ParticleUtils.randomAToB(center - f, center + f, INT);
- }
-
- static randomZone(display) {
-
- }
-
- static degreeTransform(a) {
- return a * Math.PI / 180;
- }
-
- //static toColor16 getRGB(num) {
- // return "#" + num.toString(16);
- //}
-
- static randomColor() {
- return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);
- }
-
- static setEasingByName(name) {
-
- switch (name)
- {
- case 'easeLinear':
- return Phaser.Easing.Linear.None;
- break;
-
- case 'easeInQuad':
- return Phaser.Easing.Quadratic.In;
- break;
-
- case 'easeOutQuad':
- return Phaser.Easing.Quadratic.Out;
- break;
-
- case 'easeInOutQuad':
- return Phaser.Easing.Quadratic.InOut;
- break;
-
- case 'easeInCubic':
- return Phaser.Easing.Cubic.In;
- break;
-
- case 'easeOutCubic':
- return Phaser.Easing.Cubic.Out;
- break;
-
- case 'easeInOutCubic':
- return Phaser.Easing.Cubic.InOut;
- break;
-
- case 'easeInQuart':
- return Phaser.Easing.Quartic.In;
- break;
-
- case 'easeOutQuart':
- return Phaser.Easing.Quartic.Out;
- break;
-
- case 'easeInOutQuart':
- return Phaser.Easing.Quartic.InOut;
- break;
-
- case 'easeInSine':
- return Phaser.Easing.Sinusoidal.In;
- break;
-
- case 'easeOutSine':
- return Phaser.Easing.Sinusoidal.Out;
- break;
-
- case 'easeInOutSine':
- return Phaser.Easing.Sinusoidal.InOut;
- break;
-
- case 'easeInExpo':
- return Phaser.Easing.Exponential.In;
- break;
-
- case 'easeOutExpo':
- return Phaser.Easing.Exponential.Out;
- break;
-
- case 'easeInOutExpo':
- return Phaser.Easing.Exponential.InOut;
- break;
-
- case 'easeInCirc':
- return Phaser.Easing.Circular.In;
- break;
-
- case 'easeOutCirc':
- return Phaser.Easing.Circular.Out;
- break;
-
- case 'easeInOutCirc':
- return Phaser.Easing.Circular.InOut;
- break;
-
- case 'easeInBack':
- return Phaser.Easing.Back.In;
- break;
-
- case 'easeOutBack':
- return Phaser.Easing.Back.Out;
- break;
-
- case 'easeInOutBack':
- return Phaser.Easing.Back.InOut;
- break;
-
- default:
- return Phaser.Easing.Linear.None;
- break;
- }
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/Polar2D.js b/wip/TS Source/particles/Polar2D.js
deleted file mode 100644
index f7aa8908..00000000
--- a/wip/TS Source/particles/Polar2D.js
+++ /dev/null
@@ -1,63 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var Polar2D = (function () {
- function Polar2D(r, tha) {
- this.r = Math.abs(r) || 0;
- this.tha = tha || 0;
- }
- Polar2D.prototype.set = function (r, tha) {
- this.r = r;
- this.tha = tha;
- return this;
- };
- Polar2D.prototype.setR = function (r) {
- this.r = r;
- return this;
- };
- Polar2D.prototype.setTha = function (tha) {
- this.tha = tha;
- return this;
- };
- Polar2D.prototype.copy = function (p) {
- this.r = p.r;
- this.tha = p.tha;
- return this;
- };
- Polar2D.prototype.toVector = function () {
- return new Phaser.Vec2(this.getX(), this.getY());
- };
- Polar2D.prototype.getX = function () {
- return this.r * Math.sin(this.tha);
- };
- Polar2D.prototype.getY = function () {
- return -this.r * Math.cos(this.tha);
- };
- Polar2D.prototype.normalize = function () {
- this.r = 1;
- return this;
- };
- Polar2D.prototype.equals = function (v) {
- return ((v.r === this.r) && (v.tha === this.tha));
- };
- Polar2D.prototype.toArray = function () {
- return [
- this.r,
- this.tha
- ];
- };
- Polar2D.prototype.clear = function () {
- this.r = 0.0;
- this.tha = 0.0;
- return this;
- };
- Polar2D.prototype.clone = function () {
- return new Polar2D(this.r, this.tha);
- };
- return Polar2D;
- })();
- Particles.Polar2D = Polar2D;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/Polar2D.js.map b/wip/TS Source/particles/Polar2D.js.map
deleted file mode 100644
index 1533b6dc..00000000
--- a/wip/TS Source/particles/Polar2D.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Polar2D.js","sources":["Polar2D.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Polar2D","Phaser.Particles.Polar2D.constructor","Phaser.Particles.Polar2D.set","Phaser.Particles.Polar2D.setR","Phaser.Particles.Polar2D.setTha","Phaser.Particles.Polar2D.copy","Phaser.Particles.Polar2D.toVector","Phaser.Particles.Polar2D.getX","Phaser.Particles.Polar2D.getY","Phaser.Particles.Polar2D.normalize","Phaser.Particles.Polar2D.equals","Phaser.Particles.Polar2D.toArray","Phaser.Particles.Polar2D.clear","Phaser.Particles.Polar2D.clone"],"mappings":"AAEA,IAAO,MAAM;AA+EZ,CA/ED,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAEIC,SAFSA,OAAOA,CAEJA,CAACA,EAAEA,GAAGA;gBACdC,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,IAAIA,CAACA;gBACzBA,IAAIA,CAACA,GAAGA,GAAGA,GAAGA,IAAIA,CAACA;YACvBA,CAACA;YAKDD,wBAAAA,UAAIA,CAACA,EAAEA,GAAGA;gBAENE,IAAIA,CAACA,CAACA,GAAGA,CAACA;gBACVA,IAAIA,CAACA,GAAGA,GAAGA,GAAGA;gBACdA,OAAOA,IAAIA,CAACA;YAEhBA,CAACA;YAEDF,yBAAAA,UAAKA,CAACA;gBAEFG,IAAIA,CAACA,CAACA,GAAGA,CAACA;gBACVA,OAAOA,IAAIA,CAACA;YAEhBA,CAACA;YAEDH,2BAAAA,UAAOA,GAAGA;gBAENI,IAAIA,CAACA,GAAGA,GAAGA,GAAGA;gBACdA,OAAOA,IAAIA,CAACA;YAEhBA,CAACA;YAEDJ,yBAAAA,UAAKA,CAACA;gBAEFK,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA;gBACZA,IAAIA,CAACA,GAAGA,GAAGA,CAACA,CAACA,GAAGA;gBAChBA,OAAOA,IAAIA,CAACA;YAEhBA,CAACA;YAEDL,6BAAAA;gBACIM,OAAOA,IAAIA,MAAMA,CAACA,IAAIA,CAACA,IAAIA,CAACA,IAAIA,EAAEA,EAAEA,IAAIA,CAACA,IAAIA,EAAEA,CAACA,CAACA;YACrDA,CAACA;YAEDN,yBAAAA;gBACIO,OAAOA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,GAAGA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA;YACvCA,CAACA;YAEDP,yBAAAA;gBACIQ,OAAOA,CAACA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,GAAGA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA;YACxCA,CAACA;YAEDR,8BAAAA;gBAEIS,IAAIA,CAACA,CAACA,GAAGA,CAACA;gBACVA,OAAOA,IAAIA,CAACA;YAChBA,CAACA;YAEDT,2BAAAA,UAAOA,CAACA;gBACJU,QAAOA,CAAEA,CAACA,CAACA,CAACA,KAAKA,IAAIA,CAACA,CAACA,MAAKA,CAAEA,CAACA,GAAGA,KAAKA,IAAIA,CAACA,GAAGA,CAAEA,EAACA;YACtDA,CAACA;YAEDV,4BAAAA;gBACIW,OAAOA;oBAACA,IAAIA,CAACA,CAACA;oBAAEA,IAAIA,CAACA,GAAGA;iBAACA,CAACA;YAC9BA,CAACA;YAEDX,0BAAAA;gBACIY,IAAIA,CAACA,CAACA,GAAGA,GAAGA;gBACZA,IAAIA,CAACA,GAAGA,GAAGA,GAAGA;gBACdA,OAAOA,IAAIA,CAACA;YAChBA,CAACA;YAEDZ,0BAAAA;gBACIa,OAAOA,IAAIA,OAAOA,CAACA,IAAIA,CAACA,CAACA,EAAEA,IAAIA,CAACA,GAAGA,CAACA,CAACA;YACzCA,CAACA;YACLb;AAACA,QAADA,CAACA,IAAAD;QA3EDA,4BA2ECA,QAAAA;IAELA,CAACA,+CAAAD;IA/EMA;AA+ENA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/Polar2D.ts b/wip/TS Source/particles/Polar2D.ts
deleted file mode 100644
index bd4ebf88..00000000
--- a/wip/TS Source/particles/Polar2D.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class Polar2D {
-
- constructor(r, tha) {
- this.r = Math.abs(r) || 0;
- this.tha = tha || 0;
- }
-
- r;
- tha;
-
- set(r, tha) {
-
- this.r = r;
- this.tha = tha;
- return this;
-
- }
-
- setR(r) {
-
- this.r = r;
- return this;
-
- }
-
- setTha(tha) {
-
- this.tha = tha;
- return this;
-
- }
-
- copy(p) {
-
- this.r = p.r;
- this.tha = p.tha;
- return this;
-
- }
-
- toVector() {
- return new Phaser.Vec2(this.getX(), this.getY());
- }
-
- getX() {
- return this.r * Math.sin(this.tha);
- }
-
- getY() {
- return -this.r * Math.cos(this.tha);
- }
-
- normalize() {
-
- this.r = 1;
- return this;
- }
-
- equals(v) {
- return ((v.r === this.r) && (v.tha === this.tha));
- }
-
- toArray() {
- return [this.r, this.tha];
- }
-
- clear() {
- this.r = 0.0;
- this.tha = 0.0;
- return this;
- }
-
- clone() {
- return new Polar2D(this.r, this.tha);
- }
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/particles/Span.js b/wip/TS Source/particles/Span.js
deleted file mode 100644
index e20d6d7c..00000000
--- a/wip/TS Source/particles/Span.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var Phaser;
-(function (Phaser) {
- ///
- (function (Particles) {
- var Span = (function () {
- function Span(a, b, center) {
- if (typeof b === "undefined") { b = null; }
- if (typeof center === "undefined") { center = null; }
- this.isArray = false;
- if(Particles.ParticleUtils.isArray(a)) {
- this.isArray = true;
- this.a = a;
- } else {
- this.a = Particles.ParticleUtils.initValue(a, 1);
- this.b = Particles.ParticleUtils.initValue(b, this.a);
- this.center = Particles.ParticleUtils.initValue(center, false);
- }
- }
- Span.prototype.getValue = function (INT) {
- if (typeof INT === "undefined") { INT = null; }
- if(this.isArray) {
- return this.a[Math.floor(this.a.length * Math.random())];
- } else {
- if(!this.center) {
- return Particles.ParticleUtils.randomAToB(this.a, this.b, INT);
- } else {
- return Particles.ParticleUtils.randomFloating(this.a, this.b, INT);
- }
- }
- };
- Span.getSpan = function getSpan(a, b, center) {
- return new Span(a, b, center);
- };
- return Span;
- })();
- Particles.Span = Span;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/Span.js.map b/wip/TS Source/particles/Span.js.map
deleted file mode 100644
index e8660857..00000000
--- a/wip/TS Source/particles/Span.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Span.js","sources":["Span.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Span","Phaser.Particles.Span.constructor","Phaser.Particles.Span.getValue","Phaser.Particles.Span.getSpan"],"mappings":"AAEA,IAAO,MAAM;AAsDZ,CAtDD,UAAO,MAAM;IAFbA,2CAA2CA;KAEpCA,UAAOA,SAASA;QAEnBC;YAEIC,SAFSA,IAAIA,CAEDA,CAACA,EAAEA,CAAQA,EAAEA,MAAaA;gBAAvBC,gCAAAA,CAACA,GAAGA,IAAIA;AAAAA,gBAAEA,qCAAAA,MAAMA,GAAGA,IAAIA;AAAAA,gBAElCA,IAAIA,CAACA,OAAOA,GAAGA,KAAKA;gBAEpBA,GAAIA,uBAAaA,CAACA,OAAOA,CAACA,CAACA,CAACA,CAACA;oBAEzBA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA;oBACnBA,IAAIA,CAACA,CAACA,GAAGA,CAACA;iBACbA,KAEDA;oBACIA,IAAIA,CAACA,CAACA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,CAACA,EAAEA,CAACA,CAACA;oBACtCA,IAAIA,CAACA,CAACA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,CAACA,EAAEA,IAAIA,CAACA,CAACA,CAACA;oBAC3CA,IAAIA,CAACA,MAAMA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,MAAMA,EAAEA,KAAKA,CAACA;iBACvDA;YAELA,CAACA;YAQDD,0BAAAA,UAASA,GAAUA;gBAAVE,kCAAAA,GAAGA,GAAGA,IAAIA;AAAAA,gBAEfA,GAAIA,IAAIA,CAACA,OAAOA,CAACA;oBAEbA,OAAOA,IAAIA,CAACA,CAACA,CAACA,IAAIA,CAACA,KAAKA,CAACA,IAAIA,CAACA,CAACA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,MAAMA,EAAEA,CAACA,CAACA,CAACA;iBAC5DA,KAEDA;oBACIA,GAAIA,CAACA,IAAIA,CAACA,MAAMA,CAACA;wBAEbA,OAAOA,uBAAaA,CAACA,UAAUA,CAACA,IAAIA,CAACA,CAACA,EAAEA,IAAIA,CAACA,CAACA,EAAEA,GAAGA,CAACA,CAACA;qBACxDA,KAEDA;wBACIA,OAAOA,uBAAaA,CAACA,cAAcA,CAACA,IAAIA,CAACA,CAACA,EAAEA,IAAIA,CAACA,CAACA,EAAEA,GAAGA,CAACA,CAACA;qBAC5DA;iBACJA;YAELA,CAACA;YAEDF,eAAAA,SAAOA,OAAOA,CAACA,CAACA,EAAEA,CAACA,EAAEA,MAAMA;gBACvBG,OAAOA,IAAIA,IAAIA,CAACA,CAACA,EAAEA,CAACA,EAAEA,MAAMA,CAACA,CAACA;YAClCA,CAACA;YAELH;AAACA,QAADA,CAACA,IAAAD;QAlDDA,sBAkDCA,QAAAA;IAELA,CAACA,+CAAAD;IAtDMA;AAsDNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/Span.ts b/wip/TS Source/particles/Span.ts
deleted file mode 100644
index 666280ec..00000000
--- a/wip/TS Source/particles/Span.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-///
-
-module Phaser.Particles {
-
- export class Span {
-
- constructor(a, b = null, center = null) {
-
- this.isArray = false;
-
- if (ParticleUtils.isArray(a))
- {
- this.isArray = true;
- this.a = a;
- }
- else
- {
- this.a = ParticleUtils.initValue(a, 1);
- this.b = ParticleUtils.initValue(b, this.a);
- this.center = ParticleUtils.initValue(center, false);
- }
-
- }
-
- a;
- b;
- c;
- center;
- isArray;
-
- getValue(INT = null) {
-
- if (this.isArray)
- {
- return this.a[Math.floor(this.a.length * Math.random())];
- }
- else
- {
- if (!this.center)
- {
- return ParticleUtils.randomAToB(this.a, this.b, INT);
- }
- else
- {
- return ParticleUtils.randomFloating(this.a, this.b, INT);
- }
- }
-
- }
-
- static getSpan(a, b, center) {
- return new Span(a, b, center);
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/behaviours/Behaviour.js b/wip/TS Source/particles/behaviours/Behaviour.js
deleted file mode 100644
index 724bac92..00000000
--- a/wip/TS Source/particles/behaviours/Behaviour.js
+++ /dev/null
@@ -1,118 +0,0 @@
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Behaviours) {
- var Behaviour = (function () {
- function Behaviour(life, easing) {
- /**
- * The behaviour's id;
- * @property id
- * @type {String} id
- */
- this.id = 'Behaviour_' + Behaviour.ID++;
- this.life = Particles.ParticleUtils.initValue(life, Infinity);
- /**
- * The behaviour's decaying trend, for example Proton.easeOutQuart;
- * @property easing
- * @type {String}
- * @default Proton.easeLinear
- */
- this.easing = Particles.ParticleUtils.setEasingByName(easing);
- this.age = 0;
- this.energy = 1;
- /**
- * The behaviour is Dead;
- * @property dead
- * @type {bool}
- */
- this.dead = false;
- /**
- * The behaviour's parents array;
- * @property parents
- * @type {Array}
- */
- this.parents = [];
- /**
- * The behaviour name;
- * @property name
- * @type {string}
- */
- this.name = 'Behaviour';
- }
- Behaviour.prototype.normalizeForce = /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @param {Number} this behaviour's life
- * @param {String} this behaviour's easing
- */
- //reset (life, easing) {
- // this.life = ParticleUtils.initValue(life, Infinity);
- // //this.easing = ParticleUtils.initValue(easing, Proton.ease.setEasingByName(Proton.easeLinear));
- //}
- /**
- * Normalize a force by 1:100;
- *
- * @method normalizeForce
- * @param {Proton.Vector2D} force
- */
- function (force) {
- return force.multiplyScalar(Particles.ParticleManager.MEASURE);
- };
- Behaviour.prototype.normalizeValue = /**
- * Normalize a value by 1:100;
- *
- * @method normalizeValue
- * @param {Number} value
- */
- function (value) {
- return value * Particles.ParticleManager.MEASURE;
- };
- Behaviour.prototype.initialize = /**
- * Initialize the behaviour's parameters for all particles
- *
- * @method initialize
- * @param {Proton.Particle} particle
- */
- function (particle) {
- };
- Behaviour.prototype.applyBehaviour = /**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @param {Proton.Particle} particle
- * @param {Number} the integrate time 1/ms
- * @param {Int} the particle index
- */
- function (particle, time, index) {
- this.age += time;
- if(this.age >= this.life || this.dead) {
- this.energy = 0;
- this.dead = true;
- this.destroy();
- } else {
- var scale = this.easing(particle.age / particle.life);
- this.energy = Math.max(1 - scale, 0);
- }
- };
- Behaviour.prototype.destroy = /**
- * Destory this behaviour
- * @method destory
- */
- function () {
- var index;
- var length = this.parents.length, i;
- for(i = 0; i < length; i++) {
- this.parents[i].removeBehaviour(this);
- }
- this.parents = [];
- };
- return Behaviour;
- })();
- Behaviours.Behaviour = Behaviour;
- })(Particles.Behaviours || (Particles.Behaviours = {}));
- var Behaviours = Particles.Behaviours;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/behaviours/Behaviour.js.map b/wip/TS Source/particles/behaviours/Behaviour.js.map
deleted file mode 100644
index e0f9d26b..00000000
--- a/wip/TS Source/particles/behaviours/Behaviour.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Behaviour.js","sources":["Behaviour.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Behaviours","Phaser.Particles.Behaviours.Behaviour","Phaser.Particles.Behaviours.Behaviour.constructor","Phaser.Particles.Behaviours.Behaviour.normalizeForce","Phaser.Particles.Behaviours.Behaviour.normalizeValue","Phaser.Particles.Behaviours.Behaviour.initialize","Phaser.Particles.Behaviours.Behaviour.applyBehaviour","Phaser.Particles.Behaviours.Behaviour.destroy"],"mappings":"AAEA,IAAO,MAAM;AAyIZ,CAzID,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,UAAUA;YAE9BC;gBAEIC,SAFSA,SAASA,CAENA,IAAIA,EAAEA,MAAMA;oBACpBC;;;;sBAIGA;oBACHA,IAAIA,CAACA,EAAEA,GAAGA,YAAYA,GAAGA,SAASA,CAACA,EAAEA,EAAEA;oBACvCA,IAAIA,CAACA,IAAIA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,IAAIA,EAAEA,QAAQA,CAACA;oBACnDA;;;;;sBAKGA;oBACHA,IAAIA,CAACA,MAAMA,GAAGA,uBAAaA,CAACA,eAAeA,CAACA,MAAMA,CAACA;oBACnDA,IAAIA,CAACA,GAAGA,GAAGA,CAACA;oBACZA,IAAIA,CAACA,MAAMA,GAAGA,CAACA;oBACfA;;;;sBAIGA;oBACHA,IAAIA,CAACA,IAAIA,GAAGA,KAAKA;oBACjBA;;;;sBAIGA;oBACHA,IAAIA,CAACA,OAAOA,GAAGA,EAAEA;oBACjBA;;;;sBAIGA;oBACHA,IAAIA,CAACA,IAAIA,GAAGA,WAAWA;gBAC3BA,CAACA;gBA8BPD,qCAlBMA;;;;;;kBAMGA;gBACHA,wBAAwBA;gBACxBA,0DAA0DA;gBAC1DA,sGAAsGA;gBAC5GA,GAAGA;gBAEHA;;;;;kBAKGA;gBACHA,UAAgBA,KAAKA;oBACXE,OAAOA,KAAKA,CAACA,cAAcA,CAACA,yBAAeA,CAACA,OAAOA,CAACA,CAACA;gBAC/DA,CAACA;gBAQDF,qCANAA;;;;;kBAKGA;gBACHA,UAAgBA,KAAKA;oBACXG,OAAOA,KAAKA,GAAGA,yBAAeA,CAACA,OAAOA,CAACA;gBACjDA,CAACA;gBAQDH,iCANAA;;;;;kBAKGA;gBACHA,UAAYA,QAAQA;gBACpBI,CAACA;gBAUDJ,qCARAA;;;;;;;kBAOGA;gBACHA,UAAgBA,QAAQA,EAAEA,IAAIA,EAAEA,KAAKA;oBAE3BK,IAAIA,CAACA,GAAGA,IAAIA,IAAIA;oBAEhBA,GAAIA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,IAAIA,IAAIA,CAACA,IAAIA,CAACA;wBAEnCA,IAAIA,CAACA,MAAMA,GAAGA,CAACA;wBACfA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;wBAChBA,IAAIA,CAACA,OAAOA,EAAEA;qBACjBA,KAEDA;wBACIA,IAAIA,KAAKA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,QAAQA,CAACA,GAAGA,GAAGA,QAAQA,CAACA,IAAIA,CAACA,CAACA;wBACtDA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,EAAEA,CAACA,CAACA;qBACvCA;gBAEXA,CAACA;gBAMDL,8BAJAA;;;kBAGGA;gBACHA;oBAEUM,IAAIA,KAAKA,CAACA;AACVA,oBAAAA,IAAIA,MAAMA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,MAAMA,EAAAA,CAAGA,CAACA;AAAAA,oBAEpCA,IAAKA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,EAAEA,CAC3BA;wBACIA,IAAIA,CAACA,OAAOA,CAACA,CAACA,CAACA,CAACA,eAAeA,CAACA,IAAIA,CAACA;qBACxCA;oBAEDA,IAAIA,CAACA,OAAOA,GAAGA,EAAEA;gBACrBA,CAACA;gBAELN;AAACA,YAADA,CAACA,IAAAD;YArIDA,iCAqICA,YAAAA;QAELA,CAACA,uDAAAD;QAzIMA;AAyINA,IAADA,CAACA,+CAAAD;IAzIMA;AAyINA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/behaviours/Behaviour.ts b/wip/TS Source/particles/behaviours/Behaviour.ts
deleted file mode 100644
index 50f670ca..00000000
--- a/wip/TS Source/particles/behaviours/Behaviour.ts
+++ /dev/null
@@ -1,140 +0,0 @@
-///
-
-module Phaser.Particles.Behaviours {
-
- export class Behaviour {
-
- constructor(life, easing) {
- /**
- * The behaviour's id;
- * @property id
- * @type {String} id
- */
- this.id = 'Behaviour_' + Behaviour.ID++;
- this.life = ParticleUtils.initValue(life, Infinity);
- /**
- * The behaviour's decaying trend, for example Proton.easeOutQuart;
- * @property easing
- * @type {String}
- * @default Proton.easeLinear
- */
- this.easing = ParticleUtils.setEasingByName(easing);
- this.age = 0;
- this.energy = 1;
- /**
- * The behaviour is Dead;
- * @property dead
- * @type {bool}
- */
- this.dead = false;
- /**
- * The behaviour's parents array;
- * @property parents
- * @type {Array}
- */
- this.parents = [];
- /**
- * The behaviour name;
- * @property name
- * @type {string}
- */
- this.name = 'Behaviour';
- }
-
- static ID;
- id;
- life;
- easing;
- age;
- energy;
- dead;
- parents;
- name;
-
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @param {Number} this behaviour's life
- * @param {String} this behaviour's easing
- */
- //reset (life, easing) {
- // this.life = ParticleUtils.initValue(life, Infinity);
- // //this.easing = ParticleUtils.initValue(easing, Proton.ease.setEasingByName(Proton.easeLinear));
- //}
-
- /**
- * Normalize a force by 1:100;
- *
- * @method normalizeForce
- * @param {Proton.Vector2D} force
- */
- normalizeForce (force) {
- return force.multiplyScalar(ParticleManager.MEASURE);
- }
-
- /**
- * Normalize a value by 1:100;
- *
- * @method normalizeValue
- * @param {Number} value
- */
- normalizeValue (value) {
- return value * ParticleManager.MEASURE;
- }
-
- /**
- * Initialize the behaviour's parameters for all particles
- *
- * @method initialize
- * @param {Proton.Particle} particle
- */
- initialize (particle) {
- }
-
- /**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @param {Proton.Particle} particle
- * @param {Number} the integrate time 1/ms
- * @param {Int} the particle index
- */
- applyBehaviour (particle, time, index) {
-
- this.age += time;
-
- if (this.age >= this.life || this.dead)
- {
- this.energy = 0;
- this.dead = true;
- this.destroy();
- }
- else
- {
- var scale = this.easing(particle.age / particle.life);
- this.energy = Math.max(1 - scale, 0);
- }
-
- }
-
- /**
- * Destory this behaviour
- * @method destory
- */
- destroy () {
-
- var index;
- var length = this.parents.length, i;
-
- for (i = 0; i < length; i++)
- {
- this.parents[i].removeBehaviour(this);
- }
-
- this.parents = [];
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/particles/behaviours/RandomDrift.js b/wip/TS Source/particles/behaviours/RandomDrift.js
deleted file mode 100644
index 6eda9e12..00000000
--- a/wip/TS Source/particles/behaviours/RandomDrift.js
+++ /dev/null
@@ -1,45 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Behaviours) {
- var RandomDrift = (function (_super) {
- __extends(RandomDrift, _super);
- function RandomDrift(driftX, driftY, delay, life, easing) {
- _super.call(this, life, easing);
- this.reset(driftX, driftY, delay);
- this.time = 0;
- this.name = "RandomDrift";
- }
- RandomDrift.prototype.reset = function (driftX, driftY, delay, life, easing) {
- if (typeof life === "undefined") { life = null; }
- if (typeof easing === "undefined") { easing = null; }
- this.panFoce = new Phaser.Vec2(driftX, driftY);
- this.panFoce = this.normalizeForce(this.panFoce);
- this.delay = delay;
- if(life) {
- this.life = Particles.ParticleUtils.initValue(life, Infinity);
- this.easing = Particles.ParticleUtils.initValue(easing, Phaser.Easing.Linear.None);
- }
- };
- RandomDrift.prototype.applyBehaviour = function (particle, time, index) {
- _super.prototype.applyBehaviour.call(this, particle, time, index);
- this.time += time;
- if(this.time >= this.delay) {
- particle.a.addXY(Particles.ParticleUtils.randomAToB(-this.panFoce.x, this.panFoce.x), Particles.ParticleUtils.randomAToB(-this.panFoce.y, this.panFoce.y));
- this.time = 0;
- }
- };
- return RandomDrift;
- })(Behaviours.Behaviour);
- Behaviours.RandomDrift = RandomDrift;
- })(Particles.Behaviours || (Particles.Behaviours = {}));
- var Behaviours = Particles.Behaviours;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/behaviours/RandomDrift.js.map b/wip/TS Source/particles/behaviours/RandomDrift.js.map
deleted file mode 100644
index 00c18d1b..00000000
--- a/wip/TS Source/particles/behaviours/RandomDrift.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"RandomDrift.js","sources":["RandomDrift.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Behaviours","Phaser.Particles.Behaviours.RandomDrift","Phaser.Particles.Behaviours.RandomDrift.constructor","Phaser.Particles.Behaviours.RandomDrift.reset","Phaser.Particles.Behaviours.RandomDrift.applyBehaviour"],"mappings":";;;;;AAEA,IAAO,MAAM;AA6CZ,CA7CD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,UAAUA;YAE9BC;;gBAEIC,SAFSA,WAAWA,CAERA,MAAMA,EAAEA,MAAMA,EAAEA,KAAKA,EAAEA,IAAIA,EAAEA,MAAMA;oBAC3CC,8BAAMA,IAAIA,EAAEA,MAAMA,CAsCzBA;oBArCOA,IAAIA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,MAAMA,EAAEA,KAAKA,CAACA;oBACjCA,IAAIA,CAACA,IAAIA,GAAGA,CAACA;oBACbA,IAAIA,CAACA,IAAIA,GAAGA,aAAaA;gBAC7BA,CAACA;gBAMDD,8BAAAA,UAAMA,MAAMA,EAAEA,MAAMA,EAAEA,KAAKA,EAAEA,IAAUA,EAAEA,MAAYA;oBAAxBE,mCAAAA,IAAIA,GAAEA,IAAIA;AAAAA,oBAAEA,qCAAAA,MAAMA,GAAEA,IAAIA;AAAAA,oBAEjDA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,MAAMA,CAACA;oBAC9CA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA,CAACA,cAAcA,CAACA,IAAIA,CAACA,OAAOA,CAACA;oBAChDA,IAAIA,CAACA,KAAKA,GAAGA,KAAKA;oBAElBA,GAAIA,IAAIA,CAACA;wBAELA,IAAIA,CAACA,IAAIA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,IAAIA,EAAEA,QAAQA,CAACA;wBACnDA,IAAIA,CAACA,MAAMA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,MAAMA,EAAEA,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA;qBAC3EA;gBAELA,CAACA;gBAEDF,uCAAAA,UAAeA,QAAQA,EAAEA,IAAIA,EAAEA,KAAKA;oBAEhCG,gBAAKA,CAACA,cAAcA,YAACA,QAAQA,EAAEA,IAAIA,EAAEA,KAAKA,CAAEA;oBAE5CA,IAAIA,CAACA,IAAIA,IAAIA,IAAIA;oBAEjBA,GAAIA,IAAIA,CAACA,IAAIA,IAAIA,IAAIA,CAACA,KAAKA,CAACA;wBAExBA,QAAQA,CAACA,CAACA,CAACA,KAAKA,CAACA,uBAAaA,CAACA,UAAUA,CAACA,CAACA,IAAIA,CAACA,OAAOA,CAACA,CAACA,EAAEA,IAAIA,CAACA,OAAOA,CAACA,CAACA,CAACA,EAAEA,uBAAaA,CAACA,UAAUA,CAACA,CAACA,IAAIA,CAACA,OAAOA,CAACA,CAACA,EAAEA,IAAIA,CAACA,OAAOA,CAACA,CAACA,CAACA,CAACA;wBACtIA,IAAIA,CAACA,IAAIA,GAAGA,CAACA;qBAChBA;gBAELA,CAACA;gBAELH;AAACA,YAADA,CAACA,EAzCgCD,oBAASA,EAyCzCA;YAzCDA,qCAyCCA,YAAAA;QAELA,CAACA,uDAAAD;QA7CMA;AA6CNA,IAADA,CAACA,+CAAAD;IA7CMA;AA6CNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/behaviours/RandomDrift.ts b/wip/TS Source/particles/behaviours/RandomDrift.ts
deleted file mode 100644
index 030983eb..00000000
--- a/wip/TS Source/particles/behaviours/RandomDrift.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-///
-
-module Phaser.Particles.Behaviours {
-
- export class RandomDrift extends Behaviour {
-
- constructor(driftX, driftY, delay, life, easing) {
- super(life, easing);
- this.reset(driftX, driftY, delay);
- this.time = 0;
- this.name = "RandomDrift";
- }
-
- panFoce;
- delay;
- time;
-
- reset(driftX, driftY, delay, life= null, easing= null) {
-
- this.panFoce = new Phaser.Vec2(driftX, driftY);
- this.panFoce = this.normalizeForce(this.panFoce);
- this.delay = delay;
-
- if (life)
- {
- this.life = ParticleUtils.initValue(life, Infinity);
- this.easing = ParticleUtils.initValue(easing, Phaser.Easing.Linear.None);
- }
-
- }
-
- applyBehaviour(particle, time, index) {
-
- super.applyBehaviour(particle, time, index);
-
- this.time += time;
-
- if (this.time >= this.delay)
- {
- particle.a.addXY(ParticleUtils.randomAToB(-this.panFoce.x, this.panFoce.x), ParticleUtils.randomAToB(-this.panFoce.y, this.panFoce.y));
- this.time = 0;
- }
-
- }
-
- }
-
-}
-
diff --git a/wip/TS Source/particles/initialize/Initialize.js b/wip/TS Source/particles/initialize/Initialize.js
deleted file mode 100644
index 802faf17..00000000
--- a/wip/TS Source/particles/initialize/Initialize.js
+++ /dev/null
@@ -1,27 +0,0 @@
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Initializers) {
- var Initialize = (function () {
- function Initialize() { }
- Initialize.prototype.initialize = function (target) {
- };
- Initialize.prototype.reset = function (a, b, c) {
- };
- Initialize.prototype.init = function (emitter, particle) {
- if (typeof particle === "undefined") { particle = null; }
- if(particle) {
- this.initialize(particle);
- } else {
- this.initialize(emitter);
- }
- };
- return Initialize;
- })();
- Initializers.Initialize = Initialize;
- })(Particles.Initializers || (Particles.Initializers = {}));
- var Initializers = Particles.Initializers;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/initialize/Initialize.js.map b/wip/TS Source/particles/initialize/Initialize.js.map
deleted file mode 100644
index bc54da2f..00000000
--- a/wip/TS Source/particles/initialize/Initialize.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Initialize.js","sources":["Initialize.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Initializers","Phaser.Particles.Initializers.Initialize","Phaser.Particles.Initializers.Initialize.constructor","Phaser.Particles.Initializers.Initialize.initialize","Phaser.Particles.Initializers.Initialize.reset","Phaser.Particles.Initializers.Initialize.init"],"mappings":"AAEA,IAAO,MAAM;AAwBZ,CAxBD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,YAAYA;YAEhCC;gBAAAC;AAoBCA,gBAlBGA,kCAAAA,UAAWA,MAAMA;gBACjBE,CAACA;gBAEDF,6BAAAA,UAAMA,CAACA,EAACA,CAACA,EAACA,CAACA;gBAAIG,CAACA;gBAEhBH,4BAAAA,UAAKA,OAAOA,EAAEA,QAAcA;oBAAdI,uCAAAA,QAAQA,GAAEA,IAAIA;AAAAA,oBAExBA,GAAIA,QAAQA,CAACA;wBAETA,IAAIA,CAACA,UAAUA,CAACA,QAAQA,CAACA;qBAC5BA,KAEDA;wBACIA,IAAIA,CAACA,UAAUA,CAACA,OAAOA,CAACA;qBAC3BA;gBAELA,CAACA;gBAELJ;AAACA,YAADA,CAACA,IAAAD;YApBDA,qCAoBCA,YAAAA;QAELA,CAACA,2DAAAD;QAxBMA;AAwBNA,IAADA,CAACA,+CAAAD;IAxBMA;AAwBNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/initialize/Initialize.ts b/wip/TS Source/particles/initialize/Initialize.ts
deleted file mode 100644
index 3759a366..00000000
--- a/wip/TS Source/particles/initialize/Initialize.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-///
-
-module Phaser.Particles.Initializers {
-
- export class Initialize {
-
- initialize(target) {
- }
-
- reset(a,b,c) { }
-
- init(emitter, particle= null) {
-
- if (particle)
- {
- this.initialize(particle);
- }
- else
- {
- this.initialize(emitter);
- }
-
- }
-
- }
-
-}
-
diff --git a/wip/TS Source/particles/initialize/Life.js b/wip/TS Source/particles/initialize/Life.js
deleted file mode 100644
index a8b42484..00000000
--- a/wip/TS Source/particles/initialize/Life.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Initializers) {
- var Life = (function (_super) {
- __extends(Life, _super);
- function Life(a, b, c) {
- _super.call(this);
- this.lifePan = Particles.ParticleUtils.setSpanValue(a, b, c);
- }
- Life.prototype.initialize = function (target) {
- if(this.lifePan.a == Infinity) {
- target.life = Infinity;
- } else {
- target.life = this.lifePan.getValue();
- }
- };
- return Life;
- })(Initializers.Initialize);
- Initializers.Life = Life;
- })(Particles.Initializers || (Particles.Initializers = {}));
- var Initializers = Particles.Initializers;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/initialize/Life.js.map b/wip/TS Source/particles/initialize/Life.js.map
deleted file mode 100644
index 5791ba8e..00000000
--- a/wip/TS Source/particles/initialize/Life.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Life.js","sources":["Life.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Initializers","Phaser.Particles.Initializers.Life","Phaser.Particles.Initializers.Life.constructor","Phaser.Particles.Initializers.Life.initialize"],"mappings":";;;;;AAEA,IAAO,MAAM;AA4BZ,CA5BD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,YAAYA;YAEhCC;;gBAEIC,SAFSA,IAAIA,CAEDA,CAACA,EAACA,CAACA,EAACA,CAACA;oBAEbC,6BAoBPA;oBAlBOA,IAAIA,CAACA,OAAOA,GAAGA,uBAAaA,CAACA,YAAYA,CAACA,CAACA,EAAEA,CAACA,EAAEA,CAACA,CAACA;gBAEtDA,CAACA;gBAIDD,4BAAAA,UAAWA,MAAMA;oBAEbE,GAAIA,IAAIA,CAACA,OAAOA,CAACA,CAACA,IAAIA,QAAQA,CAACA;wBAE3BA,MAAMA,CAACA,IAAIA,GAAGA,QAAQA;qBACzBA,KAEDA;wBACIA,MAAMA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,QAAQA,EAAEA;qBACxCA;gBACLA,CAACA;gBAELF;AAACA,YAADA,CAACA,EAxByBD,uBAAUA,EAwBnCA;YAxBDA,yBAwBCA,YAAAA;QAELA,CAACA,2DAAAD;QA5BMA;AA4BNA,IAADA,CAACA,+CAAAD;IA5BMA;AA4BNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/initialize/Life.ts b/wip/TS Source/particles/initialize/Life.ts
deleted file mode 100644
index 66e55633..00000000
--- a/wip/TS Source/particles/initialize/Life.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-///
-
-module Phaser.Particles.Initializers {
-
- export class Life extends Initialize {
-
- constructor(a,b,c) {
-
- super();
-
- this.lifePan = ParticleUtils.setSpanValue(a, b, c);
-
- }
-
- lifePan: Phaser.Particles.Span;
-
- initialize(target) {
-
- if (this.lifePan.a == Infinity)
- {
- target.life = Infinity;
- }
- else
- {
- target.life = this.lifePan.getValue();
- }
- }
-
- }
-
-}
-
diff --git a/wip/TS Source/particles/initialize/Mass.js b/wip/TS Source/particles/initialize/Mass.js
deleted file mode 100644
index 6fe5963b..00000000
--- a/wip/TS Source/particles/initialize/Mass.js
+++ /dev/null
@@ -1,27 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Initializers) {
- var Mass = (function (_super) {
- __extends(Mass, _super);
- function Mass(a, b, c) {
- _super.call(this);
- this.massPan = Particles.ParticleUtils.setSpanValue(a, b, c);
- }
- Mass.prototype.initialize = function (target) {
- target.mass = this.massPan.getValue();
- };
- return Mass;
- })(Initializers.Initialize);
- Initializers.Mass = Mass;
- })(Particles.Initializers || (Particles.Initializers = {}));
- var Initializers = Particles.Initializers;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/initialize/Mass.js.map b/wip/TS Source/particles/initialize/Mass.js.map
deleted file mode 100644
index 6af74186..00000000
--- a/wip/TS Source/particles/initialize/Mass.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Mass.js","sources":["Mass.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Initializers","Phaser.Particles.Initializers.Mass","Phaser.Particles.Initializers.Mass.constructor","Phaser.Particles.Initializers.Mass.initialize"],"mappings":";;;;;AAEA,IAAO,MAAM;AAiBZ,CAjBD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,YAAYA;YAEhCC;;gBAEIC,SAFSA,IAAIA,CAEDA,CAACA,EAACA,CAACA,EAACA,CAACA;oBACbC,6BAUPA;oBATOA,IAAIA,CAACA,OAAOA,GAAGA,uBAAaA,CAACA,YAAYA,CAACA,CAACA,EAAEA,CAACA,EAAEA,CAACA,CAACA;gBACtDA,CAACA;gBAIDD,4BAAAA,UAAWA,MAAMA;oBACbE,MAAMA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,QAAQA,EAAEA;gBACzCA,CAACA;gBAELF;AAACA,YAADA,CAACA,EAbyBD,uBAAUA,EAanCA;YAbDA,yBAaCA,YAAAA;QAELA,CAACA,2DAAAD;QAjBMA;AAiBNA,IAADA,CAACA,+CAAAD;IAjBMA;AAiBNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/initialize/Mass.ts b/wip/TS Source/particles/initialize/Mass.ts
deleted file mode 100644
index 16da1521..00000000
--- a/wip/TS Source/particles/initialize/Mass.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-///
-
-module Phaser.Particles.Initializers {
-
- export class Mass extends Initialize {
-
- constructor(a,b,c) {
- super();
- this.massPan = ParticleUtils.setSpanValue(a, b, c);
- }
-
- massPan: Phaser.Particles.Span;
-
- initialize(target) {
- target.mass = this.massPan.getValue();
- }
-
- }
-
-}
-
diff --git a/wip/TS Source/particles/initialize/Position.js b/wip/TS Source/particles/initialize/Position.js
deleted file mode 100644
index 75a4ff16..00000000
--- a/wip/TS Source/particles/initialize/Position.js
+++ /dev/null
@@ -1,40 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Initializers) {
- var Position = (function (_super) {
- __extends(Position, _super);
- function Position(zone) {
- _super.call(this);
- if(zone != null && zone != undefined) {
- this.zone = zone;
- } else {
- this.zone = new Phaser.Particles.Zones.PointZone();
- }
- }
- Position.prototype.reset = function (zone) {
- if(zone != null && zone != undefined) {
- this.zone = zone;
- } else {
- this.zone = new Phaser.Particles.Zones.PointZone();
- }
- };
- Position.prototype.initialize = function (target) {
- this.zone.getPosition();
- target.p.x = this.zone.vector.x;
- target.p.y = this.zone.vector.y;
- };
- return Position;
- })(Initializers.Initialize);
- Initializers.Position = Position;
- })(Particles.Initializers || (Particles.Initializers = {}));
- var Initializers = Particles.Initializers;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/initialize/Position.js.map b/wip/TS Source/particles/initialize/Position.js.map
deleted file mode 100644
index fa20d06f..00000000
--- a/wip/TS Source/particles/initialize/Position.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Position.js","sources":["Position.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Initializers","Phaser.Particles.Initializers.Position","Phaser.Particles.Initializers.Position.constructor","Phaser.Particles.Initializers.Position.reset","Phaser.Particles.Initializers.Position.initialize"],"mappings":";;;;;AAEA,IAAO,MAAM;AA0CZ,CA1CD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,YAAYA;YAEhCC;;gBAEIC,SAFSA,QAAQA,CAELA,IAAIA;oBAEZC,6BAkCPA;oBAhCOA,GAAIA,IAAIA,IAAIA,IAAIA,IAAIA,IAAIA,IAAIA,SAASA,CAACA;wBAElCA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;qBACnBA,KAEDA;wBACIA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,MAAMA,CAACA,SAASA,CAACA,KAAKA,CAACA,SAASA,EAAEA;qBACrDA;gBAELA,CAACA;gBAIDD,2BAAAA,UAAMA,IAAIA;oBACNE,GAAIA,IAAIA,IAAIA,IAAIA,IAAIA,IAAIA,IAAIA,SAASA,CAACA;wBAElCA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;qBACnBA,KAEDA;wBACIA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,MAAMA,CAACA,SAASA,CAACA,KAAKA,CAACA,SAASA,EAAEA;qBACrDA;gBACLA,CAACA;gBAEDF,gCAAAA,UAAWA,MAAMA;oBAEbG,IAAIA,CAACA,IAAIA,CAACA,WAAWA,EAAEA;oBAEvBA,MAAMA,CAACA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,IAAIA,CAACA,MAAMA,CAACA,CAACA;oBAC/BA,MAAMA,CAACA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,IAAIA,CAACA,MAAMA,CAACA,CAACA;gBACnCA,CAACA;gBAELH;AAACA,YAADA,CAACA,EAtC6BD,uBAAUA,EAsCvCA;YAtCDA,iCAsCCA,YAAAA;QAELA,CAACA,2DAAAD;QA1CMA;AA0CNA,IAADA,CAACA,+CAAAD;IA1CMA;AA0CNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/initialize/Position.ts b/wip/TS Source/particles/initialize/Position.ts
deleted file mode 100644
index f92c64bc..00000000
--- a/wip/TS Source/particles/initialize/Position.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-///
-
-module Phaser.Particles.Initializers {
-
- export class Position extends Initialize {
-
- constructor(zone) {
-
- super();
-
- if (zone != null && zone != undefined)
- {
- this.zone = zone;
- }
- else
- {
- this.zone = new Phaser.Particles.Zones.PointZone();
- }
-
- }
-
- zone;
-
- reset(zone) {
- if (zone != null && zone != undefined)
- {
- this.zone = zone;
- }
- else
- {
- this.zone = new Phaser.Particles.Zones.PointZone();
- }
- }
-
- initialize(target) {
-
- this.zone.getPosition();
-
- target.p.x = this.zone.vector.x;
- target.p.y = this.zone.vector.y;
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/initialize/Radius.ts b/wip/TS Source/particles/initialize/Radius.ts
deleted file mode 100644
index f80ff261..00000000
--- a/wip/TS Source/particles/initialize/Radius.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-
-module Phaser.Particles.Initializers {
-
- export class Radius extends Initialize {
-
- constructor(a,b,c) {
-
- super();
-
- this.radius = ParticleUtils.setSpanValue(a, b, c);
-
- }
-
- radius: Phaser.Particles.Span;
-
- reset(a, b, c) {
-
- this.radius = ParticleUtils.setSpanValue(a, b, c);
-
- }
-
- initialize(particle) {
-
- particle.radius = this.radius.getValue();
- particle.transform.oldRadius = particle.radius;
-
- }
-
- }
-
-}
-
diff --git a/wip/TS Source/particles/initialize/Rate.js b/wip/TS Source/particles/initialize/Rate.js
deleted file mode 100644
index 62876d22..00000000
--- a/wip/TS Source/particles/initialize/Rate.js
+++ /dev/null
@@ -1,51 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Initializers) {
- var Rate = (function (_super) {
- __extends(Rate, _super);
- function Rate(numpan, timepan) {
- _super.call(this);
- numpan = Particles.ParticleUtils.initValue(numpan, 1);
- timepan = Particles.ParticleUtils.initValue(timepan, 1);
- this.numPan = new Phaser.Particles.Span(numpan);
- this.timePan = new Phaser.Particles.Span(timepan);
- this.startTime = 0;
- this.nextTime = 0;
- this.init();
- }
- Rate.prototype.init = function () {
- this.startTime = 0;
- this.nextTime = this.timePan.getValue();
- };
- Rate.prototype.getValue = function (time) {
- this.startTime += time;
- if(this.startTime >= this.nextTime) {
- this.startTime = 0;
- this.nextTime = this.timePan.getValue();
- if(this.numPan.b == 1) {
- if(this.numPan.getValue(false) > 0.5) {
- return 1;
- } else {
- return 0;
- }
- } else {
- return this.numPan.getValue(true);
- }
- }
- return 0;
- };
- return Rate;
- })(Initializers.Initialize);
- Initializers.Rate = Rate;
- })(Particles.Initializers || (Particles.Initializers = {}));
- var Initializers = Particles.Initializers;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/initialize/Rate.js.map b/wip/TS Source/particles/initialize/Rate.js.map
deleted file mode 100644
index 425e0a66..00000000
--- a/wip/TS Source/particles/initialize/Rate.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Rate.js","sources":["Rate.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Initializers","Phaser.Particles.Initializers.Rate","Phaser.Particles.Initializers.Rate.constructor","Phaser.Particles.Initializers.Rate.init","Phaser.Particles.Initializers.Rate.getValue"],"mappings":";;;;;AAEA,IAAO,MAAM;AAyDZ,CAzDD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,YAAYA;YAEhCC;;gBAEIC,SAFSA,IAAIA,CAEDA,MAAMA,EAAEA,OAAOA;oBACvBC,6BAkDPA;oBAhDOA,MAAMA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,MAAMA,EAAEA,CAACA,CAACA;oBAC3CA,OAAOA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,OAAOA,EAAEA,CAACA,CAACA;oBAC7CA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,MAAMA,CAACA,SAASA,CAACA,IAAIA,CAACA,MAAMA,CAACA;oBAC/CA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA,MAAMA,CAACA,SAASA,CAACA,IAAIA,CAACA,OAAOA,CAACA;oBACjDA,IAAIA,CAACA,SAASA,GAAGA,CAACA;oBAClBA,IAAIA,CAACA,QAAQA,GAAGA,CAACA;oBACjBA,IAAIA,CAACA,IAAIA,EAAEA;gBACfA,CAACA;gBAODD,sBAAAA;oBACIE,IAAIA,CAACA,SAASA,GAAGA,CAACA;oBAClBA,IAAIA,CAACA,QAAQA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,QAAQA,EAAEA;gBAC3CA,CAACA;gBAEDF,0BAAAA,UAAUA,IAAIA;oBAEVG,IAAIA,CAACA,SAASA,IAAIA,IAAIA;oBAEtBA,GAAIA,IAAIA,CAACA,SAASA,IAAIA,IAAIA,CAACA,QAAQA,CAACA;wBAEhCA,IAAIA,CAACA,SAASA,GAAGA,CAACA;wBAClBA,IAAIA,CAACA,QAAQA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,QAAQA,EAAEA;wBAEvCA,GAAIA,IAAIA,CAACA,MAAMA,CAACA,CAACA,IAAIA,CAACA,CAACA;4BAEnBA,GAAIA,IAAIA,CAACA,MAAMA,CAACA,QAAQA,CAACA,KAAKA,CAACA,GAAGA,GAAGA,CAACA;gCAElCA,OAAOA,CAACA,CAACA;6BACZA,KAEDA;gCACIA,OAAOA,CAACA,CAACA;6BACZA;yBACJA,KAEDA;4BACIA,OAAOA,IAAIA,CAACA,MAAMA,CAACA,QAAQA,CAACA,IAAIA,CAACA,CAACA;yBACrCA;qBACJA;oBAEDA,OAAOA,CAACA,CAACA;gBACbA,CAACA;gBAELH;AAACA,YAADA,CAACA,EArDyBD,uBAAUA,EAqDnCA;YArDDA,yBAqDCA,YAAAA;QAELA,CAACA,2DAAAD;QAzDMA;AAyDNA,IAADA,CAACA,+CAAAD;IAzDMA;AAyDNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/initialize/Rate.ts b/wip/TS Source/particles/initialize/Rate.ts
deleted file mode 100644
index 71510c30..00000000
--- a/wip/TS Source/particles/initialize/Rate.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-
-module Phaser.Particles.Initializers {
-
- export class Rate extends Initialize {
-
- constructor(numpan, timepan) {
- super();
-
- numpan = ParticleUtils.initValue(numpan, 1);
- timepan = ParticleUtils.initValue(timepan, 1);
- this.numPan = new Phaser.Particles.Span(numpan);
- this.timePan = new Phaser.Particles.Span(timepan);
- this.startTime = 0;
- this.nextTime = 0;
- this.init();
- }
-
- numPan: Phaser.Particles.Span;
- timePan: Phaser.Particles.Span;
- startTime;
- nextTime;
-
- init() {
- this.startTime = 0;
- this.nextTime = this.timePan.getValue();
- }
-
- getValue (time) {
-
- this.startTime += time;
-
- if (this.startTime >= this.nextTime)
- {
- this.startTime = 0;
- this.nextTime = this.timePan.getValue();
-
- if (this.numPan.b == 1)
- {
- if (this.numPan.getValue(false) > 0.5)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- return this.numPan.getValue(true);
- }
- }
-
- return 0;
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/initialize/Velocity.js b/wip/TS Source/particles/initialize/Velocity.js
deleted file mode 100644
index 7dc8eed5..00000000
--- a/wip/TS Source/particles/initialize/Velocity.js
+++ /dev/null
@@ -1,44 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Initializers) {
- var Velocity = (function (_super) {
- __extends(Velocity, _super);
- function Velocity(rpan, thapan, type) {
- _super.call(this);
- this.rPan = Particles.ParticleUtils.setSpanValue(rpan);
- this.thaPan = Particles.ParticleUtils.setSpanValue(thapan);
- this.type = Particles.ParticleUtils.initValue(type, 'vector');
- }
- Velocity.prototype.reset = function (rpan, thapan, type) {
- this.rPan = Particles.ParticleUtils.setSpanValue(rpan);
- this.thaPan = Particles.ParticleUtils.setSpanValue(thapan);
- this.type = Particles.ParticleUtils.initValue(type, 'vector');
- };
- Velocity.prototype.normalizeVelocity = function (vr) {
- return vr * Particles.ParticleManager.MEASURE;
- };
- Velocity.prototype.initialize = function (target) {
- if(this.type == 'p' || this.type == 'P' || this.type == 'polar') {
- var polar2d = new Particles.Polar2D(this.normalizeVelocity(this.rPan.getValue()), this.thaPan.getValue() * Math.PI / 180);
- target.v.x = polar2d.getX();
- target.v.y = polar2d.getY();
- } else {
- target.v.x = this.normalizeVelocity(this.rPan.getValue());
- target.v.y = this.normalizeVelocity(this.thaPan.getValue());
- }
- };
- return Velocity;
- })(Initializers.Initialize);
- Initializers.Velocity = Velocity;
- })(Particles.Initializers || (Particles.Initializers = {}));
- var Initializers = Particles.Initializers;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/initialize/Velocity.js.map b/wip/TS Source/particles/initialize/Velocity.js.map
deleted file mode 100644
index 0c04762a..00000000
--- a/wip/TS Source/particles/initialize/Velocity.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Velocity.js","sources":["Velocity.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Initializers","Phaser.Particles.Initializers.Velocity","Phaser.Particles.Initializers.Velocity.constructor","Phaser.Particles.Initializers.Velocity.reset","Phaser.Particles.Initializers.Velocity.normalizeVelocity","Phaser.Particles.Initializers.Velocity.initialize"],"mappings":";;;;;AAEA,IAAO,MAAM;AA2CZ,CA3CD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,YAAYA;YAEhCC;;gBAEIC,SAFSA,QAAQA,CAELA,IAAIA,EAAEA,MAAMA,EAAEA,IAAIA;oBAC1BC,6BAoCPA;oBAlCOA,IAAIA,CAACA,IAAIA,GAAGA,uBAAaA,CAACA,YAAYA,CAACA,IAAIA,CAACA;oBAC5CA,IAAIA,CAACA,MAAMA,GAAGA,uBAAaA,CAACA,YAAYA,CAACA,MAAMA,CAACA;oBAChDA,IAAIA,CAACA,IAAIA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,IAAIA,EAAEA,QAAQA,CAACA;gBACvDA,CAACA;gBAMDD,2BAAAA,UAAMA,IAAIA,EAAEA,MAAMA,EAAEA,IAAIA;oBACpBE,IAAIA,CAACA,IAAIA,GAAGA,uBAAaA,CAACA,YAAYA,CAACA,IAAIA,CAACA;oBAC5CA,IAAIA,CAACA,MAAMA,GAAGA,uBAAaA,CAACA,YAAYA,CAACA,MAAMA,CAACA;oBAChDA,IAAIA,CAACA,IAAIA,GAAGA,uBAAaA,CAACA,SAASA,CAACA,IAAIA,EAAEA,QAAQA,CAACA;gBACvDA,CAACA;gBAEDF,uCAAAA,UAAkBA,EAAEA;oBAChBG,OAAOA,EAAEA,GAAGA,yBAAeA,CAACA,OAAOA,CAACA;gBACxCA,CAACA;gBAEDH,gCAAAA,UAAWA,MAAMA;oBAEbI,GAAIA,IAAIA,CAACA,IAAIA,IAAIA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,IAAIA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,IAAIA,OAAOA,CAACA;wBAE7DA,IAAIA,OAAOA,GAAGA,IAAIA,iBAAOA,CAACA,IAAIA,CAACA,iBAAiBA,CAACA,IAAIA,CAACA,IAAIA,CAACA,QAAQA,EAAEA,CAACA,EAAEA,IAAIA,CAACA,MAAMA,CAACA,QAAQA,EAAEA,GAAGA,IAAIA,CAACA,EAAEA,GAAGA,GAAGA,CAACA,CAACA;wBAChHA,MAAMA,CAACA,CAACA,CAACA,CAACA,GAAGA,OAAOA,CAACA,IAAIA,EAAEA;wBAC3BA,MAAMA,CAACA,CAACA,CAACA,CAACA,GAAGA,OAAOA,CAACA,IAAIA,EAAEA;qBAC9BA,KAEDA;wBACIA,MAAMA,CAACA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,iBAAiBA,CAACA,IAAIA,CAACA,IAAIA,CAACA,QAAQA,EAAEA,CAACA;wBACzDA,MAAMA,CAACA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,iBAAiBA,CAACA,IAAIA,CAACA,MAAMA,CAACA,QAAQA,EAAEA,CAACA;qBAC9DA;gBACLA,CAACA;gBAELJ;AAACA,YAADA,CAACA,EAvC6BD,uBAAUA,EAuCvCA;YAvCDA,iCAuCCA,YAAAA;QAELA,CAACA,2DAAAD;QA3CMA;AA2CNA,IAADA,CAACA,+CAAAD;IA3CMA;AA2CNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/initialize/Velocity.ts b/wip/TS Source/particles/initialize/Velocity.ts
deleted file mode 100644
index 61d93fdf..00000000
--- a/wip/TS Source/particles/initialize/Velocity.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-
-module Phaser.Particles.Initializers {
-
- export class Velocity extends Initialize {
-
- constructor(rpan, thapan, type) {
- super();
-
- this.rPan = ParticleUtils.setSpanValue(rpan);
- this.thaPan = ParticleUtils.setSpanValue(thapan);
- this.type = ParticleUtils.initValue(type, 'vector');
- }
-
- rPan: Phaser.Particles.Span;
- thaPan: Phaser.Particles.Span;
- type;
-
- reset(rpan, thapan, type) {
- this.rPan = ParticleUtils.setSpanValue(rpan);
- this.thaPan = ParticleUtils.setSpanValue(thapan);
- this.type = ParticleUtils.initValue(type, 'vector');
- }
-
- normalizeVelocity(vr) {
- return vr * ParticleManager.MEASURE;
- }
-
- initialize(target) {
-
- if (this.type == 'p' || this.type == 'P' || this.type == 'polar')
- {
- var polar2d = new Polar2D(this.normalizeVelocity(this.rPan.getValue()), this.thaPan.getValue() * Math.PI / 180);
- target.v.x = polar2d.getX();
- target.v.y = polar2d.getY();
- }
- else
- {
- target.v.x = this.normalizeVelocity(this.rPan.getValue());
- target.v.y = this.normalizeVelocity(this.thaPan.getValue());
- }
- }
-
- }
-
-}
diff --git a/wip/TS Source/particles/zone/PointZone.js b/wip/TS Source/particles/zone/PointZone.js
deleted file mode 100644
index 705282c9..00000000
--- a/wip/TS Source/particles/zone/PointZone.js
+++ /dev/null
@@ -1,36 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Zones) {
- var PointZone = (function (_super) {
- __extends(PointZone, _super);
- function PointZone(x, y) {
- if (typeof x === "undefined") { x = 0; }
- if (typeof y === "undefined") { y = 0; }
- _super.call(this);
- this.x = x;
- this.y = y;
- }
- PointZone.prototype.getPosition = function () {
- return this.vector.setTo(this.x, this.y);
- };
- PointZone.prototype.crossing = function (particle) {
- if(this.alert) {
- alert('Sorry PointZone does not support crossing method');
- this.alert = false;
- }
- };
- return PointZone;
- })(Zones.Zone);
- Zones.PointZone = PointZone;
- })(Particles.Zones || (Particles.Zones = {}));
- var Zones = Particles.Zones;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/zone/PointZone.js.map b/wip/TS Source/particles/zone/PointZone.js.map
deleted file mode 100644
index 4f2107a2..00000000
--- a/wip/TS Source/particles/zone/PointZone.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"PointZone.js","sources":["PointZone.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Zones","Phaser.Particles.Zones.PointZone","Phaser.Particles.Zones.PointZone.constructor","Phaser.Particles.Zones.PointZone.getPosition","Phaser.Particles.Zones.PointZone.crossing"],"mappings":";;;;;AAEA,IAAO,MAAM;AA4BZ,CA5BD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,KAAKA;YAEzBC;;gBAEIC,SAFSA,SAASA,CAENA,CAAGA,EAACA,CAAGA;oBAAPC,gCAAAA,CAACA,GAACA,CAACA;AAAAA,oBAACA,gCAAAA,CAACA,GAACA,CAACA;AAAAA,oBACfA,6BAsBPA;oBArBOA,IAAIA,CAACA,CAACA,GAAGA,CAACA;oBACVA,IAAIA,CAACA,CAACA,GAAGA,CAACA;gBACdA,CAACA;gBAKDD,kCAAAA;oBACIE,OAAOA,IAAIA,CAACA,MAAMA,CAACA,KAAKA,CAACA,IAAIA,CAACA,CAACA,EAAEA,IAAIA,CAACA,CAACA,CAACA,CAACA;gBAC7CA,CAACA;gBAEDF,+BAAAA,UAASA,QAAQA;oBAEbG,GAAIA,IAAIA,CAACA,KAAKA,CAACA;wBAEXA,KAAKA,CAACA,kDAAkDA,CAACA;wBACzDA,IAAIA,CAACA,KAAKA,GAAGA,KAAKA;qBACrBA;gBAELA,CAACA;gBAELH;AAACA,YAADA,CAACA,EAzB8BD,UAAIA,EAyBlCA;YAzBDA,4BAyBCA,YAAAA;QACLA,CAACA,6CAAAD;QA5BMA;AA4BNA,IAADA,CAACA,+CAAAD;IA5BMA;AA4BNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/zone/PointZone.ts b/wip/TS Source/particles/zone/PointZone.ts
deleted file mode 100644
index 37387411..00000000
--- a/wip/TS Source/particles/zone/PointZone.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-///
-
-module Phaser.Particles.Zones {
-
- export class PointZone extends Zone {
-
- constructor(x=0,y=0) {
- super();
- this.x = x;
- this.y = y;
- }
-
- x;
- y;
-
- getPosition() {
- return this.vector.setTo(this.x, this.y);
- }
-
- crossing(particle) {
-
- if (this.alert)
- {
- alert('Sorry PointZone does not support crossing method');
- this.alert = false;
- }
-
- }
-
- }
-}
diff --git a/wip/TS Source/particles/zone/Zone.js b/wip/TS Source/particles/zone/Zone.js
deleted file mode 100644
index baf57135..00000000
--- a/wip/TS Source/particles/zone/Zone.js
+++ /dev/null
@@ -1,20 +0,0 @@
-var Phaser;
-(function (Phaser) {
- (function (Particles) {
- ///
- (function (Zones) {
- var Zone = (function () {
- function Zone() {
- this.vector = new Phaser.Vec2();
- this.random = 0;
- this.crossType = "dead";
- this.alert = true;
- }
- return Zone;
- })();
- Zones.Zone = Zone;
- })(Particles.Zones || (Particles.Zones = {}));
- var Zones = Particles.Zones;
- })(Phaser.Particles || (Phaser.Particles = {}));
- var Particles = Phaser.Particles;
-})(Phaser || (Phaser = {}));
diff --git a/wip/TS Source/particles/zone/Zone.js.map b/wip/TS Source/particles/zone/Zone.js.map
deleted file mode 100644
index b268e71a..00000000
--- a/wip/TS Source/particles/zone/Zone.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Zone.js","sources":["Zone.ts"],"names":["Phaser","Phaser.Particles","Phaser.Particles.Zones","Phaser.Particles.Zones.Zone","Phaser.Particles.Zones.Zone.constructor"],"mappings":"AAEA,IAAO,MAAM;AAiBZ,CAjBD,UAAO,MAAM;KAANA,UAAOA,SAASA;QAFvBC,8CAA8CA;SAEvCA,UAAiBA,KAAKA;YAEzBC;gBAEIC,SAFSA,IAAIA;oBAGTC,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,MAAMA,CAACA,IAAIA,EAAAA;oBAC7BA,IAAIA,CAACA,MAAMA,GAAGA,CAACA;oBACfA,IAAIA,CAACA,SAASA,GAAGA,MAAMA;oBACvBA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA;gBACrBA,CAACA;gBAOLD;AAACA,YAADA,CAACA,IAAAD;YAdDA,kBAcCA,YAAAA;QACLA,CAACA,6CAAAD;QAjBMA;AAiBNA,IAADA,CAACA,+CAAAD;IAjBMA;AAiBNA,CAAAA,2BAAA"}
\ No newline at end of file
diff --git a/wip/TS Source/particles/zone/Zone.ts b/wip/TS Source/particles/zone/Zone.ts
deleted file mode 100644
index 0c6b9286..00000000
--- a/wip/TS Source/particles/zone/Zone.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-///
-
-module Phaser.Particles.Zones {
-
- export class Zone {
-
- constructor() {
- this.vector = new Phaser.Vec2;
- this.random = 0;
- this.crossType = "dead";
- this.alert = true;
- }
-
- vector: Phaser.Vec2;
- random: number;
- crossType: string;
- alert: bool;
-
- }
-}
diff --git a/wip/TS Source/physics/AABB.ts b/wip/TS Source/physics/AABB.ts
deleted file mode 100644
index d2414099..00000000
--- a/wip/TS Source/physics/AABB.ts
+++ /dev/null
@@ -1,511 +0,0 @@
-///
-
-/**
-* Phaser - Physics - AABB
-*/
-
-module Phaser.Physics {
-
- export class AABB {
-
- constructor(game: Phaser.Game, x: number, y: number, width: number, height: number) {
-
- this.game = game;
-
- this.pos = new Phaser.Vec2(x, y);
- this.oldpos = new Phaser.Vec2(x, y);
-
- this.width = Math.abs(width);
- this.height = Math.abs(height);
-
- this.velocity = new Phaser.Vec2;
- this.acceleration = new Phaser.Vec2;
- this.bounce = new Phaser.Vec2(0, 0);
-
- //this.drag = new Phaser.Vec2(1, 1);
- //this.gravity = new Phaser.Vec2(0, 0.2);
-
- this.drag = new Phaser.Vec2(0, 0);
- this.gravity = new Phaser.Vec2(0, 0);
-
- this.maxVelocity = new Phaser.Vec2(1000, 1000);
-
- this.aabbTileProjections = {};
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_22DEGs] = Phaser.Physics.Projection.AABB22Deg.CollideS;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_22DEGb] = Phaser.Physics.Projection.AABB22Deg.CollideB;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_45DEG] = Phaser.Physics.Projection.AABB45Deg.Collide;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_67DEGs] = Phaser.Physics.Projection.AABB67Deg.CollideS;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_67DEGb] = Phaser.Physics.Projection.AABB67Deg.CollideB;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONCAVE] = Phaser.Physics.Projection.AABBConcave.Collide;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONVEX] = Phaser.Physics.Projection.AABBConvex.Collide;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_FULL] = Phaser.Physics.Projection.AABBFull.Collide;
- this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_HALF] = Phaser.Physics.Projection.AABBHalf.Collide;
-
- }
-
- public game: Phaser.Game;
-
- public velocity: Phaser.Vec2;
- public acceleration: Phaser.Vec2;
- public drag: Phaser.Vec2;
- public gravity: Phaser.Vec2;
- public bounce: Phaser.Vec2;
- public maxVelocity: Phaser.Vec2;
-
- public static COL_NONE = 0;
- public static COL_AXIS = 1;
- public static COL_OTHER = 2;
-
- public type: number = 0;
- public pos: Phaser.Vec2;
- public oldpos: Phaser.Vec2;
- public width: number;
- public height: number;
- public oH: number;
- public oV: number;
-
- public _vx: number = 0;
- public _vy: number = 0;
- public _deltaX: number = 0;
- public _deltaY: number = 0;
-
- private aabbTileProjections;
-
- public update() {
-
- // N+ update loop
- this.integrateVerlet();
-
- if (this.acceleration.x != 0)
- {
- this.velocity.x += (this.acceleration.x * this.game.time.physicsElapsed);
- }
-
- if (this.acceleration.y != 0)
- {
- this.velocity.y += (this.acceleration.y * this.game.time.physicsElapsed);
- }
-
- this._vx = this.velocity.x * this.game.time.physicsElapsed;
- this._vy = this.velocity.y * this.game.time.physicsElapsed;
-
- var vx = this.pos.x - this.oldpos.x;
- var vy = this.pos.y - this.oldpos.y;
-
- this._deltaX = Math.min(20, Math.max(-20, vx + this._vx));
- this._deltaY = Math.min(20, Math.max(-20, vy + this._vy));
-
- this.pos.x = this.oldpos.x + this._deltaX;
- this.pos.y = this.oldpos.y + this._deltaY;
-
- }
-
- public Nupdate() {
-
- // N+ update loop
- this.integrateVerlet();
-
- var p = this.pos;
- var o = this.oldpos;
- var vx = p.x - o.x;
- var vy = p.y - o.y;
-
- var newx = Math.min(20, Math.max(-20, vx + this._vx));
- var newy = Math.min(20, Math.max(-20, vy + this._vy));
-
- this.pos.x = o.x + newx;
- this.pos.y = o.y + newy;
-
- }
-
- public updateFlixel() {
-
- // Add 'go to sleep' option
-
- this.oldpos.x = this.pos.x; //get vector values
- this.oldpos.y = this.pos.y; //p = position
-
- this._vx = (this.game.physics.computeVelocity(this.velocity.x, this.gravity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2;
- this.velocity.x += this._vx;
- //this.pos.x += (this.velocity.x * this.game.time.physicsElapsed) + this.gravity.x;
- //this.pos.x += (this.velocity.x * this.game.time.physicsElapsed);
- this._deltaX = this.velocity.x * this.game.time.physicsElapsed;
- //body.aabb.pos.x += this._delta;
-
- this._vy = (this.game.physics.computeVelocity(this.velocity.y, this.gravity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2;
- //this._vy = this.game.physics.computeVelocity(this.velocity.y, this.gravity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y);
- this.velocity.y += this._vy;
- //this.pos.y += (this.velocity.y * this.game.time.physicsElapsed) + this.gravity.y;
- //this.pos.y += (this.velocity.y * this.game.time.physicsElapsed);
- this._deltaY = this.velocity.y * this.game.time.physicsElapsed;
-
- this.pos.x += this._deltaX;
- this.pos.y += this._deltaY;
-
- //this.integrateVerlet();
-
- //var ox = this.oldpos.x;
- //var oy = this.oldpos.y;
-
- }
-
- public FFupdate() {
-
- this.oldpos.x = this.pos.x; //get vector values
- this.oldpos.y = this.pos.y; //p = position
-
- if (this.acceleration.x != 0)
- {
- this.velocity.x += (this.acceleration.x / 1000 * this.game.time.delta);
- }
-
- if (this.acceleration.y != 0)
- {
- this.velocity.y += (this.acceleration.y / 1000 * this.game.time.delta);
- }
-
- this._vx = ((this.velocity.x / 1000) * this.game.time.delta);
- this._vy = ((this.velocity.y / 1000) * this.game.time.delta);
-
- if (this._vx != 0)
- {
- if (this.drag.x != 0)
- {
- this._vx * this.drag.x;
- }
-
- if (this.gravity.x != 0)
- {
- this._vx * this.gravity.x;
- }
-
- if (this.velocity.x > this.maxVelocity.x)
- {
- this.velocity.x = this.maxVelocity.x;
- }
- else if (this.velocity.x < -this.maxVelocity.x)
- {
- this.velocity.x = -this.maxVelocity.x;
- }
- }
-
- if (this._vy != 0)
- {
- if (this.drag.y != 0)
- {
- this._vy * this.drag.y;
- }
-
- if (this.gravity.y != 0)
- {
- this._vy * this.gravity.y;
- }
-
- if (this.velocity.y > this.maxVelocity.y)
- {
- this.velocity.y = this.maxVelocity.y;
- }
- else if (this.velocity.y < -this.maxVelocity.y)
- {
- this.velocity.y = -this.maxVelocity.y;
- }
- }
-
- this.pos.x += this._vx;
- this.pos.y += this._vy;
-
- //this._vx = (this.game.physics.computeVelocity(this.velocity.x, this.gravity.x, this.acceleration.x, this.fdrag.x, this.maxVelocity.x) - this.velocity.x) / 2;
- //this.velocity.x += this._vx;
- //this.pos.x += (this.velocity.x * this.game.time.physicsElapsed) + this.gravity.x;
-
- //this._vy = (this.game.physics.computeVelocity(this.velocity.y, this.gravity.y, this.acceleration.y, this.fdrag.y, this.maxVelocity.y) - this.velocity.y) / 2;
- //this.velocity.y += this._vy;
- //this.pos.y += (this.velocity.y * this.game.time.physicsElapsed) + this.gravity.y;
-
- //this.integrateVerlet();
-
- //var ox = this.oldpos.x;
- //var oy = this.oldpos.y;
-
- //this.oldpos.x = this.pos.x; //get vector values
- //this.oldpos.y = this.pos.y; //p = position
-
- //integrate
- //this.pos.x += (this.drag.x * this.pos.x) - (this.drag.x * ox) + this.gravity.x;
- //this.pos.y += (this.drag.y * this.pos.y) - (this.drag.y * oy) + this.gravity.y;
-
- //this._vx = (this.velocity.x / 1000 * this.game.time.delta);
- //this._vy = (this.velocity.y / 1000 * this.game.time.delta);
- //this._vx = 0.2;
- //this._vy = 0.2;
-
- //this.pos.x = this.oldpos.x + Math.min(20, Math.max(-20, this.pos.x - this.oldpos.x + this._vx));
- //this.pos.y = this.oldpos.y + Math.min(20, Math.max(-20, this.pos.y - this.oldpos.y + this._vy));
-
- //this.integrateVerlet();
-
- }
-
- public integrateVerlet() {
-
- var ox = this.oldpos.x;
- var oy = this.oldpos.y;
-
- this.oldpos.x = this.pos.x; //get vector values
- this.oldpos.y = this.pos.y; //p = position
-
- //integrate
- this.pos.x += (this.drag.x * this.pos.x) - (this.drag.x * ox) + this.gravity.x;
- this.pos.y += (this.drag.y * this.pos.y) - (this.drag.y * oy) + this.gravity.y;
-
- }
-
- public reportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: TileMapCell = null) {
-
- //calc velocity (original way)
- var vx = this.pos.x - this.oldpos.x;
- var vy = this.pos.y - this.oldpos.y;
-
- //find component of velocity parallel to collision normal
- var dp = (vx * dx + vy * dy);
- var nx = dp * dx;//project velocity onto collision normal
- var ny = dp * dy;//nx,ny is normal velocity
-
- var tx = vx - nx;//px,py is tangent velocity
- var ty = vy - ny;
-
- //we only want to apply collision response forces if the object is travelling into, and not out of, the collision
-
- // default is moving out of collision, don't apply force
- var bx = 0;
- var by = 0;
- var fx = 0;
- var fy = 0;
-
- if (dp < 0)
- {
- // moving into collision, apply forces
- var f = 0.05; // friction
- fx = tx * f;
- fy = ty * f;
-
- var b = 1 + 0.5;//this bounce constant should be elsewhere, i.e inside the object/tile/etc..
-
- bx = (nx * b);
- by = (ny * b);
- }
-
- // project object out of collision
- this.pos.x += px;
- this.pos.y += py;
-
- this.oldpos.x += px + bx + fx;
- this.oldpos.y += py + by + fy;
-
- }
-
- public TWEAKEDreportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: TileMapCell = null) {
-
- //calc velocity (original way)
- //this._vx = this.pos.x - this.oldpos.x;
- //this._vy = this.pos.y - this.oldpos.y;
- //var vx = this.pos.x - this.oldpos.x;
- //var vy = this.pos.y - this.oldpos.y;
-
- //find component of velocity parallel to collision normal
- //var dp = (vx * dx + vy * dy);
- //var nx = dp * dx;//project velocity onto collision normal
- //var ny = dp * dy;//nx,ny is normal velocity
-
- //var tx = vx - nx;//px,py is tangent velocity
- //var ty = vy - ny;
-
- var dp = (this._vx * dx + this._vy * dy);
- var nx = dp * dx;//project velocity onto collision normal
- var ny = dp * dy;//nx,ny is normal velocity
-
- var tx = this._vx - nx;//px,py is tangent velocity
- var ty = this._vy - ny;
-
- //console.log('nxy', nx, ny);
- //console.log('nxy', nx, ny);
- //console.log('txy', tx, ty);
-
- this.pos.x += px; //project object out of collision
- this.pos.y += py;
-
- //this.oldpos.x += px;
- //this.oldpos.y += py;
- //this.pos.x += px;
- //this.pos.y += py;
-
- //this.velocity.x += nx;
- //this.velocity.y += ny;
-
- //we only want to apply collision response forces if the object is travelling into, and not out of, the collision
- if (dp < 0)
- //if (1 < 0)
- {
- // moving into collision, apply forces
- //var b = 1 + 0.5;//this bounce constant should be elsewhere, i.e inside the object/tile/etc..
- //var b = 0.5;//this bounce constant should be elsewhere, i.e inside the object/tile/etc..
- //var f = 0.05; // friction
- //var fx = tx * f;
- //var fy = ty * f;
-
- //this.oldpos.x += (nx * b) + fx;//apply bounce+friction impulses which alter velocity
- //this.oldpos.y += (ny * b) + fy;
- this.velocity.x += nx;
- this.velocity.y += ny;
-
- if (dx !== 0)
- {
- this.velocity.x *= -1 * this.bounce.x;
- }
-
- if (dy !== 0)
- {
- this.velocity.y *= -1 * this.bounce.y;
- }
- }
-
- }
-
- public collideAABBVsTile(tile: Phaser.Physics.TileMapCell) {
-
- var pos = this.pos;
- var c = tile;
-
- var tx = c.pos.x;
- var ty = c.pos.y;
- var txw = c.xw;
- var tyw = c.yw;
-
- var dx = pos.x - tx;//tile->obj delta
- var px = (txw + this.width) - Math.abs(dx);//penetration depth in x
-
- if (0 < px)
- {
- var dy = pos.y - ty;//tile->obj delta
- var py = (tyw + this.height) - Math.abs(dy);//pen depth in y
-
- if (0 < py)
- {
- //object may be colliding with tile; call tile-specific collision function
-
- //calculate projection vectors
- if (px < py)
- {
- //project in x
- if (dx < 0)
- {
- //project to the left
- px *= -1;
- py = 0;
- }
- else
- {
- //proj to right
- py = 0;
- }
- }
- else
- {
- //project in y
- if (dy < 0)
- {
- //project up
- px = 0;
- py *= -1;
- }
- else
- {
- //project down
- px = 0;
- }
- }
-
- this.resolveBoxTile(px, py, this, c);
-
- }
- }
- }
-
- public collideAABBVsWorldBounds() {
-
- var p = this.pos;
- var xw = this.width;
- var yw = this.height;
- var XMIN = 0;
- var XMAX = 800;
- var YMIN = 0;
- var YMAX = 600;
-
- //collide vs. x-bounds
- //test XMIN left side
- var dx = XMIN - (p.x - xw);
- if (0 < dx)
- {
- //object is colliding with XMIN
- this.reportCollisionVsWorld(dx, 0, 1, 0, null);
- }
- else
- {
- //test XMAX right side
- dx = (p.x + xw) - XMAX;
- if (0 < dx)
- {
- //object is colliding with XMAX
- this.reportCollisionVsWorld(-dx, 0, -1, 0, null);
- }
- }
-
- //collide vs. y-bounds
- //test YMIN top
- var dy = YMIN - (p.y - yw);
- if (0 < dy)
- {
- //object is colliding with YMIN
- this.reportCollisionVsWorld(0, dy, 0, 1, null);
- }
- else
- {
- //test YMAX bottom
- dy = (p.y + yw) - YMAX;
- if (0 < dy)
- {
- //object is colliding with YMAX
- this.reportCollisionVsWorld(0, -dy, 0, -1, null);
- }
- }
- }
-
- public resolveBoxTile(x, y, box, t) {
-
- if (0 < t.ID)
- {
- return this.aabbTileProjections[t.CTYPE](x, y, box, t);
- }
- else
- {
- //trace("resolveBoxTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
-
- public render(context: CanvasRenderingContext2D) {
-
- context.beginPath();
- context.strokeStyle = 'rgb(0,255,0)';
- context.strokeRect(this.pos.x - this.width, this.pos.y - this.height, this.width * 2, this.height * 2);
- context.stroke();
- context.closePath();
-
- context.fillStyle = 'rgb(0,255,0)';
- context.fillRect(this.pos.x, this.pos.y, 2, 2);
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/Body.ts b/wip/TS Source/physics/Body.ts
deleted file mode 100644
index 404d9a5b..00000000
--- a/wip/TS Source/physics/Body.ts
+++ /dev/null
@@ -1,215 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Body
-* A binding between a Sprite and a physics object (AABB or Circle)
-*/
-
-module Phaser.Physics {
-
- export class Body {
-
- constructor(sprite: Phaser.Sprite, type: number) {
-
- this.sprite = sprite;
- this.game = sprite.game;
- this.type = type;
-
- this.aabb = new Phaser.Physics.AABB(sprite.game, sprite.x, sprite.y, sprite.width, sprite.height);
-
- this.velocity = new Phaser.Vec2;
- this.acceleration = new Phaser.Vec2;
- this.drag = new Phaser.Vec2;
- this.gravity = new Phaser.Vec2;
- this.maxVelocity = new Phaser.Vec2(10000, 10000);
-
- this.angularVelocity = 0;
- this.angularAcceleration = 0;
- this.angularDrag = 0;
- this.maxAngular = 10000;
-
- //this.touching = Phaser.Types.NONE;
- //this.wasTouching = Phaser.Types.NONE;
- this.allowCollisions = Phaser.Types.ANY;
-
- //this.position = new Phaser.Vec2(sprite.x + this.bounds.halfWidth, sprite.y + this.bounds.halfHeight);
- //this.oldPosition = new Phaser.Vec2(sprite.x + this.bounds.halfWidth, sprite.y + this.bounds.halfHeight);
- //this.offset = new Phaser.Vec2;
-
- }
-
- public game: Phaser.Game;
- public sprite: Phaser.Sprite;
- public aabb: Phaser.Physics.AABB;
- public bounds: Phaser.Rectangle;
-
- /**
- * The type of Body (disabled, dynamic, static or kinematic)
- * Disabled = skips all physics operations / tests (default)
- * Dynamic = gives and receives impacts
- * Static = gives but doesn't receive impacts, cannot be moved by physics
- * Kinematic = gives impacts, but never receives, can be moved by physics
- * @type {number}
- */
- public type: number;
-
- public gravity: Phaser.Vec2;
- public bounce: Phaser.Vec2;
-
- public velocity: Phaser.Vec2;
- public acceleration: Phaser.Vec2;
- public drag: Phaser.Vec2;
- public maxVelocity: Phaser.Vec2;
-
- public angularVelocity: number = 0;
- public angularAcceleration: number = 0;
- public angularDrag: number = 0;
- public maxAngular: number = 10000;
-
- /**
- * Orientation of the object.
- * @type {number}
- */
- public facing: number;
-
- public deltaX: number = 0;
- public deltaY: number = 0;
-
- //public touching: number;
- public allowCollisions: number;
- //public wasTouching: number;
- //public mass: number = 1;
-
- //public position: Phaser.Vec2;
- //public oldPosition: Phaser.Vec2;
- //public offset: Phaser.Vec2;
- //public bounds: Phaser.Rectangle;
-
-/*
- private _width: number = 0;
- private _height: number = 0;
-
- public get x(): number {
- return this.sprite.x + this.offset.x;
- }
-
- public get y(): number {
- return this.sprite.y + this.offset.y;
- }
-
- public set width(value: number) {
- this._width = value;
- }
-
- public set height(value: number) {
- this._height = value;
- }
-
- public get width(): number {
- return this._width * this.sprite.transform.scale.x;
- }
-
- public get height(): number {
- return this._height * this.sprite.transform.scale.y;
- }
-
- public preUpdate() {
-
- this.oldPosition.copyFrom(this.position);
-
- this.bounds.x = this.x;
- this.bounds.y = this.y;
- this.bounds.width = this.width;
- this.bounds.height = this.height;
-
- }
-
- // Shall we do this? Or just update the values directly in the separate functions? But then the bounds will be out of sync - as long as
- // the bounds are updated and used in calculations then we can do one final sprite movement here I guess?
- public postUpdate() {
-
- // if this is all it does maybe move elsewhere? Sprite postUpdate?
- if (this.type !== Phaser.Types.BODY_DISABLED)
- {
- //this.game.world.physics.updateMotion(this);
-
- this.wasTouching = this.touching;
- this.touching = Phaser.Types.NONE;
-
- }
-
- this.position.setTo(this.x, this.y);
-
- }
-
- public get hullWidth(): number {
-
- if (this.deltaX > 0)
- {
- return this.bounds.width + this.deltaX;
- }
- else
- {
- return this.bounds.width - this.deltaX;
- }
-
- }
-
- public get hullHeight(): number {
-
- if (this.deltaY > 0)
- {
- return this.bounds.height + this.deltaY;
- }
- else
- {
- return this.bounds.height - this.deltaY;
- }
-
- }
-
- public get hullX(): number {
-
- if (this.position.x < this.oldPosition.x)
- {
- return this.position.x;
- }
- else
- {
- return this.oldPosition.x;
- }
-
- }
-
- public get hullY(): number {
-
- if (this.position.y < this.oldPosition.y)
- {
- return this.position.y;
- }
- else
- {
- return this.oldPosition.y;
- }
-
- }
-
- public get deltaXAbs(): number {
- return (this.deltaX > 0 ? this.deltaX : -this.deltaX);
- }
-
- public get deltaYAbs(): number {
- return (this.deltaY > 0 ? this.deltaY : -this.deltaY);
- }
-
- public get deltaX(): number {
- return this.position.x - this.oldPosition.x;
- }
-
- public get deltaY(): number {
- return this.position.y - this.oldPosition.y;
- }
-*/
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/Circle.ts b/wip/TS Source/physics/Circle.ts
deleted file mode 100644
index c29952ac..00000000
--- a/wip/TS Source/physics/Circle.ts
+++ /dev/null
@@ -1,286 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Circle
-*/
-
-module Phaser.Physics {
-
- export class Circle {
-
- constructor(game: Phaser.Game, x: number, y: number, radius:number) {
-
- this.game = game;
-
- this.pos = new Phaser.Vec2(x, y);
- this.oldpos = new Phaser.Vec2(x, y);
- this.radius = radius;
-
- this.circleTileProjections = {};
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_22DEGs] = Phaser.Physics.Projection.Circle22Deg.CollideS;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_22DEGb] = Phaser.Physics.Projection.Circle22Deg.CollideB;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_45DEG] = Phaser.Physics.Projection.Circle45Deg.Collide;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_67DEGs] = Phaser.Physics.Projection.Circle67Deg.CollideS;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_67DEGb] = Phaser.Physics.Projection.Circle67Deg.CollideB;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONCAVE] = Phaser.Physics.Projection.CircleConcave.Collide;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONVEX] = Phaser.Physics.Projection.CircleConvex.Collide;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_FULL] = Phaser.Physics.Projection.CircleFull.Collide;
- this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_HALF] = Phaser.Physics.Projection.CircleHalf.Collide;
-
- }
-
- public game: Phaser.Game;
-
- public static COL_NONE = 0;
- public static COL_AXIS = 1;
- public static COL_OTHER = 2;
-
- public type: number = 1;
- public pos: Phaser.Vec2;
- public oldpos: Phaser.Vec2;
- public radius: number;
- public oH: number; // horizontal collision
- public oV: number; // vertical collision
-
- private circleTileProjections;
-
- public integrateVerlet() {
-
- var d = 1; // drag
- var g = 0.2; // gravity
-
- var p = this.pos;
- var o = this.oldpos;
- var px;
- var py;
-
- var ox = o.x;
- var oy = o.y;
- //o = oldposition
- o.x = px = p.x; //get vector values
- o.y = py = p.y; //p = position
-
- //integrate
- p.x += (d * px) - (d * ox);
- p.y += (d * py) - (d * oy) + g;
-
- }
-
- // px projection vector
- // dx surface normal
- public reportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: Phaser.Physics.TileMapCell = null) {
-
- var p = this.pos;
- var o = this.oldpos;
-
- //calc velocity
- var vx = p.x - o.x;
- var vy = p.y - o.y;
-
- //find component of velocity parallel to collision normal
- var dp = (vx * dx + vy * dy);
- var nx = dp * dx;//project velocity onto collision normal
-
- var ny = dp * dy;//nx,ny is normal velocity
-
- var tx = vx - nx;//px,py is tangent velocity
- var ty = vy - ny;
-
- //we only want to apply collision response forces if the object is travelling into, and not out of, the collision
- var b, bx, by, f, fx, fy;
-
- if (dp < 0)
- {
- //f = FRICTION;
- f = 0.05;
- fx = tx * f;
- fy = ty * f;
-
- //b = 1 + BOUNCE;//this bounce constant should be elsewhere, i.e inside the object/tile/etc..
- b = 1 + 0.3;//this bounce constant should be elsewhere, i.e inside the object/tile/etc..
-
- bx = (nx * b);
- by = (ny * b);
- }
- else
- {
- //moving out of collision, do not apply forces
- bx = by = fx = fy = 0;
- }
-
- p.x += px;//project object out of collision
- p.y += py;
-
- o.x += px + bx + fx;//apply bounce+friction impulses which alter velocity
- o.y += py + by + fy;
-
- }
-
- public collideCircleVsWorldBounds() {
-
- var p = this.pos;
- var r = this.radius;
- var XMIN = 0;
- var XMAX = 800;
- var YMIN = 0;
- var YMAX = 600;
-
- //collide vs. x-bounds
- //test XMIN
- var dx = XMIN - (p.x - r);
-
- if (0 < dx)
- {
- //object is colliding with XMIN
- this.reportCollisionVsWorld(dx, 0, 1, 0, null);
- }
- else
- {
- //test XMAX
- dx = (p.x + r) - XMAX;
- if (0 < dx)
- {
- //object is colliding with XMAX
- this.reportCollisionVsWorld(-dx, 0, -1, 0, null);
- }
- }
-
- //collide vs. y-bounds
- //test YMIN
- var dy = YMIN - (p.y - r);
-
- if (0 < dy)
- {
- //object is colliding with YMIN
- this.reportCollisionVsWorld(0, dy, 0, 1, null);
- }
- else
- {
- //test YMAX
- dy = (p.y + r) - YMAX;
- if (0 < dy)
- {
- //object is colliding with YMAX
- this.reportCollisionVsWorld(0, -dy, 0, -1, null);
- }
- }
- }
-
- public render(context: CanvasRenderingContext2D) {
-
- context.beginPath();
- context.strokeStyle = 'rgb(0,255,0)';
- context.arc(this.pos.x, this.pos.y, this.radius, 0, Math.PI * 2);
- context.stroke();
- context.closePath();
-
- if (this.oH == 1)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.pos.x - this.radius, this.pos.y - this.radius);
- context.lineTo(this.pos.x - this.radius, this.pos.y + this.radius);
- context.stroke();
- context.closePath();
- }
- else if (this.oH == -1)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.pos.x + this.radius, this.pos.y - this.radius);
- context.lineTo(this.pos.x + this.radius, this.pos.y + this.radius);
- context.stroke();
- context.closePath();
- }
-
- if (this.oV == 1)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.pos.x - this.radius, this.pos.y - this.radius);
- context.lineTo(this.pos.x + this.radius, this.pos.y - this.radius);
- context.stroke();
- context.closePath();
- }
- else if (this.oV == -1)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.pos.x - this.radius, this.pos.y + this.radius);
- context.lineTo(this.pos.x + this.radius, this.pos.y + this.radius);
- context.stroke();
- context.closePath();
- }
-
- }
-
- public collideCircleVsTile(tile) {
-
- var pos = this.pos;
- var r = this.radius;
- var c = tile;
-
- var tx = c.pos.x;
- var ty = c.pos.y;
- var txw = c.xw;
- var tyw = c.yw;
-
- var dx = pos.x - tx;//tile->obj delta
- var px = (txw + r) - Math.abs(dx);//penetration depth in x
-
- if (0 < px)
- {
- var dy = pos.y - ty;//tile->obj delta
- var py = (tyw + r) - Math.abs(dy);//pen depth in y
-
- if (0 < py)
- {
- //object may be colliding with tile
-
- //determine grid/voronoi region of circle center
- this.oH = 0;
- this.oV = 0;
- if (dx < -txw)
- {
- //circle is on left side of tile
- this.oH = -1;
- }
- else if (txw < dx)
- {
- //circle is on right side of tile
- this.oH = 1;
- }
-
- if (dy < -tyw)
- {
- //circle is on top side of tile
- this.oV = -1;
- }
- else if (tyw < dy)
- {
- //circle is on bottom side of tile
- this.oV = 1;
- }
-
- this.resolveCircleTile(px, py, this.oH, this.oV, this, c);
-
- }
- }
- }
-
- public resolveCircleTile(x, y, oH, oV, obj, t) {
-
- if (0 < t.ID)
- {
- return this.circleTileProjections[t.CTYPE](x, y, oH, oV, obj, t);
- }
- else
- {
- console.log("resolveCircleTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " (" + t.i + "," + t.j + ")");
- return false;
- }
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/PhysicsManager.ts b/wip/TS Source/physics/PhysicsManager.ts
deleted file mode 100644
index f683537b..00000000
--- a/wip/TS Source/physics/PhysicsManager.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-///
-
-/**
-* Phaser - Physics - PhysicsManager
-*/
-
-module Phaser.Physics {
-
- export class PhysicsManager {
-
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- //this.gravity = new Vec2;
- //this.drag = new Vec2;
- //this.bounce = new Vec2;
- //this.angularDrag = 0;
-
- //this.bounds = new Rectangle(0, 0, width, height);
-
- //this._distance = new Vec2;
- //this._tangent = new Vec2;
-
- }
-
- public game: Phaser.Game;
-
- // Temp calculation vars
- private _drag: number;
- private _delta: number;
- private _velocityDelta: number;
- private _length: number = 0;
- private _distance: Vec2;
- private _tangent: Vec2;
- private _separatedX: bool;
- private _separatedY: bool;
- private _overlap: number;
- private _maxOverlap: number;
- private _obj1Velocity: number;
- private _obj2Velocity: number;
- private _obj1NewVelocity: number;
- private _obj2NewVelocity: number;
- private _average: number;
- private _quadTree: QuadTree;
- private _quadTreeResult: bool;
-
- //public bounds: Rectangle;
-
- //public gravity: Vec2;
- //public drag: Vec2;
- //public bounce: Vec2;
- //public angularDrag: number;
-
- grav: number = 0.2;
- drag: number = 1;
- bounce: number = 0.3;
- friction: number = 0.05;
-
- min_f: number = 0;
- max_f: number = 1;
-
- min_b: number = 0;
- max_b: number = 1;
-
- min_g: number = 0;
- max_g = 1;
-
- xmin: number = 0;
- xmax: number = 800;
- ymin: number = 0;
- ymax: number = 600;
-
- objrad: number = 24;
- tilerad: number = 24 * 2;
- objspeed: number = 0.2;
- maxspeed: number = 20;
-
- public update() {
- }
-
- public updateMotion(body: Phaser.Physics.Body) {
-
- this._velocityDelta = (this.computeVelocity(body.angularVelocity, body.gravity.x, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) / 2;
- body.angularVelocity += this._velocityDelta;
- body.sprite.transform.rotation += body.angularVelocity * this.game.time.physicsElapsed;
- body.angularVelocity += this._velocityDelta;
-
- this._velocityDelta = (this.computeVelocity(body.velocity.x, body.gravity.x, body.acceleration.x, body.drag.x) - body.velocity.x) / 2;
- body.velocity.x += this._velocityDelta;
- this._delta = body.velocity.x * this.game.time.physicsElapsed;
-
- body.aabb.pos.x += this._delta;
- body.deltaX = this._delta;
-
- this._velocityDelta = (this.computeVelocity(body.velocity.y, body.gravity.y, body.acceleration.y, body.drag.y) - body.velocity.y) / 2;
- body.velocity.y += this._velocityDelta;
- this._delta = body.velocity.y * this.game.time.physicsElapsed;
-
- body.aabb.pos.y += this._delta;
- body.deltaY = this._delta;
-
- //body.aabb.integrateVerlet();
-
- }
-
- /**
- * A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
- *
- * @param {number} Velocity Any component of velocity (e.g. 20).
- * @param {number} Acceleration Rate at which the velocity is changing.
- * @param {number} Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
- * @param {number} Max An absolute value cap for the velocity.
- *
- * @return {number} The altered Velocity value.
- */
- public computeVelocity(velocity: number, gravity: number = 0, acceleration: number = 0, drag: number = 0, max: number = 10000): number {
-
- if (acceleration !== 0)
- {
- velocity += (acceleration + gravity) * this.game.time.physicsElapsed;
- }
- else if (drag !== 0)
- {
- this._drag = drag * this.game.time.physicsElapsed;
-
- if (velocity - this._drag > 0)
- {
- velocity = velocity - this._drag;
- }
- else if (velocity + this._drag < 0)
- {
- velocity += this._drag;
- }
- else
- {
- velocity = 0;
- }
- }
-
- //velocity += gravity;
-
- if (velocity != 0)
- {
- if (velocity > max)
- {
- velocity = max;
- }
- else if (velocity < -max)
- {
- velocity = -max;
- }
- }
-
- return velocity;
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/physics/TileMapCell.ts b/wip/TS Source/physics/TileMapCell.ts
deleted file mode 100644
index b3081b96..00000000
--- a/wip/TS Source/physics/TileMapCell.ts
+++ /dev/null
@@ -1,492 +0,0 @@
-///
-
-/**
-* Phaser - Physics - TileMapCell
-*/
-
-module Phaser.Physics {
-
- export class TileMapCell {
-
- constructor(game: Phaser.Game, x: number, y: number, xw: number, yw: number) {
-
- this.game = game;
- this.ID = TileMapCell.TID_EMPTY; //all tiles start empty
- this.CTYPE = TileMapCell.CTYPE_EMPTY;
-
- this.pos = new Phaser.Vec2(x, y); //setup collision properties
- this.xw = xw;
- this.yw = yw;
- this.minx = this.pos.x - this.xw;
- this.maxx = this.pos.x + this.xw;
- this.miny = this.pos.y - this.yw;
- this.maxy = this.pos.y + this.yw;
-
- //this stores tile-specific collision information
- this.signx = 0;
- this.signy = 0;
- this.sx = 0;
- this.sy = 0;
-
- }
-
- public game: Phaser.Game;
-
- static TID_EMPTY = 0;
- static TID_FULL = 1;//fullAABB tile
- static TID_45DEGpn = 2;//45-degree triangle, whose normal is (+ve,-ve)
- static TID_45DEGnn = 3;//(+ve,+ve)
- static TID_45DEGnp = 4;//(-ve,+ve)
- static TID_45DEGpp = 5;//(-ve,-ve)
- static TID_CONCAVEpn = 6;//1/4-circle cutout
- static TID_CONCAVEnn = 7;
- static TID_CONCAVEnp = 8;
- static TID_CONCAVEpp = 9;
- static TID_CONVEXpn = 10;//1/4/circle
- static TID_CONVEXnn = 11;
- static TID_CONVEXnp = 12;
- static TID_CONVEXpp = 13;
- static TID_22DEGpnS = 14;//22.5 degree slope
- static TID_22DEGnnS = 15;
- static TID_22DEGnpS = 16;
- static TID_22DEGppS = 17;
- static TID_22DEGpnB = 18;
- static TID_22DEGnnB = 19;
- static TID_22DEGnpB = 20;
- static TID_22DEGppB = 21;
- static TID_67DEGpnS = 22;//67.5 degree slope
- static TID_67DEGnnS = 23;
- static TID_67DEGnpS = 24;
- static TID_67DEGppS = 25;
- static TID_67DEGpnB = 26;
- static TID_67DEGnnB = 27;
- static TID_67DEGnpB = 28;
- static TID_67DEGppB = 29;
- static TID_HALFd = 30;//half-full tiles
- static TID_HALFr = 31;
- static TID_HALFu = 32;
- static TID_HALFl = 33;
-
- //collision shape "types"
- static CTYPE_EMPTY = 0;
- static CTYPE_FULL = 1;
- static CTYPE_45DEG = 2;
- static CTYPE_CONCAVE = 6;
- static CTYPE_CONVEX = 10;
- static CTYPE_22DEGs = 14;
- static CTYPE_22DEGb = 18;
- static CTYPE_67DEGs = 22;
- static CTYPE_67DEGb = 26;
- static CTYPE_HALF = 30;
-
- ID;
- CTYPE;
- pos: Phaser.Vec2;
- xw;
- yw;
- minx;
- maxx;
- miny;
- maxy;
- signx;
- signy;
- sx;
- sy;
-
- //these functions are used to update the cell
- //note: ID is assumed to NOT be "empty" state..
- //if it IS the empty state, the tile clears itself
- SetState(ID) {
- if (ID == TileMapCell.TID_EMPTY)
- {
- this.Clear();
- }
- else
- {
- //set tile state to a non-emtpy value, and update it's edges and those of the neighbors
- this.ID = ID;
- this.UpdateType();
- //this.Draw();
- }
- return this;
- }
-
- Clear() {
- //tile was on, turn it off
- this.ID = TileMapCell.TID_EMPTY
- this.UpdateType();
- //this.Draw();
- }
-
- public render(context: CanvasRenderingContext2D) {
-
- context.beginPath();
- context.strokeStyle = 'rgb(255,255,0)';
- context.strokeRect(this.minx, this.miny, this.xw * 2, this.yw * 2);
- context.strokeRect(this.pos.x, this.pos.y, 2, 2);
- context.closePath();
-
- }
-
- //this converts a tile from implicitly-defined (via ID), to explicit (via properties)
- UpdateType() {
- if (0 < this.ID)
- {
- //tile is non-empty; collide
- if (this.ID < TileMapCell.CTYPE_45DEG)
- {
- //TID_FULL
- this.CTYPE = TileMapCell.CTYPE_FULL;
- this.signx = 0;
- this.signy = 0;
- this.sx = 0;
- this.sy = 0;
-
- }
- else if (this.ID < TileMapCell.CTYPE_CONCAVE)
- {
-
- //45deg
- this.CTYPE = TileMapCell.CTYPE_45DEG;
- if (this.ID == TileMapCell.TID_45DEGpn)
- {
- console.log('set tile as 45deg pn');
- this.signx = 1;
- this.signy = -1;
- this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
- this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
-
- }
- else if (this.ID == TileMapCell.TID_45DEGnn)
- {
- this.signx = -1;
- this.signy = -1;
- this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
- this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
-
- }
- else if (this.ID == TileMapCell.TID_45DEGnp)
- {
- this.signx = -1;
- this.signy = 1;
- this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
- this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
- }
- else if (this.ID == TileMapCell.TID_45DEGpp)
- {
- this.signx = 1;
- this.signy = 1;
- this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
- this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
- }
- else
- {
- //trace("BAAAD TILE!!!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
- else if (this.ID < TileMapCell.CTYPE_CONVEX)
- {
-
- //concave
- this.CTYPE = TileMapCell.CTYPE_CONCAVE;
- if (this.ID == TileMapCell.TID_CONCAVEpn)
- {
- this.signx = 1;
- this.signy = -1;
- this.sx = 0;
- this.sy = 0;
- }
- else if (this.ID == TileMapCell.TID_CONCAVEnn)
- {
- this.signx = -1;
- this.signy = -1;
- this.sx = 0;
- this.sy = 0;
- }
- else if (this.ID == TileMapCell.TID_CONCAVEnp)
- {
- this.signx = -1;
- this.signy = 1;
- this.sx = 0;
- this.sy = 0;
- }
- else if (this.ID == TileMapCell.TID_CONCAVEpp)
- {
- this.signx = 1;
- this.signy = 1;
- this.sx = 0;
- this.sy = 0;
- }
- else
- {
- //trace("BAAAD TILE!!!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
- else if (this.ID < TileMapCell.CTYPE_22DEGs)
- {
-
- //convex
- this.CTYPE = TileMapCell.CTYPE_CONVEX;
- if (this.ID == TileMapCell.TID_CONVEXpn)
- {
- this.signx = 1;
- this.signy = -1;
- this.sx = 0;
- this.sy = 0;
- }
- else if (this.ID == TileMapCell.TID_CONVEXnn)
- {
- this.signx = -1;
- this.signy = -1;
- this.sx = 0;
- this.sy = 0;
- }
- else if (this.ID == TileMapCell.TID_CONVEXnp)
- {
- this.signx = -1;
- this.signy = 1;
- this.sx = 0;
- this.sy = 0;
- }
- else if (this.ID == TileMapCell.TID_CONVEXpp)
- {
- this.signx = 1;
- this.signy = 1;
- this.sx = 0;
- this.sy = 0;
- }
- else
- {
- //trace("BAAAD TILE!!!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
- else if (this.ID < TileMapCell.CTYPE_22DEGb)
- {
-
- //22deg small
- this.CTYPE = TileMapCell.CTYPE_22DEGs;
- if (this.ID == TileMapCell.TID_22DEGpnS)
- {
- this.signx = 1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else if (this.ID == TileMapCell.TID_22DEGnnS)
- {
- this.signx = -1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else if (this.ID == TileMapCell.TID_22DEGnpS)
- {
- this.signx = -1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else if (this.ID == TileMapCell.TID_22DEGppS)
- {
- this.signx = 1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else
- {
- //trace("BAAAD TILE!!!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
- else if (this.ID < TileMapCell.CTYPE_67DEGs)
- {
-
- //22deg big
- this.CTYPE = TileMapCell.CTYPE_22DEGb;
- if (this.ID == TileMapCell.TID_22DEGpnB)
- {
- this.signx = 1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else if (this.ID == TileMapCell.TID_22DEGnnB)
- {
- this.signx = -1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else if (this.ID == TileMapCell.TID_22DEGnpB)
- {
- this.signx = -1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else if (this.ID == TileMapCell.TID_22DEGppB)
- {
- this.signx = 1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 1) / slen;
- this.sy = (this.signy * 2) / slen;
- }
- else
- {
- //trace("BAAAD TILE!!!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
- else if (this.ID < TileMapCell.CTYPE_67DEGb)
- {
-
- //67deg small
- this.CTYPE = TileMapCell.CTYPE_67DEGs;
- if (this.ID == TileMapCell.TID_67DEGpnS)
- {
- this.signx = 1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else if (this.ID == TileMapCell.TID_67DEGnnS)
- {
- this.signx = -1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else if (this.ID == TileMapCell.TID_67DEGnpS)
- {
- this.signx = -1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else if (this.ID == TileMapCell.TID_67DEGppS)
- {
- this.signx = 1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else
- {
- //trace("BAAAD TILE!!!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
- else if (this.ID < TileMapCell.CTYPE_HALF)
- {
-
- //67deg big
- this.CTYPE = TileMapCell.CTYPE_67DEGb;
- if (this.ID == TileMapCell.TID_67DEGpnB)
- {
- this.signx = 1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else if (this.ID == TileMapCell.TID_67DEGnnB)
- {
- this.signx = -1;
- this.signy = -1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else if (this.ID == TileMapCell.TID_67DEGnpB)
- {
- this.signx = -1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else if (this.ID == TileMapCell.TID_67DEGppB)
- {
- this.signx = 1;
- this.signy = 1;
- var slen = Math.sqrt(2 * 2 + 1 * 1);
- this.sx = (this.signx * 2) / slen;
- this.sy = (this.signy * 1) / slen;
- }
- else
- {
- //trace("BAAAD TILE!!!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
- }
- else
- {
- //half-full tile
- this.CTYPE = TileMapCell.CTYPE_HALF;
- if (this.ID == TileMapCell.TID_HALFd)
- {
- this.signx = 0;
- this.signy = -1;
- this.sx = this.signx;
- this.sy = this.signy;
- }
- else if (this.ID == TileMapCell.TID_HALFu)
- {
- this.signx = 0;
- this.signy = 1;
- this.sx = this.signx;
- this.sy = this.signy;
- }
- else if (this.ID == TileMapCell.TID_HALFl)
- {
- this.signx = 1;
- this.signy = 0;
- this.sx = this.signx;
- this.sy = this.signy;
- }
- else if (this.ID == TileMapCell.TID_HALFr)
- {
- this.signx = -1;
- this.signy = 0;
- this.sx = this.signx;
- this.sy = this.signy;
- }
- else
- {
- //trace("BAAD TILE!!!: ID=" + this.ID + " ("+ t.i + "," + t.j + ")");
- return false;
- }
-
- }
-
- }
- else
- {
- //TID_EMPTY
- this.CTYPE = TileMapCell.CTYPE_EMPTY;
- this.signx = 0;
- this.signy = 0;
- this.sx = 0;
- this.sy = 0;
- }
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/aabb/ProjAABB22Deg.ts b/wip/TS Source/physics/aabb/ProjAABB22Deg.ts
deleted file mode 100644
index cbe1bf38..00000000
--- a/wip/TS Source/physics/aabb/ProjAABB22Deg.ts
+++ /dev/null
@@ -1,128 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class AABB22Deg {
-
- public static CollideS(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- var signx = t.signx;
- var signy = t.signy;
-
- //first we need to check to make sure we're colliding with the slope at all
- var py = obj.pos.y - (signy * obj.height);
- var penY = t.pos.y - py;//this is the vector from the innermost point on the box to the highest point on
- //the tile; if it is positive, this means the box is above the tile and
- //no collision is occuring
-
- if (0 < (penY * signy))
- {
-
- var ox = (obj.pos.x - (signx * obj.width)) - (t.pos.x + (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (signy * obj.height)) - (t.pos.y - (signy * t.yw));//point on the AABB, relative to a point on the slope
-
- var sx = t.sx;//get slope unit normal
- var sy = t.sy;
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP = Math.sqrt(x * x + y * y);
-
- var aY = Math.abs(penY);
- if (lenP < lenN)
- {
- if (aY < lenP)
- {
- obj.reportCollisionVsWorld(0, penY, 0, penY / aY, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- else
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
- }
- }
- else
- {
- if (aY < lenN)
- {
- obj.reportCollisionVsWorld(0, penY, 0, penY / aY, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- }
- }
- }
-
- //if we've reached this point, no collision has occured
- return Phaser.Physics.AABB.COL_NONE;
-
- }
-
- public static CollideB(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- var signx = t.signx;
- var signy = t.signy;
-
- var ox = (obj.pos.x - (signx * obj.width)) - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (signy * obj.height)) - (t.pos.y + (signy * t.yw));//point on the AABB, relative to a point on the slope
-
- var sx = t.sx;//get slope unit normal
- var sy = t.sy;
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP = Math.sqrt(x * x + y * y);
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
-
- }
-
- return Phaser.Physics.AABB.COL_NONE;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/aabb/ProjAABB45Deg.ts b/wip/TS Source/physics/aabb/ProjAABB45Deg.ts
deleted file mode 100644
index cf87f28c..00000000
--- a/wip/TS Source/physics/aabb/ProjAABB45Deg.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class AABB45Deg {
-
- public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- var signx = t.signx;
- var signy = t.signy;
-
- var ox = (obj.pos.x - (signx * obj.width)) - t.pos.x;//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (signy * obj.height)) - t.pos.y;//point on the AABB, relative to the tile center
-
- var sx = t.sx;
- var sy = t.sy;
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP = Math.sqrt(x * x + y * y);
-
- if (lenP < lenN)
- {
- //project along axis
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
- }
- else
- {
- //project along slope
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- }
-
- return Phaser.Physics.AABB.COL_NONE;
- }
- }
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/aabb/ProjAABB67Deg.ts b/wip/TS Source/physics/aabb/ProjAABB67Deg.ts
deleted file mode 100644
index 7542bd66..00000000
--- a/wip/TS Source/physics/aabb/ProjAABB67Deg.ts
+++ /dev/null
@@ -1,124 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class AABB67Deg {
-
- public static CollideS(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- var signx = t.signx;
- var signy = t.signy;
-
- var px = obj.pos.x - (signx * obj.width);
- var penX = t.pos.x - px;
-
- if (0 < (penX * signx))
- {
-
- var ox = (obj.pos.x - (signx * obj.width)) - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (signy * obj.height)) - (t.pos.y + (signy * t.yw));//point on the AABB, relative to a point on the slope
-
- var sx = t.sx;//get slope unit normal
- var sy = t.sy;
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
- //and we need to project it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP = Math.sqrt(x * x + y * y);
-
- var aX = Math.abs(penX);
- if (lenP < lenN)
- {
- if (aX < lenP)
- {
- obj.reportCollisionVsWorld(penX, 0, penX / aX, 0, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- else
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
- }
- }
- else
- {
- if (aX < lenN)
- {
- obj.reportCollisionVsWorld(penX, 0, penX / aX, 0, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- }
- }
- }
-
- //if we've reached this point, no collision has occured
- return Phaser.Physics.AABB.COL_NONE;
-
- }
-
- public static CollideB(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- var signx = t.signx;
- var signy = t.signy;
-
- var ox = (obj.pos.x - (signx * obj.width)) - (t.pos.x + (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (signy * obj.height)) - (t.pos.y - (signy * t.yw));//point on the AABB, relative to a point on the slope
-
- var sx = t.sx;//get slope unit normal
- var sy = t.sy;
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP = Math.sqrt(x * x + y * y);
-
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- }
-
- return Phaser.Physics.AABB.COL_NONE;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/aabb/ProjAABBConcave.ts b/wip/TS Source/physics/aabb/ProjAABBConcave.ts
deleted file mode 100644
index 683fbe5c..00000000
--- a/wip/TS Source/physics/aabb/ProjAABBConcave.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class AABBConcave {
-
- public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- //if distance from "innermost" corner of AABB is further than tile radius,
- //collision is occuring and we need to project
-
- var signx = t.signx;
- var signy = t.signy;
-
- var ox = (t.pos.x + (signx * t.xw)) - (obj.pos.x - (signx * obj.width));//(ox,oy) is the vector form the innermost AABB corner to the
- var oy = (t.pos.y + (signy * t.yw)) - (obj.pos.y - (signy * obj.height));//circle's center
-
- var twid = t.xw * 2;
- var rad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
- //note that this should be precomputed at compile-time since it's constant
-
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = len - rad;
-
- if (0 < pen)
- {
- //collision; we need to either project along the axes, or project along corner->circlecenter vector
-
- var lenP = Math.sqrt(x * x + y * y);
- if (lenP < pen)
- {
- //it's shorter to move along axis directions
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
- }
- else
- {
- //project along corner->circle vector
- ox /= len;//len should never be 0, since if it IS 0, rad should be > than len
- oy /= len;//and we should never reach here
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
-
- }
-
- return Phaser.Physics.AABB.COL_NONE;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/aabb/ProjAABBConvex.ts b/wip/TS Source/physics/aabb/ProjAABBConvex.ts
deleted file mode 100644
index 0beb62ba..00000000
--- a/wip/TS Source/physics/aabb/ProjAABBConvex.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class AABBConvex {
-
- public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- //if distance from "innermost" corner of AABB is less than than tile radius,
- //collision is occuring and we need to project
-
- var signx = t.signx;
- var signy = t.signy;
-
- var ox = (obj.pos.x - (signx * obj.width)) - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the circle center to
- var oy = (obj.pos.y - (signy * obj.height)) - (t.pos.y - (signy * t.yw));//the AABB
- var len = Math.sqrt(ox * ox + oy * oy);
-
- var twid = t.xw * 2;
- var rad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
- //note that this should be precomputed at compile-time since it's constant
-
- var pen = rad - len;
- if (((signx * ox) < 0) || ((signy * oy) < 0))
- {
- //the test corner is "outside" the 1/4 of the circle we're interested in
- var lenP = Math.sqrt(x * x + y * y);
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;//we need to report
- }
- else if (0 < pen)
- {
- //project along corner->circle vector
- ox /= len;
- oy /= len;
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
-
- return Phaser.Physics.AABB.COL_NONE;
- }
-
- }
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/aabb/ProjAABBFull.ts b/wip/TS Source/physics/aabb/ProjAABBFull.ts
deleted file mode 100644
index c8ed63c3..00000000
--- a/wip/TS Source/physics/aabb/ProjAABBFull.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class AABBFull {
-
- public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- var l = Math.sqrt(x * x + y * y);
-
- obj.reportCollisionVsWorld(x, y, x / l, y / l, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/aabb/ProjAABBHalf.ts b/wip/TS Source/physics/aabb/ProjAABBHalf.ts
deleted file mode 100644
index be4f8c08..00000000
--- a/wip/TS Source/physics/aabb/ProjAABBHalf.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class AABBHalf {
-
- public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
-
- //calculate the projection vector for the half-edge, and then
- //(if collision is occuring) pick the minimum
-
- var sx = t.signx;
- var sy = t.signy;
-
- var ox = (obj.pos.x - (sx * obj.width)) - t.pos.x;//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (sy * obj.height)) - t.pos.y;//point on the AABB, relative to the tile center
-
- //we perform operations analogous to the 45deg tile, except we're using
- //an axis-aligned slope instead of an angled one..
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP = Math.sqrt(x * x + y * y);
-
- if (lenP < lenN)
- {
- //project along axis; note that we're assuming that this tile is horizontal OR vertical
- //relative to the AABB's current tile, and not diagonal OR the current tile.
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.AABB.COL_AXIS;
- }
- else
- {
- //note that we could use -= instead of -dp
- obj.reportCollisionVsWorld(sx, sy, t.signx, t.signy, t);
-
- return Phaser.Physics.AABB.COL_OTHER;
- }
- }
-
- return Phaser.Physics.AABB.COL_NONE;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/circle/ProjCircle22Deg.ts b/wip/TS Source/physics/circle/ProjCircle22Deg.ts
deleted file mode 100644
index 6599cbb0..00000000
--- a/wip/TS Source/physics/circle/ProjCircle22Deg.ts
+++ /dev/null
@@ -1,597 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class Circle22Deg {
-
- public static CollideS(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if the object is in a cell pointed at by signy, no collision will ever occur
- //otherwise,
- //
- //if we're colliding diagonally:
- // -collide vs. the appropriate vertex
- //if obj is in this tile: collide vs slope or vertex
- //if obj is horiz neighb in direction of slope: collide vs. slope or vertex
- //if obj is horiz neighb against the slope:
- // if(distance in y from circle to 90deg corner of tile < 1/2 tileheight, collide vs. face)
- // else(collide vs. corner of slope) (vert collision with a non-grid-aligned vert)
- //if obj is vert neighb against direction of slope: collide vs. face
-
- var signx = t.signx;
- var signy = t.signy;
-
- if (0 < (signy * oV))
- {
- //object will never collide vs tile, it can't reach that far
- return Phaser.Physics.Circle.COL_NONE;
- }
- else if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current tile
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- var sx = t.sx;
- var sy = t.sy;
-
- var r = obj.radius;
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - t.pos.y;//point on the circle, relative to the tile corner
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the vertex, otherwise by the normal or axially.
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
-
- var perp = (ox * -sy) + (oy * sx);
-
- if (0 < (perp * signx * signy))
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = r - len;
-
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope or vs axis
- ox -= r * sx;//this gives us the vector from
- oy -= r * sy;//a point on the slope to the innermost point on the circle
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP;
-
- //find the smallest axial projection vector
- if (x < y)
- {
- //penetration in x is smaller
- lenP = x;
- y = 0;
- //get sign for projection along x-axis
- if ((obj.pos.x - t.pos.x) < 0)
- {
- x *= -1;
- }
- }
- else
- {
- //penetration in y is smaller
- lenP = y;
- x = 0;
- //get sign for projection along y-axis
- if ((obj.pos.y - t.pos.y) < 0)
- {
- y *= -1;
- }
- }
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
- }
-
- }
- else
- {
- //colliding vertically; we can assume that (signy*oV) < 0
- //due to the first conditional far above
-
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally
- if ((signx * oH) < 0)
- {
- //colliding with face/edge OR with corner of wedge, depending on our position vertically
-
- //collide vs. vertex
- //get diag vertex position
- var vx = t.pos.x - (signx * t.xw);
- var vy = t.pos.y;
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- if ((dy * signy) < 0)
- {
- //colliding vs face
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //colliding vs. vertex
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- else
- {
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- var sx = t.sx;
- var sy = t.sy;
-
- var ox = obj.pos.x - (t.pos.x + (oH * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//point on the circle, relative to the closest tile vert
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the normal, otherwise by the vertex.
- //(NOTE: this is the opposite logic of the vertical case;
- // for vertical, if the perp prod and the slope's slope agree, it's outside.
- // for horizontal, if the perp prod and the slope's slope agree, circle is inside.
- // ..but this is only a property of flahs' coord system (i.e the rules might swap
- // in righthanded systems))
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
-
- if ((perp * signx * signy) < 0)
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
-
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, sx, sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- else
- {
- //colliding diagonally; due to the first conditional above,
- //obj is vertically offset against slope, and offset in either direction horizontally
-
- //collide vs. vertex
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
-
- return Phaser.Physics.Circle.COL_NONE;
-
- }
-
- public static CollideB(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if we're colliding diagonally:
- // -if we're in the cell pointed at by the normal, collide vs slope, else
- // collide vs. the appropriate corner/vertex
- //
- //if obj is in this tile: collide as with aabb
- //
- //if obj is horiz or vertical neighbor AGAINST the slope: collide with edge
- //
- //if obj is horiz neighb in direction of slope: collide vs. slope or vertex or edge
- //
- //if obj is vert neighb in direction of slope: collide vs. slope or vertex
-
- var signx = t.signx;
- var signy = t.signy;
- var sx: number;
- var sy: number;
-
- if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current cell
-
- sx = t.sx;
- sy = t.sy;
-
- var r = obj.radius;
- var ox = (obj.pos.x - (sx * r)) - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (sy * r)) - (t.pos.y + (signy * t.yw));//point on the AABB, relative to a point on the slope
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP;
-
- //find the smallest axial projection vector
- if (x < y)
- {
- //penetration in x is smaller
- lenP = x;
- y = 0;
- //get sign for projection along x-axis
- if ((obj.pos.x - t.pos.x) < 0)
- {
- x *= -1;
- }
- }
- else
- {
- //penetration in y is smaller
- lenP = y;
- x = 0;
- //get sign for projection along y-axis
- if ((obj.pos.y - t.pos.y) < 0)
- {
- y *= -1;
- }
- }
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- else
- {
- //colliding vertically
-
- if ((signy * oV) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- sx = t.sx;
- sy = t.sy;
-
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y + (signy * t.yw));//point on the circle, relative to the closest tile vert
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the vertex, otherwise by the normal.
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
-
- if (0 < (perp * signx * signy))
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
-
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, sx, sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally
-
- if ((signx * oH) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //colliding with edge, slope, or vertex
-
- var ox = obj.pos.x - (t.pos.x + (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - t.pos.y;//point on the circle, relative to the closest tile vert
-
- if ((oy * signy) < 0)
- {
- //we're colliding with the halfface
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //colliding with the vertex or slope
-
- sx = t.sx;
- sy = t.sy;
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the slope, otherwise by the vertex.
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
-
- if ((perp * signx * signy) < 0)
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
-
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- }
- else
- {
- //colliding diagonally
- if (0 < ((signx * oH) + (signy * oV)))
- {
- //the dotprod of slope normal and cell offset is strictly positive,
- //therefore obj is in the diagonal neighb pointed at by the normal.
-
- //collide vs slope
-
- //we should really precalc this at compile time, but for now, fuck it
- var slen: number = Math.sqrt(2 * 2 + 1 * 1);//the raw slope is (-2,-1)
- sx = (signx * 1) / slen;//get slope _unit_ normal;
- sy = (signy * 2) / slen;//raw RH normal is (1,-2)
-
- var r = obj.radius;
- var ox = (obj.pos.x - (sx * r)) - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (sy * r)) - (t.pos.y + (signy * t.yw));//point on the circle, relative to a point on the slope
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- //(sx,sy)*-dp is the projection vector
- obj.reportCollisionVsWorld(-sx * dp, -sy * dp, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- return Phaser.Physics.Circle.COL_NONE;
- }
- else
- {
- //collide vs the appropriate vertex
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
- }
-
- return Phaser.Physics.Circle.COL_NONE;
- }
-
- }
-
-}
diff --git a/wip/TS Source/physics/circle/ProjCircle45Deg.ts b/wip/TS Source/physics/circle/ProjCircle45Deg.ts
deleted file mode 100644
index ec7123e4..00000000
--- a/wip/TS Source/physics/circle/ProjCircle45Deg.ts
+++ /dev/null
@@ -1,271 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class Circle45Deg {
-
- public static Collide(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if we're colliding diagonally:
- // -if obj is in the diagonal pointed to by the slope normal: we can't collide, do nothing
- // -else, collide vs. the appropriate vertex
- //if obj is in this tile: perform collision as for aabb-ve-45deg
- //if obj is horiz OR very neighb in direction of slope: collide only vs. slope
- //if obj is horiz or vert neigh against direction of slope: collide vs. face
-
- var signx = t.signx;
- var signy = t.signy;
- var lenP;
-
- if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current tile
-
- var sx = t.sx;
- var sy = t.sy;
-
- var ox = (obj.pos.x - (sx * obj.radius)) - t.pos.x;//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (sy * obj.radius)) - t.pos.y;//point on the circle, relative to the tile center
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the innermost point is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
- if (dp < 0)
- {
- //collision; project delta onto slope and use this as the slope penetration vector
- sx *= -dp;//(sx,sy) is now the penetration vector
- sy *= -dp;
-
- //find the smallest axial projection vector
- if (x < y)
- {
- //penetration in x is smaller
- lenP = x;
- y = 0;
-
- //get sign for projection along x-axis
- if ((obj.pos.x - t.pos.x) < 0)
- {
- x *= -1;
- }
- }
- else
- {
- //penetration in y is smaller
- lenP = y;
- x = 0;
-
- //get sign for projection along y-axis
- if ((obj.pos.y - t.pos.y) < 0)
- {
- y *= -1;
- }
- }
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
-
- }
- else
- {
- //colliding vertically
- if ((signy * oV) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- var sx = t.sx;
- var sy = t.sy;
-
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y + (oV * t.yw));//point on the circle, relative to the closest tile vert
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the vertex, otherwise by the normal.
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronoi region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
- if (0 < (perp * signx * signy))
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, sx, sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally
- if ((signx * oH) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- var sx = t.sx;
- var sy = t.sy;
-
- var ox = obj.pos.x - (t.pos.x + (oH * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//point on the circle, relative to the closest tile vert
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the normal, otherwise by the vertex.
- //(NOTE: this is the opposite logic of the vertical case;
- // for vertical, if the perp prod and the slope's slope agree, it's outside.
- // for horizontal, if the perp prod and the slope's slope agree, circle is inside.
- // ..but this is only a property of flahs' coord system (i.e the rules might swap
- // in righthanded systems))
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
- if ((perp * signx * signy) < 0)
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, sx, sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- else
- {
- //colliding diagonally
- if (0 < ((signx * oH) + (signy * oV)))
- {
- //the dotprod of slope normal and cell offset is strictly positive,
- //therefore obj is in the diagonal neighb pointed at by the normal, and
- //it cannot possibly reach/touch/penetrate the slope
- return Phaser.Physics.Circle.COL_NONE;
- }
- else
- {
- //collide vs. vertex
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
-
- }
-
- return Phaser.Physics.Circle.COL_NONE;
- }
-
-
- }
-
-}
diff --git a/wip/TS Source/physics/circle/ProjCircle67Deg.ts b/wip/TS Source/physics/circle/ProjCircle67Deg.ts
deleted file mode 100644
index 5ca92702..00000000
--- a/wip/TS Source/physics/circle/ProjCircle67Deg.ts
+++ /dev/null
@@ -1,591 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class Circle67Deg {
-
- public static CollideS(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if the object is in a cell pointed at by signx, no collision will ever occur
- //otherwise,
- //
- //if we're colliding diagonally:
- // -collide vs. the appropriate vertex
- //if obj is in this tile: collide vs slope or vertex or axis
- //if obj is vert neighb in direction of slope: collide vs. slope or vertex
- //if obj is vert neighb against the slope:
- // if(distance in y from circle to 90deg corner of tile < 1/2 tileheight, collide vs. face)
- // else(collide vs. corner of slope) (vert collision with a non-grid-aligned vert)
- //if obj is horiz neighb against direction of slope: collide vs. face
-
- var signx = t.signx;
- var signy = t.signy;
- var sx: number;
- var sy: number;
-
- if (0 < (signx * oH))
- {
- //object will never collide vs tile, it can't reach that far
- return Phaser.Physics.Circle.COL_NONE;
- }
- else if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current tile
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- sx = t.sx;
- sy = t.sy;
-
- var r = obj.radius;
- var ox = obj.pos.x - t.pos.x;//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//point on the circle, relative to the tile corner
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the normal or axis, otherwise by the corner/vertex
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronoi region, or that of the vertex.
-
- var perp = (ox * -sy) + (oy * sx);
-
- if ((perp * signx * signy) < 0)
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = r - len;
-
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope or vs axis
- ox -= r * sx;//this gives us the vector from
- oy -= r * sy;//a point on the slope to the innermost point on the circle
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
- var lenP;
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
-
- //find the smallest axial projection vector
- if (x < y)
- {
- //penetration in x is smaller
- lenP = x;
- y = 0;
- //get sign for projection along x-axis
- if ((obj.pos.x - t.pos.x) < 0)
- {
- x *= -1;
- }
- }
- else
- {
- //penetration in y is smaller
- lenP = y;
- x = 0;
- //get sign for projection along y-axis
- if ((obj.pos.y - t.pos.y) < 0)
- {
- y *= -1;
- }
- }
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
- return Phaser.Physics.Circle.COL_AXIS
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
-
- }
- else
- {
- //colliding vertically
-
- if ((signy * oV) < 0)
- {
- //colliding with face/edge OR with corner of wedge, depending on our position vertically
-
- //collide vs. vertex
- //get diag vertex position
- var vx = t.pos.x;
- var vy = t.pos.y - (signy * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- if ((dx * signx) < 0)
- {
- //colliding vs face
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //colliding vs. vertex
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- else
- {
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- sx = t.sx;
- sy = t.sy;
-
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y + (oV * t.yw));//point on the circle, relative to the closest tile vert
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the vertex, otherwise by the normal.
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
-
- if (0 < (perp * signx * signy))
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
-
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally; we can assume that (signy*oV) < 0
- //due to the first conditional far above
-
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //colliding diagonally; due to the first conditional above,
- //obj is vertically offset against slope, and offset in either direction horizontally
-
- //collide vs. vertex
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
-
- return Phaser.Physics.Circle.COL_NONE;
-
- }
-
- public static CollideB(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if we're colliding diagonally:
- // -if we're in the cell pointed at by the normal, collide vs slope, else
- // collide vs. the appropriate corner/vertex
- //
- //if obj is in this tile: collide as with aabb
- //
- //if obj is horiz or vertical neighbor AGAINST the slope: collide with edge
- //
- //if obj is vert neighb in direction of slope: collide vs. slope or vertex or halfedge
- //
- //if obj is horiz neighb in direction of slope: collide vs. slope or vertex
-
- var signx = t.signx;
- var signy = t.signy;
- var sx: number;
- var sy: number;
-
- if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current cell
-
- sx = t.sx;
- sy = t.sy;
-
- var r = obj.radius;
- var ox = (obj.pos.x - (sx * r)) - (t.pos.x + (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (sy * r)) - (t.pos.y - (signy * t.yw));//point on the AABB, relative to a point on the slope
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
- var lenP;
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
-
- //find the smallest axial projection vector
- if (x < y)
- {
- //penetration in x is smaller
- lenP = x;
- y = 0;
- //get sign for projection along x-axis
- if ((obj.pos.x - t.pos.x) < 0)
- {
- x *= -1;
- }
- }
- else
- {
- //penetration in y is smaller
- lenP = y;
- x = 0;
- //get sign for projection along y-axis
- if ((obj.pos.y - t.pos.y) < 0)
- {
- y *= -1;
- }
- }
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
- }
- else
- {
- //colliding vertically
-
- if ((signy * oV) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //colliding with edge, slope, or vertex
-
- var ox = obj.pos.x - t.pos.x;//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y + (signy * t.yw));//point on the circle, relative to the closest tile vert
-
- if ((ox * signx) < 0)
- {
- //we're colliding with the halfface
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //colliding with the vertex or slope
-
- sx = t.sx;
- sy = t.sy;
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the vertex, otherwise by the slope.
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
-
- if (0 < (perp * signx * signy))
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
-
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, sx, sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally
-
- if ((signx * oH) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //we could only be colliding vs the slope OR a vertex
- //look at the vector form the closest vert to the circle to decide
-
- var slen = Math.sqrt(2 * 2 + 1 * 1);//the raw slope is (-2,-1)
- var sx = (signx * 2) / slen;//get slope _unit_ normal;
- var sy = (signy * 1) / slen;//raw RH normal is (1,-2)
-
- var ox = obj.pos.x - (t.pos.x + (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//point on the circle, relative to the closest tile vert
-
- //if the component of (ox,oy) parallel to the normal's righthand normal
- //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy)
- //then we project by the slope, otherwise by the vertex.
- //note that this is simply a VERY tricky/weird method of determining
- //if the circle is in side the slope/face's voronio region, or that of the vertex.
- var perp = (ox * -sy) + (oy * sx);
-
- if ((perp * signx * signy) < 0)
- {
- //collide vs. vertex
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. slope
-
- //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're
- //penetrating the slope. note that this method of penetration calculation doesn't hold
- //in general (i.e it won't work if the circle is in the slope), but works in this case
- //because we know the circle is in a neighboring cell
- var dp = (ox * sx) + (oy * sy);
- var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case..
- if (0 < pen)
- {
- //collision; circle out along normal by penetration amount
- obj.reportCollisionVsWorld(sx * pen, sy * pen, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- else
- {
- //colliding diagonally
- if (0 < ((signx * oH) + (signy * oV)))
- {
- //the dotprod of slope normal and cell offset is strictly positive,
- //therefore obj is in the diagonal neighb pointed at by the normal.
-
- //collide vs slope
-
- sx = t.sx;
- sy = t.sy;
-
- var r = obj.radius;
- var ox = (obj.pos.x - (sx * r)) - (t.pos.x + (signx * t.xw));//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (sy * r)) - (t.pos.y - (signy * t.yw));//point on the circle, relative to a point on the slope
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- //(sx,sy)*-dp is the projection vector
-
- obj.reportCollisionVsWorld(-sx * dp, -sy * dp, t.sx, t.sy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- return Phaser.Physics.Circle.COL_NONE;
- }
- else
- {
-
- //collide vs the appropriate vertex
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
- }
-
- return Phaser.Physics.Circle.COL_NONE;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/circle/ProjCircleConcave.ts b/wip/TS Source/physics/circle/ProjCircleConcave.ts
deleted file mode 100644
index a06c4c98..00000000
--- a/wip/TS Source/physics/circle/ProjCircleConcave.ts
+++ /dev/null
@@ -1,235 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class CircleConcave {
-
- public static Collide(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if we're colliding diagonally:
- // -if obj is in the diagonal pointed to by the slope normal: we can't collide, do nothing
- // -else, collide vs. the appropriate vertex
- //if obj is in this tile: perform collision as for aabb
- //if obj is horiz OR very neighb in direction of slope: collide vs vert
- //if obj is horiz or vert neigh against direction of slope: collide vs. face
-
- var signx = t.signx;
- var signy = t.signy;
- var lenP;
-
- if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current tile
-
- var ox = (t.pos.x + (signx * t.xw)) - obj.pos.x;//(ox,oy) is the vector from the circle to
- var oy = (t.pos.y + (signy * t.yw)) - obj.pos.y;//tile-circle's center
-
- var twid = t.xw * 2;
- var trad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
- //note that this should be precomputed at compile-time since it's constant
-
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = (len + obj.radius) - trad;
-
- if (0 < pen)
- {
- //find the smallest axial projection vector
- if (x < y)
- {
- //penetration in x is smaller
- lenP = x;
- y = 0;
-
- //get sign for projection along x-axis
- if ((obj.pos.x - t.pos.x) < 0)
- {
- x *= -1;
- }
- }
- else
- {
- //penetration in y is smaller
- lenP = y;
- x = 0;
-
- //get sign for projection along y-axis
- if ((obj.pos.y - t.pos.y) < 0)
- {
- y *= -1;
- }
- }
-
-
- if (lenP < pen)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //we can assume that len >0, because if we're here then
- //(len + obj.radius) > trad, and since obj.radius <= trad
- //len MUST be > 0
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- return Phaser.Physics.Circle.COL_NONE;
- }
-
- }
- else
- {
- //colliding vertically
- if ((signy * oV) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //we could only be colliding vs the vertical tip
-
- //get diag vertex position
- var vx = t.pos.x - (signx * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out vertically
- dx = 0;
- dy = oV;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally
- if ((signx * oH) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //we could only be colliding vs the horizontal tip
-
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y - (signy * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out horizontally
- dx = oH;
- dy = 0;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- else
- {
- //colliding diagonally
- if (0 < ((signx * oH) + (signy * oV)))
- {
- //the dotprod of slope normal and cell offset is strictly positive,
- //therefore obj is in the diagonal neighb pointed at by the normal, and
- //it cannot possibly reach/touch/penetrate the slope
- return Phaser.Physics.Circle.COL_NONE;
- }
- else
- {
- //collide vs. vertex
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
-
- }
-
- return Phaser.Physics.Circle.COL_NONE;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/circle/ProjCircleConvex.ts b/wip/TS Source/physics/circle/ProjCircleConvex.ts
deleted file mode 100644
index 2fcf2cf0..00000000
--- a/wip/TS Source/physics/circle/ProjCircleConvex.ts
+++ /dev/null
@@ -1,242 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class CircleConvex {
-
- public static Collide(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if the object is horiz AND/OR vertical neighbor in the normal (signx,signy)
- //direction, collide vs. tile-circle only.
- //if we're colliding diagonally:
- // -else, collide vs. the appropriate vertex
- //if obj is in this tile: perform collision as for aabb
- //if obj is horiz or vert neigh against direction of slope: collide vs. face
-
- var signx = t.signx;
- var signy = t.signy;
- var lenP;
-
- if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current tile
-
-
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center
-
- var twid = t.xw * 2;
- var trad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
- //note that this should be precomputed at compile-time since it's constant
-
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = (trad + obj.radius) - len;
-
- if (0 < pen)
- {
- //find the smallest axial projection vector
- if (x < y)
- {
- //penetration in x is smaller
- lenP = x;
- y = 0;
-
- //get sign for projection along x-axis
- if ((obj.pos.x - t.pos.x) < 0)
- {
- x *= -1;
- }
- }
- else
- {
- //penetration in y is smaller
- lenP = y;
- x = 0;
-
- //get sign for projection along y-axis
- if ((obj.pos.y - t.pos.y) < 0)
- {
- y *= -1;
- }
- }
-
-
- if (lenP < pen)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //note: len should NEVER be == 0, because if it is,
- //projeciton by an axis shoudl always be shorter, and we should
- //never arrive here
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
-
- }
- }
- }
- else
- {
- //colliding vertically
- if ((signy * oV) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //obj in neighboring cell pointed at by tile normal;
- //we could only be colliding vs the tile-circle surface
-
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center
-
- var twid = t.xw * 2;
- var trad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
- //note that this should be precomputed at compile-time since it's constant
-
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = (trad + obj.radius) - len;
-
- if (0 < pen)
- {
-
- //note: len should NEVER be == 0, because if it is,
- //obj is not in a neighboring cell!
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally
- if ((signx * oH) < 0)
- {
- //colliding with face/edge
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //obj in neighboring cell pointed at by tile normal;
- //we could only be colliding vs the tile-circle surface
-
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center
-
- var twid = t.xw * 2;
- var trad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
- //note that this should be precomputed at compile-time since it's constant
-
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = (trad + obj.radius) - len;
-
- if (0 < pen)
- {
-
- //note: len should NEVER be == 0, because if it is,
- //obj is not in a neighboring cell!
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- else
- {
- //colliding diagonally
- if (0 < ((signx * oH) + (signy * oV)))
- {
- //obj in diag neighb cell pointed at by tile normal;
- //we could only be colliding vs the tile-circle surface
-
- var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to
- var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center
-
- var twid = t.xw * 2;
- var trad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
- //note that this should be precomputed at compile-time since it's constant
-
- var len = Math.sqrt(ox * ox + oy * oy);
- var pen = (trad + obj.radius) - len;
-
- if (0 < pen)
- {
-
- //note: len should NEVER be == 0, because if it is,
- //obj is not in a neighboring cell!
- ox /= len;
- oy /= len;
-
- obj.reportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- else
- {
- //collide vs. vertex
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
-
- }
-
- return Phaser.Physics.Circle.COL_NONE;
-
- }
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/circle/ProjCircleFull.ts b/wip/TS Source/physics/circle/ProjCircleFull.ts
deleted file mode 100644
index 81db0856..00000000
--- a/wip/TS Source/physics/circle/ProjCircleFull.ts
+++ /dev/null
@@ -1,112 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class CircleFull {
-
- public static Collide(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if we're colliding vs. the current cell, we need to project along the
- //smallest penetration vector.
- //if we're colliding vs. horiz. or vert. neighb, we simply project horiz/vert
- //if we're colliding diagonally, we need to collide vs. tile corner
-
- if (oH == 0)
- {
- if (oV == 0)
- {
- //collision with current cell
- if (x < y)
- {
- //penetration in x is smaller; project in x
- var dx = obj.pos.x - t.pos.x;//get sign for projection along x-axis
-
- //NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
- if (dx < 0)
- {
- obj.reportCollisionVsWorld(-x, 0, -1, 0, t);
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(x, 0, 1, 0, t);
- return Phaser.Physics.Circle.COL_AXIS;
- }
- }
- else
- {
- //penetration in y is smaller; project in y
- var dy = obj.pos.y - t.pos.y;//get sign for projection along y-axis
-
- //NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
- if (dy < 0)
- {
- obj.reportCollisionVsWorld(0, -y, 0, -1, t);
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(0, y, 0, 1, t);
- return Phaser.Physics.Circle.COL_AXIS;
- }
- }
- }
- else
- {
- //collision with vertical neighbor
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- }
- else if (oV == 0)
- {
- //collision with horizontal neighbor
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //diagonal collision
-
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
-
- return Phaser.Physics.Circle.COL_NONE;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/physics/circle/ProjCircleHalf.ts b/wip/TS Source/physics/circle/ProjCircleHalf.ts
deleted file mode 100644
index b18cf53f..00000000
--- a/wip/TS Source/physics/circle/ProjCircleHalf.ts
+++ /dev/null
@@ -1,234 +0,0 @@
-///
-
-/**
-* Phaser - Physics - Projection
-*/
-
-module Phaser.Physics.Projection {
-
- export class CircleHalf {
-
- public static Collide(x, y, oH, oV, obj: Phaser.Physics.Circle, t: Phaser.Physics.TileMapCell) {
-
- //if obj is in a neighbor pointed at by the halfedge normal,
- //we'll never collide (i.e if the normal is (0,1) and the obj is in the DL.D, or R neighbors)
- //
- //if obj is in a neigbor perpendicular to the halfedge normal, it might
- //collide with the halfedge-vertex, or with the halfedge side.
- //
- //if obj is in a neigb pointing opposite the halfedge normal, obj collides with edge
- //
- //if obj is in a diagonal (pointing away from the normal), obj collides vs vertex
- //
- //if obj is in the halfedge cell, it collides as with aabb
-
- var signx = t.signx;
- var signy = t.signy;
-
- var celldp = (oH * signx + oV * signy);//this tells us about the configuration of cell-offset relative to tile normal
- if (0 < celldp)
- {
- //obj is in "far" (pointed-at-by-normal) neighbor of halffull tile, and will never hit
- return Phaser.Physics.Circle.COL_NONE;
- }
- else if (oH == 0)
- {
- if (oV == 0)
- {
- //colliding with current tile
- var r = obj.radius;
- var ox = (obj.pos.x - (signx * r)) - t.pos.x;//this gives is the coordinates of the innermost
- var oy = (obj.pos.y - (signy * r)) - t.pos.y;//point on the circle, relative to the tile center
-
-
- //we perform operations analogous to the 45deg tile, except we're using
- //an axis-aligned slope instead of an angled one..
- var sx = signx;
- var sy = signy;
-
- //if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
- //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
- var dp = (ox * sx) + (oy * sy);
-
- if (dp < 0)
- {
- //collision; project delta onto slope and use this to displace the object
- sx *= -dp;//(sx,sy) is now the projection vector
- sy *= -dp;
-
- var lenN = Math.sqrt(sx * sx + sy * sy);
- var lenP = Math.sqrt(x * x + y * y);
-
- if (lenP < lenN)
- {
- obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- obj.reportCollisionVsWorld(sx, sy, t.signx, t.signy);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
- }
- }
- else
- {
- //colliding vertically
-
- if (celldp == 0)
- {
- var r = obj.radius;
- var dx = obj.pos.x - t.pos.x;
-
- //we're in a cell perpendicular to the normal, and can collide vs. halfedge vertex
- //or halfedge side
- if ((dx * signx) < 0)
- {
- //collision with halfedge side
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //collision with halfedge vertex
- var dy = obj.pos.y - (t.pos.y + oV * t.yw);//(dx,dy) is now the vector from the appropriate halfedge vertex to the circle
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
-
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = signx / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
- }
- else
- {
- //due to the first conditional (celldp >0), we know we're in the cell "opposite" the normal, and so
- //we can only collide with the cell edge
- //collision with vertical neighbor
- obj.reportCollisionVsWorld(0, y * oV, 0, oV, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
-
- }
- }
- else if (oV == 0)
- {
- //colliding horizontally
- if (celldp == 0)
- {
- var r = obj.radius;
- var dy = obj.pos.y - t.pos.y;
-
- //we're in a cell perpendicular to the normal, and can collide vs. halfedge vertex
- //or halfedge side
- if ((dy * signy) < 0)
- {
- //collision with halfedge side
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- else
- {
- //collision with halfedge vertex
- var dx = obj.pos.x - (t.pos.x + oH * t.xw);//(dx,dy) is now the vector from the appropriate halfedge vertex to the circle
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = signx / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
- }
- else
- {
- //due to the first conditional (celldp >0), we know w're in the cell "opposite" the normal, and so
- //we can only collide with the cell edge
- obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t);
-
- return Phaser.Physics.Circle.COL_AXIS;
- }
- }
- else
- {
- //colliding diagonally; we know, due to the initial (celldp >0) test which has failed
- //if we've reached this point, that we're in a diagonal neighbor on the non-normal side, so
- //we could only be colliding with the cell vertex, if at all.
-
- //get diag vertex position
- var vx = t.pos.x + (oH * t.xw);
- var vy = t.pos.y + (oV * t.yw);
-
- var dx = obj.pos.x - vx;//calc vert->circle vector
- var dy = obj.pos.y - vy;
-
- var len = Math.sqrt(dx * dx + dy * dy);
- var pen = obj.radius - len;
- if (0 < pen)
- {
- //vertex is in the circle; project outward
- if (len == 0)
- {
- //project out by 45deg
- dx = oH / Math.SQRT2;
- dy = oV / Math.SQRT2;
- }
- else
- {
- dx /= len;
- dy /= len;
- }
-
- obj.reportCollisionVsWorld(dx * pen, dy * pen, dx, dy, t);
-
- return Phaser.Physics.Circle.COL_OTHER;
- }
-
- }
-
- return Phaser.Physics.Circle.COL_NONE;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/HeadlessRenderer.ts b/wip/TS Source/renderers/HeadlessRenderer.ts
deleted file mode 100644
index 1c170e42..00000000
--- a/wip/TS Source/renderers/HeadlessRenderer.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-///
-
-module Phaser.Renderer.Headless {
-
- export class HeadlessRenderer implements Phaser.IRenderer {
-
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- public game: Phaser.Game;
- public renderCount: number;
-
- public render() {
- // Nothing, headless remember?
- }
-
- public renderGameObject(camera, object) {
- // Nothing, headless remember?
- }
-
- public cameraRenderer;
- public groupRenderer;
- public spriteRenderer;
- public geometryRenderer;
- public scrollZoneRenderer;
- public tilemapRenderer;
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/IRenderer.ts b/wip/TS Source/renderers/IRenderer.ts
deleted file mode 100644
index 4b32e594..00000000
--- a/wip/TS Source/renderers/IRenderer.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-///
-
-module Phaser {
-
- export interface IRenderer {
-
- render();
-
- renderCount: number;
-
- renderGameObject;
-
- cameraRenderer;
- groupRenderer;
- spriteRenderer;
- geometryRenderer;
- scrollZoneRenderer;
- tilemapRenderer;
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/canvas/CameraRenderer.ts b/wip/TS Source/renderers/canvas/CameraRenderer.ts
deleted file mode 100644
index 9dc08413..00000000
--- a/wip/TS Source/renderers/canvas/CameraRenderer.ts
+++ /dev/null
@@ -1,187 +0,0 @@
-///
-
-module Phaser.Renderer.Canvas {
-
- export class CameraRenderer {
-
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- /**
- * The essential reference to the main game object
- */
- public game: Phaser.Game;
-
- private _ga: number = 1;
- private _sx: number = 0;
- private _sy: number = 0;
- private _sw: number = 0;
- private _sh: number = 0;
- private _dx: number = 0;
- private _dy: number = 0;
- private _dw: number = 0;
- private _dh: number = 0;
- private _fx: number = 1;
- private _fy: number = 1;
- private _tx: number = 0;
- private _ty: number = 0;
- private _gac: number = 1;
- private _sin: number = 0;
- private _cos: number = 1;
-
- public preRender(camera: Phaser.Camera): bool {
-
- if (camera.visible == false || camera.transform.scale.x == 0 || camera.transform.scale.y == 0 || camera.texture.alpha < 0.1)
- {
- return false;
- }
-
- if (this.game.device.patchAndroidClearRectBug)
- {
- camera.texture.context.fillStyle = 'rgb(0,0,0)';
- camera.texture.context.fillRect(0, 0, camera.width, camera.height);
- }
- else
- {
- camera.texture.context.clearRect(0, 0, camera.width, camera.height);
- }
-
- // Alpha
- if (camera.texture.alpha !== 1 && camera.texture.context.globalAlpha != camera.texture.alpha)
- {
- this._ga = camera.texture.context.globalAlpha;
- camera.texture.context.globalAlpha = camera.texture.alpha;
- }
-
- if (camera.texture.opaque)
- {
- camera.texture.context.fillStyle = camera.texture.backgroundColor;
- camera.texture.context.fillRect(0, 0, camera.width, camera.height);
- }
-
- //if (camera.texture.loaded)
- //{
- // camera.texture.context.drawImage(
- // camera.texture.texture, // Source Image
- // this._sx, // Source X (location within the source image)
- // this._sy, // Source Y
- // this._sw, // Source Width
- // this._sh, // Source Height
- // 0, // Destination X (where on the canvas it'll be drawn)
- // 0, // Destination Y
- // this._dw, // Destination Width (always same as Source Width unless scaled)
- // this._dh // Destination Height (always same as Source Height unless scaled)
- // );
- //}
-
- // Global Composite Ops
- if (camera.texture.globalCompositeOperation)
- {
- camera.texture.context.globalCompositeOperation = camera.texture.globalCompositeOperation;
- }
-
- camera.plugins.preRender();
-
- }
-
- public postRender(camera: Phaser.Camera) {
-
- // This could have been over-written by a sprite, need to store elsewhere
- if (this._ga > -1)
- {
- camera.texture.context.globalAlpha = this._ga;
- }
-
- camera.plugins.postRender();
-
- // Reset our temp vars
- this._ga = -1;
- this._sx = 0;
- this._sy = 0;
- this._sw = camera.width;
- this._sh = camera.height;
- this._fx = camera.transform.scale.x;
- this._fy = camera.transform.scale.y;
- this._sin = 0;
- this._cos = 1;
- this._dx = camera.screenView.x;
- this._dy = camera.screenView.y;
- this._dw = camera.width;
- this._dh = camera.height;
-
- this.game.stage.context.save();
-
- // Flip X
- if (camera.texture.flippedX)
- {
- this._fx = -camera.transform.scale.x;
- }
-
- // Flip Y
- if (camera.texture.flippedY)
- {
- this._fy = -camera.transform.scale.y;
- }
-
- // Rotation and Flipped
- if (camera.modified)
- {
- if (camera.transform.rotation !== 0 || camera.transform.rotationOffset !== 0)
- {
- this._sin = Math.sin(camera.game.math.degreesToRadians(camera.transform.rotationOffset + camera.transform.rotation));
- this._cos = Math.cos(camera.game.math.degreesToRadians(camera.transform.rotationOffset + camera.transform.rotation));
- }
-
- this.game.stage.context.setTransform(
- this._cos * this._fx, // scale x
- (this._sin * this._fx) + camera.transform.skew.x, // skew x
- -(this._sin * this._fy) + camera.transform.skew.y, // skew y
- this._cos * this._fy, // scale y
- this._dx, // translate x
- this._dy // translate y
- );
-
- this._dx = camera.transform.origin.x * -this._dw;
- this._dy = camera.transform.origin.y * -this._dh;
- }
- else
- {
- this._dx -= (this._dw * camera.transform.origin.x);
- this._dy -= (this._dh * camera.transform.origin.y);
- }
-
- this._sx = Math.floor(this._sx);
- this._sy = Math.floor(this._sy);
- this._sw = Math.floor(this._sw);
- this._sh = Math.floor(this._sh);
- this._dx = Math.floor(this._dx);
- this._dy = Math.floor(this._dy);
- this._dw = Math.floor(this._dw);
- this._dh = Math.floor(this._dh);
-
- if (this._sw <= 0 || this._sh <= 0 || this._dw <= 0 || this._dh <= 0)
- {
- this.game.stage.context.restore();
- return false;
- }
-
- this.game.stage.context.drawImage(
- camera.texture.canvas, // Source Image
- this._sx, // Source X (location within the source image)
- this._sy, // Source Y
- this._sw, // Source Width
- this._sh, // Source Height
- this._dx, // Destination X (where on the canvas it'll be drawn)
- this._dy, // Destination Y
- this._dw, // Destination Width (always same as Source Width unless scaled)
- this._dh // Destination Height (always same as Source Height unless scaled)
- );
-
- this.game.stage.context.restore();
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/canvas/CanvasRenderer.ts b/wip/TS Source/renderers/canvas/CanvasRenderer.ts
deleted file mode 100644
index 5e93d9b2..00000000
--- a/wip/TS Source/renderers/canvas/CanvasRenderer.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-///
-
-module Phaser.Renderer.Canvas {
-
- export class CanvasRenderer implements Phaser.IRenderer {
-
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- this.cameraRenderer = new Phaser.Renderer.Canvas.CameraRenderer(game);
- this.groupRenderer = new Phaser.Renderer.Canvas.GroupRenderer(game);
- this.spriteRenderer = new Phaser.Renderer.Canvas.SpriteRenderer(game);
- this.geometryRenderer = new Phaser.Renderer.Canvas.GeometryRenderer(game);
- this.scrollZoneRenderer = new Phaser.Renderer.Canvas.ScrollZoneRenderer(game);
- this.tilemapRenderer = new Phaser.Renderer.Canvas.TilemapRenderer(game);
-
- }
-
- public game: Phaser.Game;
-
- private _c: number = 0;
- private _cameraList: Phaser.Camera[];
- private _camera: Phaser.Camera;
-
- public cameraRenderer: Phaser.Renderer.Canvas.CameraRenderer;
- public groupRenderer: Phaser.Renderer.Canvas.GroupRenderer;
- public spriteRenderer: Phaser.Renderer.Canvas.SpriteRenderer;
- public geometryRenderer: Phaser.Renderer.Canvas.GeometryRenderer;
- public scrollZoneRenderer: Phaser.Renderer.Canvas.ScrollZoneRenderer;
- public tilemapRenderer: Phaser.Renderer.Canvas.TilemapRenderer;
-
- public renderCount: number;
- public renderTotal: number;
-
- public render() {
-
- this._cameraList = this.game.world.getAllCameras();
- this.renderCount = 0;
-
- // Then iterate through world.group on them all (where not blacklisted, etc)
- for (this._c = 0; this._c < this._cameraList.length; this._c++)
- {
- if (this._cameraList[this._c].visible)
- {
- this.cameraRenderer.preRender(this._cameraList[this._c]);
-
- this.game.world.group.render(this._cameraList[this._c]);
-
- this.cameraRenderer.postRender(this._cameraList[this._c]);
- }
- }
-
- this.renderTotal = this.renderCount;
-
- }
-
- public renderGameObject(camera:Phaser.Camera, object) {
-
- if (object.type == Types.SPRITE || object.type == Types.BUTTON)
- {
- this.spriteRenderer.render(camera, object);
- }
- else if (object.type == Types.SCROLLZONE)
- {
- this.scrollZoneRenderer.render(camera, object);
- }
- else if (object.type == Types.TILEMAP)
- {
- this.tilemapRenderer.render(camera, object);
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/canvas/GeometryRenderer.ts b/wip/TS Source/renderers/canvas/GeometryRenderer.ts
deleted file mode 100644
index 66367852..00000000
--- a/wip/TS Source/renderers/canvas/GeometryRenderer.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-///
-
-module Phaser.Renderer.Canvas {
-
- export class GeometryRenderer {
-
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- /**
- * The essential reference to the main game object
- */
- public game: Phaser.Game;
-
- // Local rendering related temp vars to help avoid gc spikes through constant var creation
- private _ga: number = 1;
- private _sx: number = 0;
- private _sy: number = 0;
- private _sw: number = 0;
- private _sh: number = 0;
- private _dx: number = 0;
- private _dy: number = 0;
- private _dw: number = 0;
- private _dh: number = 0;
- private _fx: number = 1;
- private _fy: number = 1;
- private _sin: number = 0;
- private _cos: number = 1;
-
- public renderCircle(camera: Phaser.Camera, circle: Phaser.Circle, context, outline: bool = false, fill: bool = true, lineColor: string = 'rgb(0,255,0)', fillColor: string = 'rgba(0,100,0.0.3)', lineWidth: number = 1): bool {
-
- // Reset our temp vars
- this._sx = 0;
- this._sy = 0;
- this._sw = circle.diameter;
- this._sh = circle.diameter;
- this._fx = 1;
- this._fy = 1;
- this._sin = 0;
- this._cos = 1;
- this._dx = camera.screenView.x + circle.x - camera.worldView.x;
- this._dy = camera.screenView.y + circle.y - camera.worldView.y;
- this._dw = circle.diameter;
- this._dh = circle.diameter;
-
- this._sx = Math.floor(this._sx);
- this._sy = Math.floor(this._sy);
- this._sw = Math.floor(this._sw);
- this._sh = Math.floor(this._sh);
- this._dx = Math.floor(this._dx);
- this._dy = Math.floor(this._dy);
- this._dw = Math.floor(this._dw);
- this._dh = Math.floor(this._dh);
-
- this.game.stage.saveCanvasValues();
-
- context.save();
- context.lineWidth = lineWidth;
- context.strokeStyle = lineColor;
- context.fillStyle = fillColor;
-
- context.beginPath();
- context.arc(this._dx, this._dy, circle.radius, 0, Math.PI * 2);
- context.closePath();
-
- if (outline)
- {
- //context.stroke();
- }
-
- if (fill)
- {
- context.fill();
- }
-
- context.restore();
-
- this.game.stage.restoreCanvasValues();
-
- return true;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/canvas/GroupRenderer.ts b/wip/TS Source/renderers/canvas/GroupRenderer.ts
deleted file mode 100644
index a746680d..00000000
--- a/wip/TS Source/renderers/canvas/GroupRenderer.ts
+++ /dev/null
@@ -1,163 +0,0 @@
-///
-
-module Phaser.Renderer.Canvas {
-
- export class GroupRenderer {
-
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- /**
- * The essential reference to the main game object
- */
- public game: Phaser.Game;
-
- // Local rendering related temp vars to help avoid gc spikes through var creation
- private _ga: number = 1;
- private _sx: number = 0;
- private _sy: number = 0;
- private _sw: number = 0;
- private _sh: number = 0;
- private _dx: number = 0;
- private _dy: number = 0;
- private _dw: number = 0;
- private _dh: number = 0;
- private _fx: number = 1;
- private _fy: number = 1;
- private _sin: number = 0;
- private _cos: number = 1;
-
- public preRender(camera: Phaser.Camera, group: Phaser.Group) {
-
- if (group.visible == false || camera.transform.scale.x == 0 || camera.transform.scale.y == 0 || camera.texture.alpha < 0.1)
- {
- return false;
- }
-
- // Reset our temp vars
- this._ga = -1;
- this._sx = 0;
- this._sy = 0;
- this._sw = group.texture.width;
- this._sh = group.texture.height;
- this._fx = group.transform.scale.x;
- this._fy = group.transform.scale.y;
- this._sin = 0;
- this._cos = 1;
- //this._dx = (camera.screenView.x * camera.scrollFactor.x) + camera.frameBounds.x - (camera.worldView.x * camera.scrollFactor.x);
- //this._dy = (camera.screenView.y * camera.scrollFactor.y) + camera.frameBounds.y - (camera.worldView.y * camera.scrollFactor.y);
- this._dx = 0;
- this._dy = 0;
- this._dw = group.texture.width;
- this._dh = group.texture.height;
-
- // Global Composite Ops
- if (group.texture.globalCompositeOperation)
- {
- group.texture.context.save();
- group.texture.context.globalCompositeOperation = group.texture.globalCompositeOperation;
- }
-
- // Alpha
- if (group.texture.alpha !== 1 && group.texture.context.globalAlpha !== group.texture.alpha)
- {
- this._ga = group.texture.context.globalAlpha;
- group.texture.context.globalAlpha = group.texture.alpha;
- }
-
- // Flip X
- if (group.texture.flippedX)
- {
- this._fx = -group.transform.scale.x;
- }
-
- // Flip Y
- if (group.texture.flippedY)
- {
- this._fy = -group.transform.scale.y;
- }
-
- // Rotation and Flipped
- if (group.modified)
- {
- if (group.transform.rotation !== 0 || group.transform.rotationOffset !== 0)
- {
- this._sin = Math.sin(group.game.math.degreesToRadians(group.transform.rotationOffset + group.transform.rotation));
- this._cos = Math.cos(group.game.math.degreesToRadians(group.transform.rotationOffset + group.transform.rotation));
- }
-
- group.texture.context.save();
-
- group.texture.context.setTransform(
- this._cos * this._fx, // scale x
- (this._sin * this._fx) + group.transform.skew.x, // skew x
- -(this._sin * this._fy) + group.transform.skew.y, // skew y
- this._cos * this._fy, // scale y
- this._dx, // translate x
- this._dy // translate y
- );
-
- this._dx = -group.transform.origin.x;
- this._dy = -group.transform.origin.y;
- }
- else
- {
- if (!group.transform.origin.equals(0))
- {
- this._dx -= group.transform.origin.x;
- this._dy -= group.transform.origin.y;
- }
- }
-
- this._sx = Math.floor(this._sx);
- this._sy = Math.floor(this._sy);
- this._sw = Math.floor(this._sw);
- this._sh = Math.floor(this._sh);
- this._dx = Math.floor(this._dx);
- this._dy = Math.floor(this._dy);
- this._dw = Math.floor(this._dw);
- this._dh = Math.floor(this._dh);
-
- if (group.texture.opaque)
- {
- group.texture.context.fillStyle = group.texture.backgroundColor;
- group.texture.context.fillRect(this._dx, this._dy, this._dw, this._dh);
- }
-
- if (group.texture.loaded)
- {
- group.texture.context.drawImage(
- group.texture.texture, // Source Image
- this._sx, // Source X (location within the source image)
- this._sy, // Source Y
- this._sw, // Source Width
- this._sh, // Source Height
- this._dx, // Destination X (where on the canvas it'll be drawn)
- this._dy, // Destination Y
- this._dw, // Destination Width (always same as Source Width unless scaled)
- this._dh // Destination Height (always same as Source Height unless scaled)
- );
- }
-
- return true;
-
- }
-
- public postRender(camera: Phaser.Camera, group: Phaser.Group) {
-
- if (group.modified || group.texture.globalCompositeOperation)
- {
- group.texture.context.restore();
- }
-
- if (this._ga > -1)
- {
- group.texture.context.globalAlpha = this._ga;
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/canvas/ScrollZoneRenderer.ts b/wip/TS Source/renderers/canvas/ScrollZoneRenderer.ts
deleted file mode 100644
index a21e9fb1..00000000
--- a/wip/TS Source/renderers/canvas/ScrollZoneRenderer.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-///
-
-module Phaser.Renderer.Canvas {
-
- export class ScrollZoneRenderer {
-
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- /**
- * The essential reference to the main game object
- */
- public game: Phaser.Game;
-
- // Local rendering related temp vars to help avoid gc spikes through constant var creation
- private _ga: number = 1;
- private _sx: number = 0;
- private _sy: number = 0;
- private _sw: number = 0;
- private _sh: number = 0;
- private _dx: number = 0;
- private _dy: number = 0;
- private _dw: number = 0;
- private _dh: number = 0;
- private _fx: number = 1;
- private _fy: number = 1;
- private _sin: number = 0;
- private _cos: number = 1;
-
- /**
- * Check whether this object is visible in a specific camera Rectangle.
- * @param camera {Rectangle} The Rectangle you want to check.
- * @return {bool} Return true if bounds of this sprite intersects the given Rectangle, otherwise return false.
- */
- public inCamera(camera: Phaser.Camera, scrollZone: Phaser.ScrollZone): bool {
-
- // Object fixed in place regardless of the camera scrolling? Then it's always visible
- if (scrollZone.transform.scrollFactor.equals(0))
- {
- return true;
- }
-
- //return RectangleUtils.intersects(sprite.cameraView, camera.screenView);
- return true;
-
- }
-
- public render(camera: Phaser.Camera, scrollZone: Phaser.ScrollZone): bool {
-
- if (scrollZone.transform.scale.x == 0 || scrollZone.transform.scale.y == 0 || scrollZone.texture.alpha < 0.1 || this.inCamera(camera, scrollZone) == false)
- {
- return false;
- }
-
- // Reset our temp vars
- this._ga = -1;
- this._sx = 0;
- this._sy = 0;
- this._sw = scrollZone.width;
- this._sh = scrollZone.height;
- this._fx = scrollZone.transform.scale.x;
- this._fy = scrollZone.transform.scale.y;
- this._sin = 0;
- this._cos = 1;
- this._dx = (camera.screenView.x * scrollZone.transform.scrollFactor.x) + scrollZone.x - (camera.worldView.x * scrollZone.transform.scrollFactor.x);
- this._dy = (camera.screenView.y * scrollZone.transform.scrollFactor.y) + scrollZone.y - (camera.worldView.y * scrollZone.transform.scrollFactor.y);
- this._dw = scrollZone.width;
- this._dh = scrollZone.height;
-
- // Alpha
- if (scrollZone.texture.alpha !== 1)
- {
- this._ga = scrollZone.texture.context.globalAlpha;
- scrollZone.texture.context.globalAlpha = scrollZone.texture.alpha;
- }
-
- // Sprite Flip X
- if (scrollZone.texture.flippedX)
- {
- this._fx = -scrollZone.transform.scale.x;
- }
-
- // Sprite Flip Y
- if (scrollZone.texture.flippedY)
- {
- this._fy = -scrollZone.transform.scale.y;
- }
-
- // Rotation and Flipped
- if (scrollZone.modified)
- {
- if (scrollZone.texture.renderRotation == true && (scrollZone.rotation !== 0 || scrollZone.transform.rotationOffset !== 0))
- {
- this._sin = Math.sin(scrollZone.game.math.degreesToRadians(scrollZone.transform.rotationOffset + scrollZone.rotation));
- this._cos = Math.cos(scrollZone.game.math.degreesToRadians(scrollZone.transform.rotationOffset + scrollZone.rotation));
- }
-
- scrollZone.texture.context.save();
-
- scrollZone.texture.context.setTransform(
- this._cos * this._fx, // scale x
- (this._sin * this._fx) + scrollZone.transform.skew.x, // skew x
- -(this._sin * this._fy) + scrollZone.transform.skew.y, // skew y
- this._cos * this._fy, // scale y
- this._dx, // translate x
- this._dy // translate y
- );
-
- this._dx = -scrollZone.transform.origin.x;
- this._dy = -scrollZone.transform.origin.y;
- }
- else
- {
- if (!scrollZone.transform.origin.equals(0))
- {
- this._dx -= scrollZone.transform.origin.x;
- this._dy -= scrollZone.transform.origin.y;
- }
- }
-
- this._sx = Math.floor(this._sx);
- this._sy = Math.floor(this._sy);
- this._sw = Math.floor(this._sw);
- this._sh = Math.floor(this._sh);
- this._dx = Math.floor(this._dx);
- this._dy = Math.floor(this._dy);
- this._dw = Math.floor(this._dw);
- this._dh = Math.floor(this._dh);
-
- for (var i = 0; i < scrollZone.regions.length; i++)
- {
- if (scrollZone.texture.isDynamic)
- {
- scrollZone.regions[i].render(scrollZone.texture.context, scrollZone.texture.texture, this._dx, this._dy, this._dw, this._dh);
- }
- else
- {
- scrollZone.regions[i].render(scrollZone.texture.context, scrollZone.texture.texture, this._dx, this._dy, this._dw, this._dh);
- }
- }
-
- if (scrollZone.modified)
- {
- scrollZone.texture.context.restore();
- }
-
- if (this._ga > -1)
- {
- scrollZone.texture.context.globalAlpha = this._ga;
- }
-
- this.game.renderer.renderCount++;
-
- return true;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/canvas/SpriteRenderer.ts b/wip/TS Source/renderers/canvas/SpriteRenderer.ts
deleted file mode 100644
index aa65f5bd..00000000
--- a/wip/TS Source/renderers/canvas/SpriteRenderer.ts
+++ /dev/null
@@ -1,191 +0,0 @@
-///
-
-module Phaser.Renderer.Canvas {
-
- export class SpriteRenderer {
-
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- /**
- * The essential reference to the main game object
- */
- public game: Phaser.Game;
-
- // Local rendering related temp vars to help avoid gc spikes through constant var creation
- //private _c: number = 0;
- private _ga: number = 1;
- private _sx: number = 0;
- private _sy: number = 0;
- private _sw: number = 0;
- private _sh: number = 0;
- private _dx: number = 0;
- private _dy: number = 0;
- private _dw: number = 0;
- private _dh: number = 0;
-
- /**
- * Check whether this object is visible in a specific camera Rectangle.
- * @param camera {Rectangle} The Rectangle you want to check.
- * @return {bool} Return true if bounds of this sprite intersects the given Rectangle, otherwise return false.
- */
- public inCamera(camera: Phaser.Camera, sprite: Phaser.Sprite): bool {
-
- // Object fixed in place regardless of the camera scrolling? Then it's always visible
- if (sprite.transform.scrollFactor.equals(0))
- {
- return true;
- }
-
- return RectangleUtils.intersects(sprite.cameraView, camera.screenView);
-
- }
-
- /**
- * Render this sprite to specific camera. Called by game loop after update().
- * @param camera {Camera} Camera this sprite will be rendered to.
- * @return {bool} Return false if not rendered, otherwise return true.
- */
- public render(camera: Phaser.Camera, sprite: Phaser.Sprite): bool {
-
- Phaser.SpriteUtils.updateCameraView(camera, sprite);
-
- if (sprite.transform.scale.x == 0 || sprite.transform.scale.y == 0 || sprite.texture.alpha < 0.1 || this.inCamera(camera, sprite) == false)
- {
- return false;
- }
-
- // Reset our temp vars
- this._ga = -1;
- this._sx = 0;
- this._sy = 0;
- this._sw = sprite.texture.width;
- this._sh = sprite.texture.height;
- //this._dx = camera.screenView.x + sprite.x - (camera.worldView.x * sprite.transform.scrollFactor.x);
- //this._dy = camera.screenView.y + sprite.y - (camera.worldView.y * sprite.transform.scrollFactor.y);
- this._dx = sprite.x - (camera.worldView.x * sprite.transform.scrollFactor.x);
- this._dy = sprite.y - (camera.worldView.y * sprite.transform.scrollFactor.y);
- this._dw = sprite.texture.width;
- this._dh = sprite.texture.height;
-
- if (sprite.animations.currentFrame !== null)
- {
- this._sx = sprite.animations.currentFrame.x;
- this._sy = sprite.animations.currentFrame.y;
-
- if (sprite.animations.currentFrame.trimmed)
- {
- this._dx += sprite.animations.currentFrame.spriteSourceSizeX;
- this._dy += sprite.animations.currentFrame.spriteSourceSizeY;
- this._sw = sprite.animations.currentFrame.spriteSourceSizeW;
- this._sh = sprite.animations.currentFrame.spriteSourceSizeH;
- this._dw = sprite.animations.currentFrame.spriteSourceSizeW;
- this._dh = sprite.animations.currentFrame.spriteSourceSizeH;
- }
- }
-
- if (sprite.modified)
- {
- camera.texture.context.save();
-
- camera.texture.context.setTransform(
- sprite.transform.local.data[0], // scale x
- sprite.transform.local.data[3], // skew x
- sprite.transform.local.data[1], // skew y
- sprite.transform.local.data[4], // scale y
- this._dx, // translate x
- this._dy // translate y
- );
-
- this._dx = sprite.transform.origin.x * -this._dw;
- this._dy = sprite.transform.origin.y * -this._dh;
- }
- else
- {
- this._dx -= (this._dw * sprite.transform.origin.x);
- this._dy -= (this._dh * sprite.transform.origin.y);
- }
-
- if (sprite.crop)
- {
- this._sx += sprite.crop.x * sprite.transform.scale.x;
- this._sy += sprite.crop.y * sprite.transform.scale.y;
- this._sw = sprite.crop.width * sprite.transform.scale.x;
- this._sh = sprite.crop.height * sprite.transform.scale.y;
- this._dx += sprite.crop.x * sprite.transform.scale.x;
- this._dy += sprite.crop.y * sprite.transform.scale.y;
- this._dw = sprite.crop.width * sprite.transform.scale.x;
- this._dh = sprite.crop.height * sprite.transform.scale.y;
- }
-
- this._sx = Math.floor(this._sx);
- this._sy = Math.floor(this._sy);
- this._sw = Math.floor(this._sw);
- this._sh = Math.floor(this._sh);
- this._dx = Math.floor(this._dx);
- this._dy = Math.floor(this._dy);
- this._dw = Math.floor(this._dw);
- this._dh = Math.floor(this._dh);
-
- if (this._sw <= 0 || this._sh <= 0 || this._dw <= 0 || this._dh <= 0)
- {
- return false;
- }
-
- // Global Composite Ops
- if (sprite.texture.globalCompositeOperation)
- {
- camera.texture.context.save();
- camera.texture.context.globalCompositeOperation = sprite.texture.globalCompositeOperation;
- }
-
- // Alpha
- if (sprite.texture.alpha !== 1 && camera.texture.context.globalAlpha != sprite.texture.alpha)
- {
- this._ga = sprite.texture.context.globalAlpha;
- camera.texture.context.globalAlpha = sprite.texture.alpha;
- }
-
- if (sprite.texture.opaque)
- {
- camera.texture.context.fillStyle = sprite.texture.backgroundColor;
- camera.texture.context.fillRect(this._dx, this._dy, this._dw, this._dh);
- }
-
- if (sprite.texture.loaded)
- {
- camera.texture.context.drawImage(
- sprite.texture.texture, // Source Image
- this._sx, // Source X (location within the source image)
- this._sy, // Source Y
- this._sw, // Source Width
- this._sh, // Source Height
- this._dx, // Destination X (where on the canvas it'll be drawn)
- this._dy, // Destination Y
- this._dw, // Destination Width (always same as Source Width unless scaled)
- this._dh // Destination Height (always same as Source Height unless scaled)
- );
- }
-
- if (sprite.modified || sprite.texture.globalCompositeOperation)
- {
- camera.texture.context.restore();
- }
-
- if (this._ga > -1)
- {
- camera.texture.context.globalAlpha = this._ga;
- }
-
- sprite.renderOrderID = this.game.renderer.renderCount;
-
- this.game.renderer.renderCount++;
-
- return true;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/renderers/canvas/TilemapRenderer.ts b/wip/TS Source/renderers/canvas/TilemapRenderer.ts
deleted file mode 100644
index b5f5d1c6..00000000
--- a/wip/TS Source/renderers/canvas/TilemapRenderer.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-///
-
-module Phaser.Renderer.Canvas {
-
- export class TilemapRenderer {
-
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- /**
- * The essential reference to the main game object
- */
- public game: Phaser.Game;
-
- // Local rendering related temp vars to help avoid gc spikes through constant var creation
- private _ga: number = 1;
- private _dx: number = 0;
- private _dy: number = 0;
- private _dw: number = 0;
- private _dh: number = 0;
- private _tx: number = 0;
- private _ty: number = 0;
- private _tl: number = 0;
- private _maxX: number = 0;
- private _maxY: number = 0;
- private _startX: number = 0;
- private _startY: number = 0;
- private _columnData;
-
- /**
- * Render a tilemap to a specific camera.
- * @param camera {Camera} The camera this tilemap will be rendered to.
- */
- public render(camera: Phaser.Camera, tilemap: Phaser.Tilemap): bool {
-
- // Loop through the layers
-
- this._tl = tilemap.layers.length;
-
- for (var i = 0; i < this._tl; i++)
- {
- if (tilemap.layers[i].visible == false || tilemap.layers[i].alpha < 0.1)
- {
- continue;
- }
-
- var layer: TilemapLayer = tilemap.layers[i];
-
- // Work out how many tiles we can fit into our camera and round it up for the edges
- this._maxX = this.game.math.ceil(camera.width / layer.tileWidth) + 1;
- this._maxY = this.game.math.ceil(camera.height / layer.tileHeight) + 1;
-
- // And now work out where in the tilemap the camera actually is
- this._startX = this.game.math.floor(camera.worldView.x / layer.tileWidth);
- this._startY = this.game.math.floor(camera.worldView.y / layer.tileHeight);
-
- // Tilemap bounds check
- if (this._startX < 0)
- {
- this._startX = 0;
- }
-
- if (this._startY < 0)
- {
- this._startY = 0;
- }
-
- if (this._maxX > layer.widthInTiles)
- {
- this._maxX = layer.widthInTiles;
- }
-
- if (this._maxY > layer.heightInTiles)
- {
- this._maxY = layer.heightInTiles;
- }
-
- if (this._startX + this._maxX > layer.widthInTiles)
- {
- this._startX = layer.widthInTiles - this._maxX;
- }
-
- if (this._startY + this._maxY > layer.heightInTiles)
- {
- this._startY = layer.heightInTiles - this._maxY;
- }
-
- // Finally get the offset to avoid the blocky movement
- //this._dx = (camera.screenView.x * layer.transform.scrollFactor.x) - (camera.worldView.x * layer.transform.scrollFactor.x);
- //this._dy = (camera.screenView.y * layer.transform.scrollFactor.y) - (camera.worldView.y * layer.transform.scrollFactor.y);
- //this._dx = (camera.screenView.x * this.scrollFactor.x) + this.x - (camera.worldView.x * this.scrollFactor.x);
- //this._dy = (camera.screenView.y * this.scrollFactor.y) + this.y - (camera.worldView.y * this.scrollFactor.y);
- this._dx = 0;
- this._dy = 0;
-
- this._dx += -(camera.worldView.x - (this._startX * layer.tileWidth));
- this._dy += -(camera.worldView.y - (this._startY * layer.tileHeight));
-
- this._tx = this._dx;
- this._ty = this._dy;
-
- // Alpha
- if (layer.texture.alpha !== 1)
- {
- this._ga = layer.texture.context.globalAlpha;
- layer.texture.context.globalAlpha = layer.texture.alpha;
- }
-
- for (var row = this._startY; row < this._startY + this._maxY; row++)
- {
- this._columnData = layer.mapData[row];
-
- for (var tile = this._startX; tile < this._startX + this._maxX; tile++)
- {
- if (layer.tileOffsets[this._columnData[tile]])
- {
- layer.texture.context.drawImage(
- layer.texture.texture,
- layer.tileOffsets[this._columnData[tile]].x,
- layer.tileOffsets[this._columnData[tile]].y,
- layer.tileWidth,
- layer.tileHeight,
- this._tx,
- this._ty,
- layer.tileWidth,
- layer.tileHeight
- );
-
- }
-
- this._tx += layer.tileWidth;
-
- }
-
- this._tx = this._dx;
- this._ty += layer.tileHeight;
-
- }
-
- if (this._ga > -1)
- {
- layer.texture.context.globalAlpha = this._ga;
- }
- }
-
- return true;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/sound/Sound.ts b/wip/TS Source/sound/Sound.ts
deleted file mode 100644
index 25780245..00000000
--- a/wip/TS Source/sound/Sound.ts
+++ /dev/null
@@ -1,553 +0,0 @@
-///
-
-/**
-* Phaser - Sound
-*
-* A Sound file, used by the Game.SoundManager for playback.
-*/
-
-module Phaser {
-
- export class Sound {
-
- /**
- * Sound constructor
- * @param [volume] {number} volume of this sound when playing.
- * @param [loop] {bool} loop this sound when playing? (Default to false)
- */
- constructor(game: Phaser.Game, key: string, volume: number = 1, loop: bool = false) {
-
- this.game = game;
-
- this.usingWebAudio = this.game.sound.usingWebAudio;
- this.usingAudioTag = this.game.sound.usingAudioTag;
- this.key = key;
-
- if (this.usingWebAudio)
- {
- this.context = this.game.sound.context;
- this.masterGainNode = this.game.sound.masterGain;
-
- if (typeof this.context.createGain === 'undefined')
- {
- this.gainNode = this.context.createGainNode();
- }
- else
- {
- this.gainNode = this.context.createGain();
- }
-
- this.gainNode.gain.value = volume * this.game.sound.volume;
- this.gainNode.connect(this.masterGainNode);
- }
- else
- {
- if (this.game.cache.getSound(key) && this.game.cache.getSound(key).locked == false)
- {
- this._sound = this.game.cache.getSoundData(key);
- this.totalDuration = this._sound.duration;
- }
- else
- {
- this.game.cache.onSoundUnlock.add(this.soundHasUnlocked, this);
- }
- }
-
- this._volume = volume;
- this.loop = loop;
- this.markers = {};
-
- this.onDecoded = new Phaser.Signal;
- this.onPlay = new Phaser.Signal;
- this.onPause = new Phaser.Signal;
- this.onResume = new Phaser.Signal;
- this.onLoop = new Phaser.Signal;
- this.onStop = new Phaser.Signal;
- this.onMute = new Phaser.Signal;
- this.onMarkerComplete = new Phaser.Signal;
-
- }
-
- private soundHasUnlocked(key: string) {
-
- if (key == this.key)
- {
- this._sound = this.game.cache.getSoundData(this.key);
- this.totalDuration = this._sound.duration;
- //console.log('sound has unlocked', this._sound);
- }
-
- }
-
- /**
- * Local reference to the current Phaser.Game.
- */
- public game: Phaser.Game;
-
- /**
- * Reference to AudioContext instance.
- */
- public context = null;
-
- /**
- * Reference to gain node of SoundManager.
- */
- public masterGainNode;
-
- /**
- * GainNode of this sound.
- */
- public gainNode;
-
- /**
- * Decoded data buffer / Audio tag.
- */
- private _buffer = null;
-
- /**
- * Volume of this sound.
- */
- private _volume: number;
-
- /**
- * The real sound object (buffer source).
- */
- private _sound;
-
- private _muteVolume: number;
- private _muted: bool = false;
- private _tempPosition: number;
- private _tempVolume: number;
- private _tempLoop: bool;
- private _tempMarker: string;
-
- public usingWebAudio: bool = false;
- public usingAudioTag: bool = false;
-
- public name: string = '';
-
- autoplay: bool = false;
- totalDuration: number = 0;
- startTime: number = 0;
- currentTime: number = 0;
- duration: number = 0;
- stopTime: number = 0;
- position: number;
- paused: bool = false;
- loop: bool = false;
- isPlaying: bool = false;
- key: string;
- markers;
- currentMarker: string = '';
-
- // events
- public onDecoded: Phaser.Signal;
- public onPlay: Phaser.Signal;
- public onPause: Phaser.Signal;
- public onResume: Phaser.Signal;
- public onLoop: Phaser.Signal;
- public onStop: Phaser.Signal;
- public onMute: Phaser.Signal;
- public onMarkerComplete: Phaser.Signal;
-
- public pendingPlayback: bool = false;
-
- public get isDecoding(): bool {
- return this.game.cache.getSound(this.key).isDecoding;
- }
-
- public get isDecoded(): bool {
- return this.game.cache.isSoundDecoded(this.key);
- }
-
- public addMarker(name: string, start: number, stop: number, volume: number = 1, loop: bool = false) {
- this.markers[name] = { name: name, start: start, stop: stop, volume: volume, duration: stop - start, loop: loop };
- }
-
- public removeMarker(name: string) {
- delete this.markers[name];
- }
-
- public update() {
-
- if (this.pendingPlayback && this.game.cache.isSoundReady(this.key))
- {
- this.pendingPlayback = false;
- this.play(this._tempMarker, this._tempPosition, this._tempVolume, this._tempLoop);
- }
-
- if (this.isPlaying)
- {
- this.currentTime = this.game.time.now - this.startTime;
-
- if (this.currentTime >= this.duration)
- {
- //console.log(this.currentMarker, 'has hit duration');
-
- if (this.usingWebAudio)
- {
- if (this.loop)
- {
- //console.log('loop1');
-
- // won't work with markers, needs to reset the position
- this.onLoop.dispatch(this);
-
- if (this.currentMarker == '')
- {
- //console.log('loop2');
- this.currentTime = 0;
- this.startTime = this.game.time.now;
- }
- else
- {
- //console.log('loop3');
- this.play(this.currentMarker, 0, this.volume, true, true);
- }
- }
- else
- {
- //console.log('stopping, no loop for marker');
- this.stop();
- }
- }
- else
- {
- if (this.loop)
- {
- this.onLoop.dispatch(this);
- this.play(this.currentMarker, 0, this.volume, true, true);
- }
- else
- {
- this.stop();
- }
- }
- }
-
- }
-
- }
-
- public override: bool = false;
-
- /**
- * Play this sound, or a marked section of it.
- * @param marker {string} Assets key of the sound you want to play.
- * @param [volume] {number} volume of the sound you want to play.
- * @param [loop] {bool} loop when it finished playing? (Default to false)
- * @return {Sound} The playing sound object.
- */
- public play(marker: string = '', position: number = 0, volume: number = 1, loop: bool = false, forceRestart: bool = false) {
-
- //console.log('play', marker, 'current is', this.currentMarker);
-
- if (this.isPlaying == true && forceRestart == false && this.override == false)
- {
- // Use Restart instead
- return;
- }
-
- if (this.isPlaying && this.override)
- {
- //console.log('asked to play', marker, 'but already playing', this.currentMarker);
- if (this.usingWebAudio)
- {
- if (typeof this._sound.stop === 'undefined')
- {
- this._sound.noteOff(0);
- }
- else
- {
- this._sound.stop(0);
- }
- }
- else if (this.usingAudioTag)
- {
- this._sound.pause();
- this._sound.currentTime = 0;
- }
- }
-
- this.currentMarker = marker;
-
- if (marker !== '' && this.markers[marker])
- {
- this.position = this.markers[marker].start;
- this.volume = this.markers[marker].volume;
- this.loop = this.markers[marker].loop;
- this.duration = this.markers[marker].duration * 1000;
-
- //console.log('marker info loaded', this.loop, this.duration);
-
- this._tempMarker = marker;
- this._tempPosition = this.position;
- this._tempVolume = this.volume;
- this._tempLoop = this.loop;
- }
- else
- {
- this.position = position;
- this.volume = volume;
- this.loop = loop;
- this.duration = 0;
-
- this._tempMarker = marker;
- this._tempPosition = position;
- this._tempVolume = volume;
- this._tempLoop = loop;
- }
-
- if (this.usingWebAudio)
- {
- // Does the sound need decoding?
- if (this.game.cache.isSoundDecoded(this.key))
- {
- // Do we need to do this every time we play? How about just if the buffer is empty?
- if (this._buffer == null)
- {
- this._buffer = this.game.cache.getSoundData(this.key);
- }
-
- //if (this._sound == null)
- //{
- this._sound = this.context.createBufferSource();
- this._sound.buffer = this._buffer;
- this._sound.connect(this.gainNode);
- this.totalDuration = this._sound.buffer.duration;
- //}
-
- if (this.duration == 0)
- {
- this.duration = this.totalDuration * 1000;
- }
-
- if (this.loop && marker == '')
- {
- this._sound.loop = true;
- }
-
- // Useful to cache this somewhere perhaps?
- if (typeof this._sound.start === 'undefined')
- {
- this._sound.noteGrainOn(0, this.position, this.duration / 1000);
- //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
- }
- else
- {
- this._sound.start(0, this.position, this.duration / 1000);
- }
-
- this.isPlaying = true;
- this.startTime = this.game.time.now;
- this.currentTime = 0;
- this.stopTime = this.startTime + this.duration;
- this.onPlay.dispatch(this);
-
- //console.log('playing, start', this.startTime, 'stop');
-
- }
- else
- {
- this.pendingPlayback = true;
-
- if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding == false)
- {
- this.game.sound.decode(this.key, this);
- }
- }
- }
- else
- {
- //console.log('Sound play Audio');
-
- if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked)
- {
- //console.log('tried playing locked sound, pending set, reload started');
- this.game.cache.reloadSound(this.key);
- this.pendingPlayback = true;
- }
- else
- {
- //console.log('sound not locked, state?', this._sound.readyState);
- if (this._sound && this._sound.readyState == 4)
- {
- if (this.duration == 0)
- {
- this.duration = this.totalDuration * 1000;
- }
-
- //console.log('playing', this._sound);
- this._sound.currentTime = this.position;
- this._sound.muted = this._muted;
-
- if (this._muted)
- {
- this._sound.volume = 0;
- }
- else
- {
- this._sound.volume = this._volume;
- }
-
- this._sound.play();
-
- this.isPlaying = true;
- this.startTime = this.game.time.now;
- this.currentTime = 0;
- this.stopTime = this.startTime + this.duration;
- this.onPlay.dispatch(this);
- }
- else
- {
- this.pendingPlayback = true;
- }
- }
-
- }
-
- }
-
- public restart(marker: string = '', position: number = 0, volume: number = 1, loop: bool = false) {
- this.play(marker, position, volume, loop, true);
- }
-
- public pause() {
-
- if (this.isPlaying && this._sound)
- {
- this.stop();
- this.isPlaying = false;
- this.paused = true;
- this.onPause.dispatch(this);
- }
-
- }
-
- public resume() {
-
- if (this.paused && this._sound)
- {
- if (this.usingWebAudio)
- {
- if (typeof this._sound.start === 'undefined')
- {
- this._sound.noteGrainOn(0, this.position, this.duration);
- //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
- }
- else
- {
- this._sound.start(0, this.position, this.duration);
- }
- }
- else
- {
- this._sound.play();
- }
-
- this.isPlaying = true;
- this.paused = false;
- this.onResume.dispatch(this);
- }
-
- }
-
- /**
- * Stop playing this sound.
- */
- public stop() {
-
- if (this.isPlaying && this._sound)
- {
- if (this.usingWebAudio)
- {
- if (typeof this._sound.stop === 'undefined')
- {
- this._sound.noteOff(0);
- }
- else
- {
- this._sound.stop(0);
- }
- }
- else if (this.usingAudioTag)
- {
- this._sound.pause();
- this._sound.currentTime = 0;
- }
- }
-
- this.isPlaying = false;
-
- var prevMarker: string = this.currentMarker;
-
- this.currentMarker = '';
-
- this.onStop.dispatch(this, prevMarker);
-
- }
-
- /**
- * Mute sounds.
- */
- public get mute(): bool {
- return this._muted;
- }
-
- public set mute(value: bool) {
-
- if (value)
- {
- this._muted = true;
-
- if (this.usingWebAudio)
- {
- this._muteVolume = this.gainNode.gain.value;
- this.gainNode.gain.value = 0;
- }
- else if (this.usingAudioTag && this._sound)
- {
- this._muteVolume = this._sound.volume;
- this._sound.volume = 0;
- }
- }
- else
- {
- this._muted = false;
-
- if (this.usingWebAudio)
- {
- this.gainNode.gain.value = this._muteVolume;
- }
- else if (this.usingAudioTag && this._sound)
- {
- this._sound.volume = this._muteVolume;
- }
- }
-
- this.onMute.dispatch(this);
-
- }
-
- public set volume(value: number) {
-
- this._volume = value;
-
- if (this.usingWebAudio)
- {
- this.gainNode.gain.value = value;
- }
- else if (this.usingAudioTag && this._sound)
- {
- this._sound.volume = value;
- }
-
- }
-
- public get volume(): number {
- return this._volume;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/sound/SoundManager.ts b/wip/TS Source/sound/SoundManager.ts
deleted file mode 100644
index 9d1ff8eb..00000000
--- a/wip/TS Source/sound/SoundManager.ts
+++ /dev/null
@@ -1,371 +0,0 @@
-///
-
-/**
-* Phaser - SoundManager
-*
-*/
-
-module Phaser {
-
- export class SoundManager {
-
- /**
- * SoundManager constructor
- * Create a new SoundManager.
- */
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- this._volume = 1;
- this._muted = false;
- this._sounds = [];
-
- if (this.game.device.iOS && this.game.device.webAudio == false)
- {
- this.channels = 1;
- }
-
- if (this.game.device.iOS || (window['PhaserGlobal'] && window['PhaserGlobal'].fakeiOSTouchLock))
- {
- this.game.input.touch.callbackContext = this;
- this.game.input.touch.touchStartCallback = this.unlock;
- this.game.input.mouse.callbackContext = this;
- this.game.input.mouse.mouseDownCallback = this.unlock;
- this.touchLocked = true;
- }
- else
- {
- // What about iOS5?
- this.touchLocked = false;
- }
-
- if (window['PhaserGlobal'])
- {
- // Check to see if all audio playback is disabled (i.e. handled by a 3rd party class)
- if (window['PhaserGlobal'].disableAudio == true)
- {
- this.usingWebAudio = false;
- this.noAudio = true;
- return;
- }
-
- // Check if the Web Audio API is disabled (for testing Audio Tag playback during development)
- if (window['PhaserGlobal'].disableWebAudio == true)
- {
- this.usingWebAudio = false;
- this.usingAudioTag = true;
- this.noAudio = false;
- return;
- }
- }
-
-
- this.usingWebAudio = true;
- this.noAudio = false;
-
- if (!!window['AudioContext'])
- {
- this.context = new window['AudioContext']();
- }
- else if (!!window['webkitAudioContext'])
- {
- this.context = new window['webkitAudioContext']();
- }
- else if (!!window['Audio'])
- {
- this.usingWebAudio = false;
- this.usingAudioTag = true;
- }
- else
- {
- this.usingWebAudio = false;
- this.noAudio = true;
- }
-
- if (this.context !== null)
- {
- if (typeof this.context.createGain === 'undefined')
- {
- this.masterGain = this.context.createGainNode();
- }
- else
- {
- this.masterGain = this.context.createGain();
- }
-
- this.masterGain.gain.value = 1;
- this.masterGain.connect(this.context.destination);
- }
-
- }
-
- public usingWebAudio: bool = false;
- public usingAudioTag: bool = false;
- public noAudio: bool = false;
-
- /**
- * Local reference to the current Phaser.Game.
- */
- public game: Phaser.Game;
-
- /**
- * Reference to AudioContext instance.
- */
- public context = null;
-
- /**
- * The Master Gain node through which all sounds
- */
- public masterGain;
-
- /**
- * Volume of sounds.
- * @type {number}
- */
- private _volume: number;
-
- private _sounds: Phaser.Sound[];
-
- private _muteVolume: number;
- private _muted: bool = false;
-
- public channels: number;
-
- public touchLocked: bool = false;
-
- private _unlockSource = null;
-
- public unlock() {
-
- if (this.touchLocked == false)
- {
- return;
- }
-
- //console.log('SoundManager touch unlocked');
-
- if (this.game.device.webAudio && (window['PhaserGlobal'] && window['PhaserGlobal'].disableWebAudio == false))
- {
- // Create empty buffer and play it
- var buffer = this.context.createBuffer(1, 1, 22050);
- this._unlockSource = this.context.createBufferSource();
- this._unlockSource.buffer = buffer;
- this._unlockSource.connect(this.context.destination);
- this._unlockSource.noteOn(0);
- }
- else
- {
- // Create an Audio tag?
- this.touchLocked = false;
- this._unlockSource = null;
- this.game.input.touch.callbackContext = null;
- this.game.input.touch.touchStartCallback = null;
- this.game.input.mouse.callbackContext = null;
- this.game.input.mouse.mouseDownCallback = null;
- }
-
- }
-
- /**
- * A global audio mute toggle.
- */
- public get mute():bool {
- return this._muted;
- }
-
- public set mute(value: bool) {
-
- if (value)
- {
- if (this._muted)
- {
- return;
- }
-
- this._muted = true;
-
- if (this.usingWebAudio)
- {
- this._muteVolume = this.masterGain.gain.value;
- this.masterGain.gain.value = 0;
- }
-
- // Loop through sounds
- for (var i = 0; i < this._sounds.length; i++)
- {
- if (this._sounds[i].usingAudioTag)
- {
- this._sounds[i].mute = true;
- }
- }
- }
- else
- {
- if (this._muted == false)
- {
- return;
- }
-
- this._muted = false;
-
- if (this.usingWebAudio)
- {
- this.masterGain.gain.value = this._muteVolume;
- }
-
- // Loop through sounds
- for (var i = 0; i < this._sounds.length; i++)
- {
- if (this._sounds[i].usingAudioTag)
- {
- this._sounds[i].mute = false;
- }
- }
- }
-
- }
-
- /**
- * The global audio volume. A value between 0 (silence) and 1 (full volume)
- */
- public set volume(value: number) {
-
- value = this.game.math.clamp(value, 1, 0);
-
- this._volume = value;
-
- if (this.usingWebAudio)
- {
- this.masterGain.gain.value = value;
- }
-
- // Loop through the sound cache and change the volume of all html audio tags
- for (var i = 0; i < this._sounds.length; i++)
- {
- if (this._sounds[i].usingAudioTag)
- {
- this._sounds[i].volume = this._sounds[i].volume * value;
- }
- }
-
- }
-
- public get volume(): number {
-
- if (this.usingWebAudio)
- {
- return this.masterGain.gain.value;
- }
- else
- {
- return this._volume;
- }
-
- }
-
- public stopAll() {
-
- for (var i = 0; i < this._sounds.length; i++)
- {
- if (this._sounds[i])
- {
- this._sounds[i].stop();
- }
- }
-
- }
-
- public pauseAll() {
-
- for (var i = 0; i < this._sounds.length; i++)
- {
- if (this._sounds[i])
- {
- this._sounds[i].pause();
- }
- }
-
- }
-
- public resumeAll() {
-
- for (var i = 0; i < this._sounds.length; i++)
- {
- if (this._sounds[i])
- {
- this._sounds[i].resume();
- }
- }
-
- }
-
- /**
- * Decode a sound with its assets key.
- * @param key {string} Assets key of the sound to be decoded.
- * @param [sound] {Sound} its bufer will be set to decoded data.
- */
- public decode(key: string, sound: Sound = null) {
-
- var soundData = this.game.cache.getSoundData(key);
-
- if (soundData)
- {
- if (this.game.cache.isSoundDecoded(key) === false)
- {
- this.game.cache.updateSound(key, 'isDecoding', true);
-
- var that = this;
-
- this.context.decodeAudioData(soundData, function (buffer) {
-
- that.game.cache.decodedSound(key, buffer);
-
- if (sound)
- {
- that.onSoundDecode.dispatch(sound);
- }
- });
- }
- }
-
- }
-
- public onSoundDecode: Phaser.Signal = new Phaser.Signal;
-
- public update() {
-
- if (this.touchLocked)
- {
- if (this.game.device.webAudio && this._unlockSource !== null)
- {
- if ((this._unlockSource.playbackState === this._unlockSource.PLAYING_STATE || this._unlockSource.playbackState === this._unlockSource.FINISHED_STATE))
- {
- this.touchLocked = false;
- this._unlockSource = null;
- this.game.input.touch.callbackContext = null;
- this.game.input.touch.touchStartCallback = null;
- }
- }
- }
-
- for (var i = 0; i < this._sounds.length; i++)
- {
- this._sounds[i].update();
- }
-
- }
-
- public add(key: string, volume: number = 1, loop: bool = false): Sound {
-
- var sound: Phaser.Sound = new Sound(this.game, key, volume, loop);
-
- this._sounds.push(sound);
-
- return sound;
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/system/Device.ts b/wip/TS Source/system/Device.ts
deleted file mode 100644
index 2180ba2e..00000000
--- a/wip/TS Source/system/Device.ts
+++ /dev/null
@@ -1,552 +0,0 @@
-///
-
-/**
-* Phaser - Device
-*
-* Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr
-* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js
-*/
-
-module Phaser {
-
- export class Device {
-
- /**
- * Device constructor
- */
- constructor() {
-
- this._checkAudio();
- this._checkBrowser();
- this._checkCSS3D();
- this._checkDevice();
- this._checkFeatures();
- this._checkOS();
-
- }
-
- /**
- * An optional 'fix' for the horrendous Android stock browser bug
- * https://code.google.com/p/android/issues/detail?id=39247
- * @type {bool}
- */
- public patchAndroidClearRectBug: bool = false;
-
- // Operating System
-
- /**
- * Is running desktop?
- * @type {bool}
- */
- public desktop: bool = false;
-
- /**
- * Is running on iOS?
- * @type {bool}
- */
- public iOS: bool = false;
-
- /**
- * Is running on android?
- * @type {bool}
- */
- public android: bool = false;
-
- /**
- * Is running on chromeOS?
- * @type {bool}
- */
- public chromeOS: bool = false;
-
- /**
- * Is running on linux?
- * @type {bool}
- */
- public linux: bool = false;
-
- /**
- * Is running on maxOS?
- * @type {bool}
- */
- public macOS: bool = false;
-
- /**
- * Is running on windows?
- * @type {bool}
- */
- public windows: bool = false;
-
- // Features
-
- /**
- * Is canvas available?
- * @type {bool}
- */
- public canvas: bool = false;
-
- /**
- * Is file available?
- * @type {bool}
- */
- public file: bool = false;
-
- /**
- * Is fileSystem available?
- * @type {bool}
- */
- public fileSystem: bool = false;
-
- /**
- * Is localStorage available?
- * @type {bool}
- */
- public localStorage: bool = false;
-
- /**
- * Is webGL available?
- * @type {bool}
- */
- public webGL: bool = false;
-
- /**
- * Is worker available?
- * @type {bool}
- */
- public worker: bool = false;
-
- /**
- * Is touch available?
- * @type {bool}
- */
- public touch: bool = false;
-
- /**
- * Is mspointer available?
- * @type {bool}
- */
- public mspointer: bool = false;
-
- /**
- * Is css3D available?
- * @type {bool}
- */
- public css3D: bool = false;
-
- // Browser
-
- /**
- * Is running in arora?
- * @type {bool}
- */
- public arora: bool = false;
-
- /**
- * Is running in chrome?
- * @type {bool}
- */
- public chrome: bool = false;
-
- /**
- * Is running in epiphany?
- * @type {bool}
- */
- public epiphany: bool = false;
-
- /**
- * Is running in firefox?
- * @type {bool}
- */
- public firefox: bool = false;
-
- /**
- * Is running in ie?
- * @type {bool}
- */
- public ie: bool = false;
-
- /**
- * Version of ie?
- * @type Number
- */
- public ieVersion: number = 0;
-
- /**
- * Is running in mobileSafari?
- * @type {bool}
- */
- public mobileSafari: bool = false;
-
- /**
- * Is running in midori?
- * @type {bool}
- */
- public midori: bool = false;
-
- /**
- * Is running in opera?
- * @type {bool}
- */
- public opera: bool = false;
-
- /**
- * Is running in safari?
- * @type {bool}
- */
- public safari: bool = false;
- public webApp: bool = false;
-
- // Audio
-
- /**
- * Are Audio tags available?
- * @type {bool}
- */
- public audioData: bool = false;
-
- /**
- * Is the WebAudio API available?
- * @type {bool}
- */
- public webAudio: bool = false;
-
- /**
- * Can this device play ogg files?
- * @type {bool}
- */
- public ogg: bool = false;
-
- /**
- * Can this device play opus files?
- * @type {bool}
- */
- public opus: bool = false;
-
- /**
- * Can this device play mp3 files?
- * @type {bool}
- */
- public mp3: bool = false;
-
- /**
- * Can this device play wav files?
- * @type {bool}
- */
- public wav: bool = false;
-
- /**
- * Can this device play m4a files?
- * @type {bool}
- */
- public m4a: bool = false;
-
- /**
- * Can this device play webm files?
- * @type {bool}
- */
- public webm: bool = false;
-
- // Device
-
- /**
- * Is running on iPhone?
- * @type {bool}
- */
- public iPhone: bool = false;
-
- /**
- * Is running on iPhone4?
- * @type {bool}
- */
- public iPhone4: bool = false;
-
- /**
- * Is running on iPad?
- * @type {bool}
- */
- public iPad: bool = false;
-
- /**
- * PixelRatio of the host device?
- * @type Number
- */
- public pixelRatio: number = 0;
-
- /**
- * Check which OS is game running on.
- * @private
- */
- private _checkOS() {
-
- var ua = navigator.userAgent;
-
- if (/Android/.test(ua))
- {
- this.android = true;
- }
- else if (/CrOS/.test(ua))
- {
- this.chromeOS = true;
- }
- else if (/iP[ao]d|iPhone/i.test(ua))
- {
- this.iOS = true;
- }
- else if (/Linux/.test(ua))
- {
- this.linux = true;
- }
- else if (/Mac OS/.test(ua))
- {
- this.macOS = true;
- }
- else if (/Windows/.test(ua))
- {
- this.windows = true;
- }
-
- if (this.windows || this.macOS || this.linux)
- {
- this.desktop = true;
- }
-
- }
-
- /**
- * Check HTML5 features of the host environment.
- * @private
- */
- private _checkFeatures() {
-
- this.canvas = !!window['CanvasRenderingContext2D'];
-
- try
- {
- this.localStorage = !!localStorage.getItem;
- }
- catch (error)
- {
- this.localStorage = false;
- }
-
- this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob'];
- this.fileSystem = !!window['requestFileSystem'];
- this.webGL = !!window['WebGLRenderingContext'];
- this.worker = !!window['Worker'];
-
- if ('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled)
- {
- this.touch = true;
- }
-
- if (window.navigator.msPointerEnabled)
- {
- this.mspointer = true;
- }
-
- }
-
- /**
- * Check what browser is game running in.
- * @private
- */
- private _checkBrowser() {
-
- var ua = navigator.userAgent;
-
- if (/Arora/.test(ua))
- {
- this.arora = true;
- }
- else if (/Chrome/.test(ua))
- {
- this.chrome = true;
- }
- else if (/Epiphany/.test(ua))
- {
- this.epiphany = true;
- }
- else if (/Firefox/.test(ua))
- {
- this.firefox = true;
- }
- else if (/Mobile Safari/.test(ua))
- {
- this.mobileSafari = true;
- }
- else if (/MSIE (\d+\.\d+);/.test(ua))
- {
- this.ie = true;
- this.ieVersion = parseInt(RegExp.$1);
- }
- else if (/Midori/.test(ua))
- {
- this.midori = true;
- }
- else if (/Opera/.test(ua))
- {
- this.opera = true;
- }
- else if (/Safari/.test(ua))
- {
- this.safari = true;
- }
-
- // WebApp mode in iOS
- if (navigator['standalone'])
- {
- this.webApp = true;
- }
-
- }
-
- public canPlayAudio(type: string): bool {
-
- if (type == 'mp3' && this.mp3)
- {
- return true;
- }
- else if (type == 'ogg' && (this.ogg || this.opus))
- {
- return true;
- }
- else if (type == 'm4a' && this.m4a)
- {
- return true;
- }
- else if (type == 'wav' && this.wav)
- {
- return true;
- }
- else if (type == 'webm' && this.webm)
- {
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Check audio support.
- * @private
- */
- private _checkAudio() {
-
- this.audioData = !!(window['Audio']);
- this.webAudio = !!(window['webkitAudioContext'] || window['AudioContext']);
-
- var audioElement: HTMLAudioElement = document.createElement('audio');
- var result = false;
-
- try
- {
- if (result = !!audioElement.canPlayType)
- {
- if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''))
- {
- this.ogg = true;
- }
-
- if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''))
- {
- this.opus = true;
- }
-
- if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, ''))
- {
- this.mp3 = true;
- }
-
- // Mimetypes accepted:
- // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
- // bit.ly/iphoneoscodecs
- if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ''))
- {
- this.wav = true;
- }
-
- if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, ''))
- {
- this.m4a = true;
- }
-
- if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''))
- {
- this.webm = true;
- }
- }
- } catch (e) { }
-
- }
-
- /**
- * Check PixelRatio of devices.
- * @private
- */
- private _checkDevice() {
-
- this.pixelRatio = window['devicePixelRatio'] || 1;
- this.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') != -1;
- this.iPhone4 = (this.pixelRatio == 2 && this.iPhone);
- this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1;
-
- }
-
- /**
- * Check whether the host environment support 3D CSS.
- * @private
- */
- private _checkCSS3D() {
-
- var el = document.createElement('p');
- var has3d;
- var transforms = {
- 'webkitTransform': '-webkit-transform',
- 'OTransform': '-o-transform',
- 'msTransform': '-ms-transform',
- 'MozTransform': '-moz-transform',
- 'transform': 'transform'
- };
-
- // Add it to the body to get the computed style.
- document.body.insertBefore(el, null);
-
- for (var t in transforms)
- {
- if (el.style[t] !== undefined)
- {
- el.style[t] = "translate3d(1px,1px,1px)";
- has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
- }
- }
-
- document.body.removeChild(el);
-
- this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none");
-
- }
-
- public isConsoleOpen(): bool {
-
- if (window.console && window.console['firebug'])
- {
- return true;
- }
-
- if (window.console)
- {
- console.profile();
- console.profileEnd();
-
- if (console.clear) console.clear();
-
- return console['profiles'].length > 0;
- }
-
- return false;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/system/RequestAnimationFrame.ts b/wip/TS Source/system/RequestAnimationFrame.ts
deleted file mode 100644
index 3fa64929..00000000
--- a/wip/TS Source/system/RequestAnimationFrame.ts
+++ /dev/null
@@ -1,185 +0,0 @@
-///
-
-/**
-* Phaser - RequestAnimationFrame
-*
-* Abstracts away the use of RAF or setTimeOut for the core game update loop. The callback can be re-mapped on the fly.
-*/
-
-module Phaser {
-
- export class RequestAnimationFrame {
-
- /**
- * Constructor
- * @param {Any} callback
- * @return {RequestAnimationFrame} This object.
- */
- constructor(game: Phaser.Game, callback) {
-
- this.game = game;
- this.callback = callback;
-
- var vendors = ['ms', 'moz', 'webkit', 'o'];
-
- for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++)
- {
- window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
- window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
- }
-
- this.start();
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * The function to be called each frame. Will be called in the context of _game
- * @property callback
- * @type Any
- **/
- public callback;
-
- /**
- *
- * @property _timeOutID
- * @type Any
- * @private
- **/
- private _timeOutID;
-
- /**
- *
- * @property _isSetTimeOut
- * @type bool
- * @private
- **/
- private _isSetTimeOut: bool = false;
-
- /**
- *
- * @method usingSetTimeOut
- * @return bool
- **/
- public isUsingSetTimeOut(): bool {
-
- return this._isSetTimeOut;
-
- }
-
- /**
- *
- * @method usingRAF
- * @return bool
- **/
- public isUsingRAF(): bool {
-
- return this._isSetTimeOut === true;
-
- }
-
- /**
- *
- * @property isRunning
- * @type bool
- **/
- public isRunning: bool = false;
-
- /**
- * A reference to the RAF/setTimeout to avoid constant anonymous function creation
- */
- public _onLoop;
-
- /**
- * Starts the requestAnimatioFrame running or setTimeout if unavailable in browser
- * @method start
- * @param {Any} [callback]
- **/
- public start(callback = null) {
-
- if (callback)
- {
- this.callback = callback;
- }
-
- if (!window.requestAnimationFrame)
- {
- this._isSetTimeOut = true;
- this._onLoop = () => this.SetTimeoutUpdate();
- this._timeOutID = window.setTimeout(this._onLoop, 0);
- }
- else
- {
- this._isSetTimeOut = false;
- this._onLoop = () => this.RAFUpdate(0);
- window.requestAnimationFrame(this._onLoop);
- }
-
- this.isRunning = true;
-
- }
-
- /**
- * Stops the requestAnimationFrame from running
- * @method stop
- **/
- public stop() {
-
- if (this._isSetTimeOut)
- {
- clearTimeout(this._timeOutID);
- }
- else
- {
- window.cancelAnimationFrame;
- }
-
- this.isRunning = false;
-
- }
-
- /**
- * The update method for the requestAnimationFrame
- * @method RAFUpdate
- **/
- public RAFUpdate(time: number) {
-
- this.game.time.update(time);
-
- if (this.callback)
- {
- this.callback.call(this.game);
- }
-
- this._onLoop = (time) => this.RAFUpdate(time);
-
- window.requestAnimationFrame(this._onLoop);
-
- }
-
- /**
- * The update method for the setTimeout
- * @method SetTimeoutUpdate
- **/
- public SetTimeoutUpdate() {
-
- this.game.time.update(Date.now());
-
- this._onLoop = () => this.SetTimeoutUpdate();
-
- this._timeOutID = window.setTimeout(this._onLoop, 16);
-
- if (this.callback)
- {
- this.callback.call(this.game);
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/system/StageScaleMode.ts b/wip/TS Source/system/StageScaleMode.ts
deleted file mode 100644
index c2a968a4..00000000
--- a/wip/TS Source/system/StageScaleMode.ts
+++ /dev/null
@@ -1,536 +0,0 @@
-///
-
-/**
-* Phaser - StageScaleMode
-*
-* This class controls the scaling of your game. On mobile devices it will also remove the URL bar and allow
-* you to maintain proportion and aspect ratio.
-* The resizing method is based on a technique taken from Viewporter v2.0 by Zynga Inc. http://github.com/zynga/viewporter
-*/
-
-module Phaser {
-
- export class StageScaleMode {
-
- /**
- * StageScaleMode constructor
- */
- constructor(game: Phaser.Game, width: number, height: number) {
-
- this.game = game;
-
- this.enterLandscape = new Phaser.Signal;
- this.enterPortrait = new Phaser.Signal;
-
- if (window['orientation'])
- {
- this.orientation = window['orientation'];
- }
- else
- {
- if (window.outerWidth > window.outerHeight)
- {
- this.orientation = 90;
- }
- else
- {
- this.orientation = 0;
- }
- }
-
- this.scaleFactor = new Phaser.Vec2(1, 1);
- this.aspectRatio = 0;
- this.minWidth = width;
- this.minHeight = height;
- this.maxWidth = width;
- this.maxHeight = height;
-
- window.addEventListener('orientationchange', (event) => this.checkOrientation(event), false);
- window.addEventListener('resize', (event) => this.checkResize(event), false);
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Stage height when start the game.
- * @type {number}
- */
- private _startHeight: number = 0;
- private _iterations: number;
- private _check;
-
- /**
- * Specifies that the game be visible in the specified area without trying to preserve the original aspect ratio.
- * @type {number}
- */
- public static EXACT_FIT: number = 0;
-
- /**
- * Specifies that the size of the game be fixed, so that it remains unchanged even if the size of the window changes.
- * @type {number}
- */
- public static NO_SCALE: number = 1;
-
- /**
- * Specifies that the entire game be visible in the specified area without distortion while maintaining the original aspect ratio.
- * @type {number}
- */
- public static SHOW_ALL: number = 2;
-
- /**
- * If the game should be forced to use Landscape mode, this is set to true by Game.Stage
- * @type {bool}
- */
- public forceLandscape: bool = false;
-
- /**
- * If the game should be forced to use Portrait mode, this is set to true by Game.Stage
- * @type {bool}
- */
- public forcePortrait: bool = false;
-
- /**
- * If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.
- * @type {bool}
- */
- public incorrectOrientation: bool = false;
-
- /**
- * If you wish to align your game in the middle of the page then you can set this value to true.
- * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
- * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
- * @type {bool}
- */
- public pageAlignHorizontally: bool = false;
-
- /**
- * If you wish to align your game in the middle of the page then you can set this value to true.
- * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
- * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
- * @type {bool}
- */
- public pageAlignVeritcally: bool = false;
-
- /**
- * Minimum width the canvas should be scaled to (in pixels)
- * @type {number}
- */
- public minWidth: number = null;
-
- /**
- * Maximum width the canvas should be scaled to (in pixels).
- * If null it will scale to whatever width the browser can handle.
- * @type {number}
- */
- public maxWidth: number = null;
-
- /**
- * Minimum height the canvas should be scaled to (in pixels)
- * @type {number}
- */
- public minHeight: number = null;
-
- /**
- * Maximum height the canvas should be scaled to (in pixels).
- * If null it will scale to whatever height the browser can handle.
- * @type {number}
- */
- public maxHeight: number = null;
-
- /**
- * Width of the stage after calculation.
- * @type {number}
- */
- public width: number = 0;
-
- /**
- * Height of the stage after calculation.
- * @type {number}
- */
- public height: number = 0;
-
- /**
- * Asperct ratio of the scaled game size (width / height)
- * @type {number}
- */
- public aspectRatio: number;
-
- /**
- * The maximum number of times it will try to resize the canvas to fill the browser (default is 5)
- * @type {number}
- */
- public maxIterations: number = 5;
-
- /**
- * The scale factor of the scaled game width
- * @type {Vec2}
- */
- public scaleFactor: Phaser.Vec2;
-
- /**
- * Window orientation angle (90 and -90 are landscape, 0 and 80 are portrait)
- * @type {number}
- */
- public orientation: number;
-
- /**
- * A Signal that is dispatched when the device enters landscape orientation from portrait
- * @type {Signal}
- */
- public enterLandscape: Phaser.Signal;
-
- /**
- * A Signal that is dispatched when the device enters portrait orientation from landscape
- * @type {Signal}
- */
- public enterPortrait: Phaser.Signal;
-
- // Full Screen API calls
- public get isFullScreen(): bool {
-
- if (document['fullscreenElement'] === null|| document['mozFullScreenElement'] === null|| document['webkitFullscreenElement'] === null)
- {
- return false;
- }
-
- return true;
-
- }
-
- public startFullScreen() {
-
- if (this.isFullScreen)
- {
- return;
- }
-
- var element = this.game.stage.canvas;
-
- if (element['requestFullScreen'])
- {
- element['requestFullScreen']();
- }
- else if(element['mozRequestFullScreen'])
- {
- element['mozRequestFullScreen']();
- }
- else if (element['webkitRequestFullScreen'])
- {
- element['webkitRequestFullScreen']();
- }
-
- }
-
- public stopFullScreen() {
-
- if (document['cancelFullScreen'])
- {
- document['cancelFullScreen']();
- }
- else if (document['mozCancelFullScreen'])
- {
- document['mozCancelFullScreen']();
- }
- else if (document['webkitCancelFullScreen'])
- {
- document['webkitCancelFullScreen']();
- }
-
- }
-
- /**
- * The core update loop, called by Phaser.Stage
- */
- public update() {
-
- if (this.forceLandscape || this.forcePortrait)
- {
- this.checkOrientationState();
- }
-
- /*
- if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
- {
- this.refresh();
- }
-
- if (this.forceLandscape || this.forcePortrait)
- {
- this.checkOrientationState();
- }
- */
-
- }
-
- private checkOrientationState() {
-
- // They are in the wrong orientation
- if (this.incorrectOrientation)
- {
- if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth))
- {
- // Back to normal
- this.game.paused = false;
- this.incorrectOrientation = false;
- this.refresh();
- }
- }
- else
- {
- if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth))
- {
- // Show orientation screen
- this.game.paused = true;
- this.incorrectOrientation = true;
- this.refresh();
- }
- }
-
- }
-
- public get isPortrait(): bool {
- return this.orientation == 0 || this.orientation == 180;
- }
-
- public get isLandscape(): bool {
- return this.orientation === 90 || this.orientation === -90;
- }
-
- /**
- * Handle window.orientationchange events
- */
- private checkOrientation(event) {
-
- this.orientation = window['orientation'];
-
- if (this.isLandscape)
- {
- this.enterLandscape.dispatch(this.orientation, true, false);
- }
- else
- {
- this.enterPortrait.dispatch(this.orientation, false, true);
- }
-
- if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE)
- {
- this.refresh();
- }
-
- }
-
- /**
- * Handle window.resize events
- */
- private checkResize(event) {
-
- if (window.outerWidth > window.outerHeight)
- {
- this.orientation = 90;
- }
- else
- {
- this.orientation = 0;
- }
-
- if (this.isLandscape)
- {
- this.enterLandscape.dispatch(this.orientation, true, false);
- }
- else
- {
- this.enterPortrait.dispatch(this.orientation, false, true);
- }
-
- if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE)
- {
- this.refresh();
- }
-
- }
-
- /**
- * Re-calculate scale mode and update screen size.
- */
- private refresh() {
-
- // We can't do anything about the status bars in iPads, web apps or desktops
- if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false)
- {
- document.documentElement['style'].minHeight = '2000px';
-
- this._startHeight = window.innerHeight;
-
- if (this.game.device.android && this.game.device.chrome == false)
- {
- window.scrollTo(0, 1);
- }
- else
- {
- window.scrollTo(0, 0);
- }
- }
-
- if (this._check == null && this.maxIterations > 0)
- {
- this._iterations = this.maxIterations;
- this._check = window.setInterval(() => this.setScreenSize(), 10);
- this.setScreenSize();
- }
-
- }
-
- /**
- * Set screen size automatically based on the scaleMode.
- */
- public setScreenSize(force: bool = false) {
-
- if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false)
- {
- if (this.game.device.android && this.game.device.chrome == false)
- {
- window.scrollTo(0, 1);
- }
- else
- {
- window.scrollTo(0, 0);
- }
- }
-
- this._iterations--;
-
- if (force || window.innerHeight > this._startHeight || this._iterations < 0)
- {
- // Set minimum height of content to new window height
- document.documentElement['style'].minHeight = window.innerHeight + 'px';
-
- if (this.incorrectOrientation == true)
- {
- this.setMaximum();
- }
- else if (this.game.stage.scaleMode == StageScaleMode.EXACT_FIT)
- {
- this.setExactFit();
- }
- else if (this.game.stage.scaleMode == StageScaleMode.SHOW_ALL)
- {
- this.setShowAll();
- }
-
- this.setSize();
-
- clearInterval(this._check);
-
- this._check = null;
-
- }
-
- }
-
- private setSize() {
-
- if (this.incorrectOrientation == false)
- {
- if (this.maxWidth && this.width > this.maxWidth)
- {
- this.width = this.maxWidth;
- }
-
- if (this.maxHeight && this.height > this.maxHeight)
- {
- this.height = this.maxHeight;
- }
-
- if (this.minWidth && this.width < this.minWidth)
- {
- this.width = this.minWidth;
- }
-
- if (this.minHeight && this.height < this.minHeight)
- {
- this.height = this.minHeight;
- }
- }
-
- this.game.stage.canvas.style.width = this.width + 'px';
- this.game.stage.canvas.style.height = this.height + 'px';
-
- this.game.input.scale.setTo(this.game.stage.width / this.width, this.game.stage.height / this.height);
-
- if (this.pageAlignHorizontally)
- {
- if (this.width < window.innerWidth && this.incorrectOrientation == false)
- {
- this.game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px';
- }
- else
- {
- this.game.stage.canvas.style.marginLeft = '0px';
- }
- }
-
- if (this.pageAlignVeritcally)
- {
- if (this.height < window.innerHeight && this.incorrectOrientation == false)
- {
- this.game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px';
- }
- else
- {
- this.game.stage.canvas.style.marginTop = '0px';
- }
- }
-
- this.game.stage.getOffset(this.game.stage.canvas);
-
- this.aspectRatio = this.width / this.height;
- this.scaleFactor.x = this.game.stage.width / this.width;
- this.scaleFactor.y = this.game.stage.height / this.height;
-
- }
-
- private setMaximum() {
-
- this.width = window.innerWidth;
- this.height = window.innerHeight;
-
- }
-
- private setShowAll() {
-
- var multiplier = Math.min((window.innerHeight / this.game.stage.height), (window.innerWidth / this.game.stage.width));
-
- this.width = Math.round(this.game.stage.width * multiplier);
- this.height = Math.round(this.game.stage.height * multiplier);
-
- }
-
- private setExactFit() {
-
- if (this.maxWidth && window.innerWidth > this.maxWidth)
- {
- this.width = this.maxWidth;
- }
- else
- {
- this.width = window.innerWidth;
- }
-
- if (this.maxHeight && window.innerHeight > this.maxHeight)
- {
- this.height = this.maxHeight;
- }
- else
- {
- this.height = window.innerHeight;
- }
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/system/screens/BootScreen.ts b/wip/TS Source/system/screens/BootScreen.ts
deleted file mode 100644
index 559347c3..00000000
--- a/wip/TS Source/system/screens/BootScreen.ts
+++ /dev/null
@@ -1,131 +0,0 @@
-///
-
-/**
-* Phaser - BootScreen
-*
-* The BootScreen is displayed when Phaser is started without any default functions or State
-*/
-
-module Phaser {
-
- export class BootScreen {
-
- /**
- * BootScreen constructor
- * Create a new BootScreen with specific width and height.
- *
- * @param width {number} Screen canvas width.
- * @param height {number} Screen canvas height.
- */
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- this._logo = new Image();
- this._logo.src = this._logoData;
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Engine logo.
- */
- private _logo;
-
- /**
- * Engine logo image data.
- */
- private _logoData: string = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGgAAAAZCAYAAADdYmvFAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAstJREFUeNrsWlFuwjAMbavdZGcAcRm4AXzvCPuGG8BlEJxhZ+l4TJ48z3actGGthqUI1MaO/V6cmIT2/fW10eTt46NvKshtvDZlG31yfOL9a/ldU6x4IZ0GQs0gS217enMkJYr5ixXkYrFoVqtV1kDn8/n+KfXw/Hq9Nin7h8MhScB2u3Xtav2ivsNWrh7XLcWMYqA4eUZ1kj0MAifHJEeKFojWzyIH+rL/0Cwif2AX9nN1oQOgrTg8XcTFx+ScdEOJ4WBxXQ1EjRyrn0cOzzQLzFyQSQcgw/5Qkkr0JVEQpNIdhL4vm4DL5fLulNTHcy6Uxl4/6iMLiePx2KzX6/v30+n0aynUlrnSeNq2/VN9bgM4dFPdNPmsJnIg/PuQbJmLdFN3UNu0SzbyJ0GOWJVWZE/QMkY+owrqXxGEdZA37BVyX6lJTipT6J1lf7fbqc+xh8nYeIvikatP+PGW0nEJ4jOydHYOIcfKnmgWoZDQSIIeio4Sf1IthYWskCO4vqQ6lFYjl8tl9L1H67PZbMz3VO3t93uVXHofmUjReLyMwHi5eCb3ICwJj5ZU9nCg+SzUgPYyif+2epTk4pkkyDp+eXTlZu2BkUybEkklePZfK9lPuTnc07vbmt1bYulHBeNQgx18SsH4ni/cV2rSLtqNDNUH2JQ2SsXS57Y9PHlfumkwCdICt5rnkNdPjpMiIEWgRlAJSdF4SvCQMWj+VyfI0h8D/EgWSYKiJKXi8VrOhJUxaFiFCOKKUJAtR78k9eX4USLHXqLGXOIiWUT4Vj9JiP4W0io3VDz8AJXblNWQrOimLjIGy/9uLICH6mrVmFbxEFHauzmc0fGJJmPg/v+6D0oB7N2bj0FsNHtSWTQniWTR931QlHXvasDTHXLjqY0/1/8hSDxACD+lAGH8dKQbQk5N3TFtzDmLWutvV0+pL5FVoHvCNG35FGAAayS4KUoKC9QAAAAASUVORK5CYII=";
-
- /**
- * Background gradient effect color 1.
- */
- private _color1 = { r: 20, g: 20, b: 20 };
-
- /**
- * Background gradient effect color 2.
- */
- private _color2 = { r: 200, g: 200, b: 200 };
-
- /**
- * Fade effect tween.
- * @type {Phaser.Tween}
- */
- private _fade: Phaser.Tween = null;
-
- /**
- * Update color and fade.
- */
- public update() {
-
- if (this._fade == null)
- {
- this.colorCycle();
- }
-
- this._color1.r = Math.round(this._color1.r);
- this._color1.g = Math.round(this._color1.g);
- this._color1.b = Math.round(this._color1.b);
- this._color2.r = Math.round(this._color2.r);
- this._color2.g = Math.round(this._color2.g);
- this._color2.b = Math.round(this._color2.b);
-
- }
-
- /**
- * Render BootScreen.
- */
- public render() {
-
- var grd = this.game.stage.context.createLinearGradient(0, 0, 0, this.game.stage.height);
- grd.addColorStop(0, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')');
- grd.addColorStop(0.5, 'rgb(' + this._color2.r + ', ' + this._color2.g + ', ' + this._color2.b + ')');
- grd.addColorStop(1, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')');
- this.game.stage.context.fillStyle = grd;
- this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height);
-
- this.game.stage.context.shadowOffsetX = 0;
- this.game.stage.context.shadowOffsetY = 0;
-
- if (this._logo)
- {
- this.game.stage.context.drawImage(this._logo, 32, 32);
- }
-
- this.game.stage.context.shadowColor = 'rgb(0,0,0)';
- this.game.stage.context.shadowOffsetX = 1;
- this.game.stage.context.shadowOffsetY = 1;
- this.game.stage.context.shadowBlur = 0;
- this.game.stage.context.fillStyle = 'rgb(255,255,255)';
- this.game.stage.context.font = 'bold 18px Arial';
- this.game.stage.context.textBaseline = 'top';
- this.game.stage.context.fillText(Phaser.VERSION, 32, 64+32);
- this.game.stage.context.fillText('Game Size: ' + this.game.stage.width + ' x ' + this.game.stage.height, 32, 64+64);
- this.game.stage.context.fillText('www.photonstorm.com', 32, 64+96);
- this.game.stage.context.font = '16px Arial';
- this.game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64+160);
- this.game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64+184);
-
- }
-
- /**
- * Start color fading cycle.
- */
- private colorCycle() {
-
- this._fade = this.game.add.tween(this._color2);
-
- this._fade.to({ r: Math.random() * 250, g: Math.random() * 250, b: Math.random() * 250 }, 3000, Phaser.Easing.Linear.None);
- this._fade.onComplete.add(this.colorCycle, this);
- this._fade.start();
-
- }
-
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/system/screens/OrientationScreen.ts b/wip/TS Source/system/screens/OrientationScreen.ts
deleted file mode 100644
index 1a3ea3a0..00000000
--- a/wip/TS Source/system/screens/OrientationScreen.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-///
-
-/**
-* Phaser - OrientationScreen
-*
-* The Orientation Screen is displayed whenever the device is turned to an unsupported orientation.
-*/
-
-module Phaser {
-
- export class OrientationScreen {
-
- /**
- * OrientationScreen constructor
- * Create a new OrientationScreen.
- */
- constructor(game: Phaser.Game) {
- this.game = game;
- }
-
- private _enabled: bool = false;
-
- /**
- * Local reference to game.
- */
- public game: Phaser.Game;
-
- /**
- * The image to be displayed when the device is rotated to an unsupported orientation.
- * Set this to be the key of an image previously loaded into the Game.Cache.
- * @type {Cache Reference}
- */
- public image;
-
- /**
- * Enable the orientation screen. An image that is displayed whenever the device enters an unsupported orientation.
- * Set this to be the key of an image previously loaded into the Game.Cache.
- * @type {Cache Reference}
- */
- public enable(imageKey: string) {
-
- this._enabled = true;
- this.image = this.game.cache.getImage(imageKey);
-
- }
-
- /**
- * Update (can be overridden)
- */
- public update() {
- }
-
- /**
- * Render
- */
- public render() {
-
- if (this._enabled)
- {
- this.game.stage.context.drawImage(this.image, 0, 0, this.image.width, this.image.height, 0, 0, this.game.stage.width, this.game.stage.height);
- }
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/system/screens/PauseScreen.ts b/wip/TS Source/system/screens/PauseScreen.ts
deleted file mode 100644
index a2e615ca..00000000
--- a/wip/TS Source/system/screens/PauseScreen.ts
+++ /dev/null
@@ -1,143 +0,0 @@
-///
-
-/**
-* Phaser - PauseScreen
-*
-* The PauseScreen is displayed whenever the game loses focus or the player switches to another browser tab.
-*/
-
-module Phaser {
-
- export class PauseScreen {
-
- /**
- * PauseScreen constructor
- * Create a new PauseScreen with specific width and height.
- *
- * @param width {number} Screen canvas width.
- * @param height {number} Screen canvas height.
- */
- constructor(game: Phaser.Game, width: number, height: number) {
-
- this.game = game;
- this._canvas = document.createElement('canvas');
- this._canvas.width = width;
- this._canvas.height = height;
- this._context = this._canvas.getContext('2d');
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Canvas element used by engine.
- * @type {HTMLCanvasElement}
- */
- private _canvas: HTMLCanvasElement;
-
- /**
- * Render context of stage's canvas.
- * @type {CanvasRenderingContext2D}
- */
- private _context: CanvasRenderingContext2D;
-
- /**
- * Background color.
- */
- private _color;
-
- /**
- * Fade effect tween.
- * @type {Phaser.Tween}
- */
- private _fade: Phaser.Tween;
-
- /**
- * Called when the game enters pause mode.
- */
- public onPaused() {
-
- // Take a grab of the current canvas to our temporary one
- this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
- this._context.drawImage(this.game.stage.canvas, 0, 0);
- this._color = { r: 255, g: 255, b: 255 };
- this.fadeOut();
-
- }
-
- /**
- * Called when the game resume from pause mode.
- */
- public onResume() {
- this._fade.stop();
- this.game.tweens.remove(this._fade);
- }
-
- /**
- * Update background color.
- */
- public update() {
- this._color.r = Math.round(this._color.r);
- this._color.g = Math.round(this._color.g);
- this._color.b = Math.round(this._color.b);
- }
-
- /**
- * Render PauseScreen.
- */
- public render() {
-
- this.game.stage.context.drawImage(this._canvas, 0, 0);
-
- this.game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)';
- this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height);
-
- // Draw a 'play' arrow
- var arrowWidth = Math.round(this.game.stage.width / 2);
- var arrowHeight = Math.round(this.game.stage.height / 2);
-
- var sx = this.game.stage.centerX - arrowWidth / 2;
- var sy = this.game.stage.centerY - arrowHeight / 2;
-
- this.game.stage.context.beginPath();
- this.game.stage.context.moveTo(sx, sy);
- this.game.stage.context.lineTo(sx, sy + arrowHeight);
- this.game.stage.context.lineTo(sx + arrowWidth, this.game.stage.centerY);
- this.game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)';
- this.game.stage.context.fill();
- this.game.stage.context.closePath();
-
- }
-
- /**
- * Start fadeOut effect.
- */
- private fadeOut() {
-
- this._fade = this.game.add.tween(this._color);
-
- this._fade.to({ r: 50, g: 50, b: 50 }, 1000, Phaser.Easing.Linear.None);
- this._fade.onComplete.add(this.fadeIn, this);
- this._fade.start();
-
- }
-
- /**
- * Start fadeIn effect.
- */
- private fadeIn() {
-
- this._fade = this.game.add.tween(this._color);
-
- this._fade.to({ r: 255, g: 255, b: 255 }, 1000, Phaser.Easing.Linear.None);
- this._fade.onComplete.add(this.fadeOut, this);
- this._fade.start();
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tilemap/Tile.ts b/wip/TS Source/tilemap/Tile.ts
deleted file mode 100644
index ad9085f7..00000000
--- a/wip/TS Source/tilemap/Tile.ts
+++ /dev/null
@@ -1,204 +0,0 @@
-///
-
-/**
-* Phaser - Tile
-*
-* A Tile is a single representation of a tile within a Tilemap
-*/
-
-module Phaser {
-
- export class Tile {
-
- /**
- * Tile constructor
- * Create a new Tile.
- *
- * @param tilemap {Tilemap} the tilemap this tile belongs to.
- * @param index {number} The index of this tile type in the core map data.
- * @param width {number} Width of the tile.
- * @param height number} Height of the tile.
- */
- constructor(game: Phaser.Game, tilemap: Phaser.Tilemap, index: number, width: number, height: number) {
-
- this.game = game;
- this.tilemap = tilemap;
- this.index = index;
-
- this.width = width;
- this.height = height;
- this.allowCollisions = Types.NONE;
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * You can give this Tile a friendly name to help with debugging. Never used internally.
- * @type {string}
- */
- public name: string;
-
- /**
- * The virtual mass of the tile.
- * @type {number}
- */
- public mass: number = 1.0;
-
- /**
- * Tile width.
- * @type {number}
- */
- public width: number;
-
- /**
- * Tile height.
- * @type {number}
- */
- public height: number;
-
- /**
- * Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
- * @type {number}
- */
- public allowCollisions: number;
-
- /**
- * Indicating collide with any object on the left.
- * @type {bool}
- */
- public collideLeft: bool = false;
-
- /**
- * Indicating collide with any object on the right.
- * @type {bool}
- */
- public collideRight: bool = false;
-
- /**
- * Indicating collide with any object on the top.
- * @type {bool}
- */
- public collideUp: bool = false;
-
- /**
- * Indicating collide with any object on the bottom.
- * @type {bool}
- */
- public collideDown: bool = false;
-
- /**
- * Enable separation at x-axis.
- * @type {bool}
- */
- public separateX: bool = true;
-
- /**
- * Enable separation at y-axis.
- * @type {bool}
- */
- public separateY: bool = true;
-
- /**
- * A reference to the tilemap this tile object belongs to.
- * @type {Tilemap}
- */
- public tilemap: Phaser.Tilemap;
-
- /**
- * The index of this tile type in the core map data.
- * For example, if your map only has 16 kinds of tiles in it,
- * this number is usually between 0 and 15.
- * @type {number}
- */
- public index: number;
-
- /**
- * Clean up memory.
- */
- public destroy() {
-
- this.tilemap = null;
-
- }
-
- /**
- * Set collision configs.
- * @param collision {number} Bit field of flags. (see Tile.allowCollision)
- * @param resetCollisions {bool} Reset collision flags before set.
- * @param separateX {bool} Enable seprate at x-axis.
- * @param separateY {bool} Enable seprate at y-axis.
- */
- public setCollision(collision: number, resetCollisions: bool, separateX: bool, separateY: bool) {
-
- if (resetCollisions)
- {
- this.resetCollision();
- }
-
- this.separateX = separateX;
- this.separateY = separateY;
-
- this.allowCollisions = collision;
-
- if (collision & Phaser.Types.ANY)
- {
- this.collideLeft = true;
- this.collideRight = true;
- this.collideUp = true;
- this.collideDown = true;
- return;
- }
-
- if (collision & Phaser.Types.LEFT || collision & Phaser.Types.WALL)
- {
- this.collideLeft = true;
- }
-
- if (collision & Phaser.Types.RIGHT || collision & Phaser.Types.WALL)
- {
- this.collideRight = true;
- }
-
- if (collision & Phaser.Types.UP || collision & Phaser.Types.CEILING)
- {
- this.collideUp = true;
- }
-
- if (collision & Phaser.Types.DOWN || collision & Phaser.Types.CEILING)
- {
- this.collideDown = true;
- }
-
- }
-
- /**
- * Reset collision status flags.
- */
- public resetCollision() {
-
- this.allowCollisions = Phaser.Types.NONE;
- this.collideLeft = false;
- this.collideRight = false;
- this.collideUp = false;
- this.collideDown = false;
-
- }
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {string} a string representation of the object.
- **/
- public toString(): string {
-
- return "[{Tile (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]";
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/tilemap/Tilemap.ts b/wip/TS Source/tilemap/Tilemap.ts
deleted file mode 100644
index 171e1cfa..00000000
--- a/wip/TS Source/tilemap/Tilemap.ts
+++ /dev/null
@@ -1,520 +0,0 @@
-///
-
-/**
-* Phaser - Tilemap
-*
-* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size.
-* Internally it creates a TilemapLayer for each layer in the tilemap.
-*/
-
-module Phaser {
-
- export class Tilemap {
-
- /**
- * Tilemap constructor
- * Create a new Tilemap.
- *
- * @param game {Phaser.Game} Current game instance.
- * @param key {string} Asset key for this map.
- * @param mapData {string} Data of this map. (a big 2d array, normally in csv)
- * @param format {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON.
- * @param resizeWorld {bool} Resize the world bound automatically based on this tilemap?
- * @param tileWidth {number} Width of tiles in this map.
- * @param tileHeight {number} Height of tiles in this map.
- */
- constructor(game: Game, key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth: number = 0, tileHeight: number = 0) {
-
- this.game = game;
- this.type = Phaser.Types.TILEMAP;
-
- this.exists = true;
- this.active = true;
- this.visible = true;
- this.alive = true;
-
- this.z = -1;
- this.group = null;
- this.name = '';
-
- this.texture = new Phaser.Display.Texture(this);
- this.transform = new Phaser.Components.TransformManager(this);
-
- this.tiles = [];
- this.layers = [];
-
- this.mapFormat = format;
-
- switch (format)
- {
- case Tilemap.FORMAT_CSV:
- this.parseCSV(game.cache.getText(mapData), key, tileWidth, tileHeight);
- break;
-
- case Tilemap.FORMAT_TILED_JSON:
- this.parseTiledJSON(game.cache.getText(mapData), key);
- break;
- }
-
- if (this.currentLayer && resizeWorld)
- {
- this.game.world.setSize(this.currentLayer.widthInPixels, this.currentLayer.heightInPixels, true);
- }
-
- }
-
- private _tempCollisionData;
-
- /**
- * Reference to the main game object
- */
- public game: Phaser.Game;
-
- /**
- * The type of game object.
- */
- public type: number;
-
- /**
- * The name of game object.
- */
- public name: string;
-
- /**
- * The Group this Sprite belongs to.
- */
- public group: Group;
-
- /**
- * Controls if both update and render are called by the core game loop.
- */
- public exists: bool;
-
- /**
- * Controls if update() is automatically called by the core game loop.
- */
- public active: bool;
-
- /**
- * Controls if this Sprite is rendered or skipped during the core game loop.
- */
- public visible: bool;
-
- /**
- * A useful state for many game objects. Kill and revive both flip this switch.
- */
- public alive: bool;
-
- /**
- * The texture used to render the Sprite.
- */
- public texture: Phaser.Display.Texture;
-
- /**
- * The Sprite transform component.
- */
- public transform: Phaser.Components.TransformManager;
-
- /**
- * z order value of the object.
- */
- public z: number = -1;
-
- /**
- * Render iteration counter
- */
- public renderOrderID: number = 0;
-
- /**
- * Tilemap data format enum: CSV.
- * @type {number}
- */
- public static FORMAT_CSV: number = 0;
-
- /**
- * Tilemap data format enum: Tiled JSON.
- * @type {number}
- */
- public static FORMAT_TILED_JSON: number = 1;
-
- /**
- * Array contains tile objects of this map.
- * @type {Tile[]}
- */
- public tiles: Phaser.Tile[];
-
- /**
- * Array contains tilemap layer objects of this map.
- * @type {TilemapLayer[]}
- */
- public layers : Phaser.TilemapLayer[];
-
- /**
- * Current tilemap layer.
- * @type {TilemapLayer}
- */
- public currentLayer: Phaser.TilemapLayer;
-
- /**
- * The tilemap layer for collision.
- * @type {TilemapLayer}
- */
- public collisionLayer: Phaser.TilemapLayer;
-
- /**
- * Tilemap collision callback.
- * @type {function}
- */
- public collisionCallback = null;
-
- /**
- * Context for the collision callback called with.
- */
- public collisionCallbackContext;
-
- /**
- * Format of this tilemap data. Available values: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON.
- * @type {number}
- */
- public mapFormat: number;
-
- /**
- * Parset csv map data and generate tiles.
- * @param data {string} CSV map data.
- * @param key {string} Asset key for tileset image.
- * @param tileWidth {number} Width of its tile.
- * @param tileHeight {number} Height of its tile.
- */
- private parseCSV(data: string, key: string, tileWidth: number, tileHeight: number) {
-
- var layer: TilemapLayer = new TilemapLayer(this, 0, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight);
-
- // Trim any rogue whitespace from the data
- data = data.trim();
-
- var rows = data.split("\n");
-
- for (var i = 0; i < rows.length; i++)
- {
- var column = rows[i].split(",");
-
- if (column.length > 0)
- {
- layer.addColumn(column);
- }
- }
-
- layer.updateBounds();
-
- var tileQuantity = layer.parseTileOffsets();
-
- this.currentLayer = layer;
- this.collisionLayer = layer;
-
- this.layers.push(layer);
-
- this.generateTiles(tileQuantity);
-
- }
-
- /**
- * Parse JSON map data and generate tiles.
- * @param data {string} JSON map data.
- * @param key {string} Asset key for tileset image.
- */
- private parseTiledJSON(data: string, key: string) {
-
- // Trim any rogue whitespace from the data
- data = data.trim();
-
- var json = JSON.parse(data);
-
- for (var i = 0; i < json.layers.length; i++)
- {
- var layer: TilemapLayer = new TilemapLayer(this, i, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight);
-
- // Check it's a data layer
- if (!json.layers[i].data)
- {
- continue;
- }
-
- layer.alpha = json.layers[i].opacity;
- layer.visible = json.layers[i].visible;
- layer.tileMargin = json.tilesets[0].margin;
- layer.tileSpacing = json.tilesets[0].spacing;
-
- var c = 0;
- var row;
-
- for (var t = 0; t < json.layers[i].data.length; t++)
- {
- if (c == 0)
- {
- row = [];
- }
-
- row.push(json.layers[i].data[t]);
-
- c++;
-
- if (c == json.layers[i].width)
- {
- layer.addColumn(row);
- c = 0;
- }
- }
-
- layer.updateBounds();
-
- var tileQuantity = layer.parseTileOffsets();
-
- this.currentLayer = layer;
- this.collisionLayer = layer;
-
- this.layers.push(layer);
-
- }
-
- this.generateTiles(tileQuantity);
-
- }
-
- /**
- * Create tiles of given quantity.
- * @param qty {number} Quentity of tiles to be generated.
- */
- private generateTiles(qty:number) {
-
- for (var i = 0; i < qty; i++)
- {
- this.tiles.push(new Phaser.Tile(this.game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight));
- }
-
- }
-
- public get widthInPixels(): number {
- return this.currentLayer.widthInPixels;
- }
-
- public get heightInPixels(): number {
- return this.currentLayer.heightInPixels;
- }
-
- // Tile Collision
-
- /**
- * Set callback to be called when this tilemap collides.
- * @param context {object} Callback will be called with this context.
- * @param callback {function} Callback function.
- */
- public setCollisionCallback(context, callback) {
-
- this.collisionCallbackContext = context;
- this.collisionCallback = callback;
-
- }
-
- /**
- * Set collision configs of tiles in a range index.
- * @param start {number} First index of tiles.
- * @param end {number} Last index of tiles.
- * @param collision {number} Bit field of flags. (see Tile.allowCollision)
- * @param resetCollisions {bool} Reset collision flags before set.
- * @param separateX {bool} Enable seprate at x-axis.
- * @param separateY {bool} Enable seprate at y-axis.
- */
- public setCollisionRange(start: number, end: number, collision:number = Types.ANY, resetCollisions: bool = false, separateX: bool = true, separateY: bool = true) {
-
- for (var i = start; i < end; i++)
- {
- this.tiles[i].setCollision(collision, resetCollisions, separateX, separateY);
- }
-
- }
-
- /**
- * Set collision configs of tiles with given index.
- * @param values {number[]} Index array which contains all tile indexes. The tiles with those indexes will be setup with rest parameters.
- * @param collision {number} Bit field of flags. (see Tile.allowCollision)
- * @param resetCollisions {bool} Reset collision flags before set.
- * @param separateX {bool} Enable seprate at x-axis.
- * @param separateY {bool} Enable seprate at y-axis.
- */
- public setCollisionByIndex(values:number[], collision:number = Types.ANY, resetCollisions: bool = false, separateX: bool = true, separateY: bool = true) {
-
- for (var i = 0; i < values.length; i++)
- {
- this.tiles[values[i]].setCollision(collision, resetCollisions, separateX, separateY);
- }
-
- }
-
- // Tile Management
-
- /**
- * Get the tile by its index.
- * @param value {number} Index of the tile you want to get.
- * @return {Tile} The tile with given index.
- */
- public getTileByIndex(value: number): Phaser.Tile {
-
- if (this.tiles[value])
- {
- return this.tiles[value];
- }
-
- return null;
-
- }
-
- /**
- * Get the tile located at specific position and layer.
- * @param x {number} X position of this tile located.
- * @param y {number} Y position of this tile located.
- * @param [layer] {number} layer of this tile located.
- * @return {Tile} The tile with specific properties.
- */
- public getTile(x: number, y: number, layer: number = this.currentLayer.ID): Phaser.Tile {
-
- return this.tiles[this.layers[layer].getTileIndex(x, y)];
-
- }
-
- /**
- * Get the tile located at specific position (in world coordinate) and layer. (thus you give a position of a point which is within the tile)
- * @param x {number} X position of the point in target tile.
- * @param x {number} Y position of the point in target tile.
- * @param [layer] {number} layer of this tile located.
- * @return {Tile} The tile with specific properties.
- */
- public getTileFromWorldXY(x: number, y: number, layer: number = this.currentLayer.ID): Phaser.Tile {
-
- return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)];
-
- }
-
- /**
- * Gets the tile underneath the Input.x/y position
- * @param layer The layer to check, defaults to 0
- * @returns {Tile}
- */
- public getTileFromInputXY(layer: number = this.currentLayer.ID): Phaser.Tile {
-
- return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)];
-
- }
-
- /**
- * Get tiles overlaps the given object.
- * @param object {GameObject} Tiles you want to get that overlaps this.
- * @return {array} Array with tiles information. (Each contains x, y and the tile.)
- */
- public getTileOverlaps(object: Phaser.Sprite) {
-
- return this.currentLayer.getTileOverlaps(object);
-
- }
-
- // COLLIDE
- /**
- * Check whether this tilemap collides with the given game object or group of objects.
- * @param objectOrGroup {function} Target object of group you want to check.
- * @param callback {function} This is called if objectOrGroup collides the tilemap.
- * @param context {object} Callback will be called with this context.
- * @return {bool} Return true if this collides with given object, otherwise return false.
- */
- public collide(objectOrGroup = null, callback = null, context = null) {
-
- if (callback !== null && context !== null)
- {
- this.collisionCallback = callback;
- this.collisionCallbackContext = context;
- }
-
- if (objectOrGroup == null)
- {
- objectOrGroup = this.game.world.group;
- }
-
- // Group?
- if (objectOrGroup.isGroup == false)
- {
- this.collideGameObject(objectOrGroup);
- }
- else
- {
- objectOrGroup.forEachAlive(this, this.collideGameObject, true);
- }
-
- }
-
- /**
- * Check whether this tilemap collides with the given game object.
- * @param object {GameObject} Target object you want to check.
- * @return {bool} Return true if this collides with given object, otherwise return false.
- */
- public collideGameObject(object: Phaser.Sprite): bool {
-
- if (object.body.type == Types.BODY_DYNAMIC && object.exists == true && object.body.allowCollisions != Types.NONE)
- {
- this._tempCollisionData = this.collisionLayer.getTileOverlaps(object);
-
- if (this.collisionCallback !== null && this._tempCollisionData.length > 0)
- {
- this.collisionCallback.call(this.collisionCallbackContext, object, this._tempCollisionData);
- }
-
- return true;
- }
- else
- {
- return false;
- }
-
- }
-
- /**
- * Set a tile to a specific layer.
- * @param x {number} X position of this tile.
- * @param y {number} Y position of this tile.
- * @param index {number} The index of this tile type in the core map data.
- * @param [layer] {number} which layer you want to set the tile to.
- */
- public putTile(x: number, y: number, index: number, layer: number = this.currentLayer.ID) {
-
- this.layers[layer].putTile(x, y, index);
-
- }
-
- /**
- * Can be over-ridden if required
- */
- public preUpdate() {
- }
-
- /**
- * Can be over-ridden if required
- */
- public update() {
- }
-
- /**
- * Can be over-ridden if required
- */
- public postUpdate() {
- }
-
- public destroy() {
-
- this.texture = null;
- this.transform = null;
-
- this.tiles.length = 0;
- this.layers.length = 0;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/tilemap/TilemapLayer.ts b/wip/TS Source/tilemap/TilemapLayer.ts
deleted file mode 100644
index 871f2fee..00000000
--- a/wip/TS Source/tilemap/TilemapLayer.ts
+++ /dev/null
@@ -1,544 +0,0 @@
-///
-
-/**
-* Phaser - TilemapLayer
-*
-* A Tilemap Layer. Tiled format maps can have multiple overlapping layers.
-*/
-
-module Phaser {
-
- export class TilemapLayer {
-
- /**
- * TilemapLayer constructor
- * Create a new TilemapLayer.
- *
- * @param parent {Tilemap} The tilemap that contains this layer.
- * @param id {number} The ID of this layer within the Tilemap array.
- * @param key {string} Asset key for this map.
- * @param mapFormat {number} Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON.
- * @param name {string} Name of this layer, so you can get this layer by its name.
- * @param tileWidth {number} Width of tiles in this map.
- * @param tileHeight {number} Height of tiles in this map.
- */
- constructor(parent: Phaser.Tilemap, id:number, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) {
-
- this.parent = parent;
- this.game = parent.game;
-
- this.ID = id;
- this.name = name;
- this.mapFormat = mapFormat;
- this.tileWidth = tileWidth;
- this.tileHeight = tileHeight;
- this.boundsInTiles = new Rectangle();
-
- this.texture = new Phaser.Display.Texture(this);
- this.transform = new Phaser.Components.TransformManager(this);
-
- if (key !== null)
- {
- this.texture.loadImage(key, false);
- }
- else
- {
- this.texture.opaque = true;
- }
-
- // Handy proxies
- this.alpha = this.texture.alpha;
-
- this.mapData = [];
- this._tempTileBlock = [];
-
- }
-
- // Private vars to help avoid gc spikes
- private _tempTileX: number;
- private _tempTileY: number;
- private _tempTileW: number;
- private _tempTileH: number;
- private _tempTileBlock;
- private _tempBlockResults;
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * The tilemap that contains this layer.
- * @type {Tilemap}
- */
- public parent: Phaser.Tilemap;
-
- /**
- * The texture used to render the Sprite.
- */
- public texture: Phaser.Display.Texture;
-
- /**
- * The Sprite transform component.
- */
- public transform: Phaser.Components.TransformManager;
-
- public tileOffsets;
-
- /**
- * The alpha of the Sprite between 0 and 1, a value of 1 being fully opaque.
- */
- public alpha: number;
-
- /**
- * Name of this layer, so you can get this layer by its name.
- * @type {string}
- */
- public name: string;
-
- /**
- * The ID of the layer within the Tilemap.
- * @type {number}
- */
- public ID: number;
-
- /**
- * Controls whether update() and draw() are automatically called.
- * @type {bool}
- */
- public exists: bool = true;
-
- /**
- * Controls whether draw() are automatically called.
- * @type {bool}
- */
- public visible: bool = true;
-
- /**
- * Properties of this map layer. (normally set by map editors)
- */
- public properties: {};
-
- /**
- * Map data in a 2d array, its element is a index number for that tile.
- * @type {number[][]}
- */
- public mapData;
-
- /**
- * Format of this map data, available: Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON.
- */
- public mapFormat: number;
-
- /**
- * Map bounds (width and height) in tiles not pixels.
- * @type {Rectangle}
- */
- public boundsInTiles: Phaser.Rectangle;
-
- /**
- * Width of each tile.
- * @type {number}
- */
- public tileWidth: number;
-
- /**
- * Height of a single tile.
- * @type {number}
- */
- public tileHeight: number;
-
- /**
- * How many tiles in each row.
- * Read-only variable, do NOT recommend changing after the map is loaded!
- * @type {number}
- */
- public widthInTiles: number = 0;
-
- /**
- * How many tiles in each column.
- * Read-only variable, do NOT recommend changing after the map is loaded!
- * @type {number}
- */
- public heightInTiles: number = 0;
-
- /**
- * Read-only variable, do NOT recommend changing after the map is loaded!
- * @type {number}
- */
- public widthInPixels: number = 0;
-
- /**
- * Read-only variable, do NOT recommend changing after the map is loaded!
- * @type {number}
- */
- public heightInPixels: number = 0;
-
- /**
- * Distance between REAL tiles to the tileset texture bound.
- * @type {number}
- */
- public tileMargin: number = 0;
-
- /**
- * Distance between every 2 neighbor tile in the tileset texture.
- * @type {number}
- */
- public tileSpacing: number = 0;
-
- /**
- * Set a specific tile with its x and y in tiles.
- * @param x {number} X position of this tile in world coordinates.
- * @param y {number} Y position of this tile in world coordinates.
- * @param index {number} The index of this tile type in the core map data.
- */
- public putTileWorldXY(x: number, y: number, index: number) {
-
- x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
- y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
-
- if (y >= 0 && y < this.mapData.length)
- {
- if (x >= 0 && x < this.mapData[y].length)
- {
- this.mapData[y][x] = index;
- }
- }
-
- }
-
- /**
- * Set a specific tile with its x and y in tiles.
- * @param x {number} X position of this tile.
- * @param y {number} Y position of this tile.
- * @param index {number} The index of this tile type in the core map data.
- */
- public putTile(x: number, y: number, index: number) {
-
- if (y >= 0 && y < this.mapData.length)
- {
- if (x >= 0 && x < this.mapData[y].length)
- {
- this.mapData[y][x] = index;
- }
- }
-
- }
-
- /**
- * Swap tiles with 2 kinds of indexes.
- * @param tileA {number} First tile index.
- * @param tileB {number} Second tile index.
- * @param [x] {number} specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner.
- * @param [y] {number} specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner.
- * @param [width] {number} specify a Rectangle of tiles to operate. The width in tiles.
- * @param [height] {number} specify a Rectangle of tiles to operate. The height in tiles.
- */
- public swapTile(tileA: number, tileB: number, x: number = 0, y: number = 0, width: number = this.widthInTiles, height: number = this.heightInTiles) {
-
- this.getTempBlock(x, y, width, height);
-
- for (var r = 0; r < this._tempTileBlock.length; r++)
- {
- // First sweep marking tileA as needing a new index
- if (this._tempTileBlock[r].tile.index == tileA)
- {
- this._tempTileBlock[r].newIndex = true;
- }
-
- // In the same pass we can swap tileB to tileA
- if (this._tempTileBlock[r].tile.index == tileB)
- {
- this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileA;
- }
- }
-
- for (var r = 0; r < this._tempTileBlock.length; r++)
- {
- // And now swap our newIndex tiles for tileB
- if (this._tempTileBlock[r].newIndex == true)
- {
- this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB;
- }
- }
-
- }
-
- /**
- * Fill a tile block with a specific tile index.
- * @param index {number} Index of tiles you want to fill with.
- * @param [x] {number} x position (in tiles) of block's left-top corner.
- * @param [y] {number} y position (in tiles) of block's left-top corner.
- * @param [width] {number} width of block.
- * @param [height] {number} height of block.
- */
- public fillTile(index: number, x: number = 0, y: number = 0, width: number = this.widthInTiles, height: number = this.heightInTiles) {
-
- this.getTempBlock(x, y, width, height);
-
- for (var r = 0; r < this._tempTileBlock.length; r++)
- {
- this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = index;
- }
-
- }
-
- /**
- * Set random tiles to a specific tile block.
- * @param tiles {number[]} Tiles with indexes in this array will be randomly set to the given block.
- * @param [x] {number} x position (in tiles) of block's left-top corner.
- * @param [y] {number} y position (in tiles) of block's left-top corner.
- * @param [width] {number} width of block.
- * @param [height] {number} height of block.
- */
- public randomiseTiles(tiles: number[], x: number = 0, y: number = 0, width: number = this.widthInTiles, height: number = this.heightInTiles) {
-
- this.getTempBlock(x, y, width, height);
-
- for (var r = 0; r < this._tempTileBlock.length; r++)
- {
- this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = this.game.math.getRandom(tiles);
- }
-
- }
-
- /**
- * Replace one kind of tiles to another kind.
- * @param tileA {number} Index of tiles you want to replace.
- * @param tileB {number} Index of tiles you want to set.
- * @param [x] {number} x position (in tiles) of block's left-top corner.
- * @param [y] {number} y position (in tiles) of block's left-top corner.
- * @param [width] {number} width of block.
- * @param [height] {number} height of block.
- */
- public replaceTile(tileA: number, tileB: number, x: number = 0, y: number = 0, width: number = this.widthInTiles, height: number = this.heightInTiles) {
-
- this.getTempBlock(x, y, width, height);
-
- for (var r = 0; r < this._tempTileBlock.length; r++)
- {
- if (this._tempTileBlock[r].tile.index == tileA)
- {
- this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB;
- }
- }
-
- }
-
- /**
- * Get a tile block with specific position and size.(both are in tiles)
- * @param x {number} X position of block's left-top corner.
- * @param y {number} Y position of block's left-top corner.
- * @param width {number} Width of block.
- * @param height {number} Height of block.
- */
- public getTileBlock(x: number, y: number, width: number, height: number) {
-
- var output = [];
-
- this.getTempBlock(x, y, width, height);
-
- for (var r = 0; r < this._tempTileBlock.length; r++)
- {
- output.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
- }
-
- return output;
-
- }
-
- /**
- * Get a tile with specific position (in world coordinate). (thus you give a position of a point which is within the tile)
- * @param x {number} X position of the point in target tile.
- * @param x {number} Y position of the point in target tile.
- */
- public getTileFromWorldXY(x: number, y: number): number {
-
- x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
- y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
-
- return this.getTileIndex(x, y);
-
- }
-
- /**
- * Get tiles overlaps the given object.
- * @param object {GameObject} Tiles you want to get that overlaps this.
- * @return {array} Array with tiles informations. (Each contains x, y and the tile.)
- */
- public getTileOverlaps(object: Phaser.Sprite) {
-
- // If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds)
- if (object.body.bounds.x < 0 || object.body.bounds.x > this.widthInPixels || object.body.bounds.y < 0 || object.body.bounds.bottom > this.heightInPixels)
- {
- return;
- }
-
- // What tiles do we need to check against?
- this._tempTileX = this.game.math.snapToFloor(object.body.bounds.x, this.tileWidth) / this.tileWidth;
- this._tempTileY = this.game.math.snapToFloor(object.body.bounds.y, this.tileHeight) / this.tileHeight;
- this._tempTileW = (this.game.math.snapToCeil(object.body.bounds.width, this.tileWidth) + this.tileWidth) / this.tileWidth;
- this._tempTileH = (this.game.math.snapToCeil(object.body.bounds.height, this.tileHeight) + this.tileHeight) / this.tileHeight;
-
- // Loop through the tiles we've got and check overlaps accordingly (the results are stored in this._tempTileBlock)
-
- this._tempBlockResults = [];
- this.getTempBlock(this._tempTileX, this._tempTileY, this._tempTileW, this._tempTileH, true);
-
- /*
- for (var r = 0; r < this._tempTileBlock.length; r++)
- {
- if (this.game.world.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY) == true)
- {
- this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
- }
- }
- */
-
- return this._tempBlockResults;
-
- }
-
- /**
- * Get a tile block with its position and size. (This method does not return, it'll set result to _tempTileBlock)
- * @param x {number} X position of block's left-top corner.
- * @param y {number} Y position of block's left-top corner.
- * @param width {number} Width of block.
- * @param height {number} Height of block.
- * @param collisionOnly {bool} Whethor or not ONLY return tiles which will collide (its allowCollisions value is not Collision.NONE).
- */
- private getTempBlock(x: number, y: number, width: number, height: number, collisionOnly: bool = false) {
-
- if (x < 0)
- {
- x = 0;
- }
-
- if (y < 0)
- {
- y = 0;
- }
-
- if (width > this.widthInTiles)
- {
- width = this.widthInTiles;
- }
-
- if (height > this.heightInTiles)
- {
- height = this.heightInTiles;
- }
-
- this._tempTileBlock = [];
-
- for (var ty = y; ty < y + height; ty++)
- {
- for (var tx = x; tx < x + width; tx++)
- {
- if (collisionOnly)
- {
- // We only want to consider the tile for checking if you can actually collide with it
- if (this.mapData[ty] && this.mapData[ty][tx] && this.parent.tiles[this.mapData[ty][tx]].allowCollisions != Types.NONE)
- {
- this._tempTileBlock.push({ x: tx, y: ty, tile: this.parent.tiles[this.mapData[ty][tx]] });
- }
- }
- else
- {
- if (this.mapData[ty] && this.mapData[ty][tx])
- {
- this._tempTileBlock.push({ x: tx, y: ty, tile: this.parent.tiles[this.mapData[ty][tx]] });
- }
- }
- }
- }
-
- }
-
- /**
- * Get the tile index of specific position (in tiles).
- * @param x {number} X position of the tile.
- * @param y {number} Y position of the tile.
- * @return {number} Index of the tile at that position. Return null if there isn't a tile there.
- */
- public getTileIndex(x: number, y: number): number {
-
- if (y >= 0 && y < this.mapData.length)
- {
- if (x >= 0 && x < this.mapData[y].length)
- {
- return this.mapData[y][x];
- }
- }
-
- return null;
-
- }
-
- /**
- * Add a column of tiles into the layer.
- * @param column {string[]/number[]} An array of tile indexes to be added.
- */
- public addColumn(column) {
-
- var data = [];
-
- for (var c = 0; c < column.length; c++)
- {
- data[c] = parseInt(column[c]);
- }
-
- if (this.widthInTiles == 0)
- {
- this.widthInTiles = data.length;
- this.widthInPixels = this.widthInTiles * this.tileWidth;
- }
-
- this.mapData.push(data);
-
- this.heightInTiles++;
- this.heightInPixels += this.tileHeight;
-
- }
-
- /**
- * Update boundsInTiles with widthInTiles and heightInTiles.
- */
- public updateBounds() {
-
- this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles);
-
- }
-
- /**
- * Parse tile offsets from map data.
- * @return {number} length of tileOffsets array.
- */
- public parseTileOffsets():number {
-
- this.tileOffsets = [];
-
- var i = 0;
-
- if (this.mapFormat == Tilemap.FORMAT_TILED_JSON)
- {
- // For some reason Tiled counts from 1 not 0
- this.tileOffsets[0] = null;
- i = 1;
- }
-
- for (var ty = this.tileMargin; ty < this.texture.height; ty += (this.tileHeight + this.tileSpacing))
- {
- for (var tx = this.tileMargin; tx < this.texture.width; tx += (this.tileWidth + this.tileSpacing))
- {
- this.tileOffsets[i] = { x: tx, y: ty };
- i++;
- }
- }
-
- return this.tileOffsets.length;
-
- }
-
- }
-}
\ No newline at end of file
diff --git a/wip/TS Source/time/TimeManager.ts b/wip/TS Source/time/TimeManager.ts
deleted file mode 100644
index 5902aec5..00000000
--- a/wip/TS Source/time/TimeManager.ts
+++ /dev/null
@@ -1,278 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- export class TimeManager {
-
- /**
- * This is the core internal game clock. It manages the elapsed time and calculation of delta values,
- * used for game object motion and tweens.
- *
- * @class TimeManager
- * @constructor
- * @param {Phaser.Game} game A reference to the currently running game.
- */
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- this._started = 0;
- this._timeLastSecond = this._started;
- this.time = this._started;
-
- this.game.onPause.add(this.gamePaused, this);
- this.game.onResume.add(this.gameResumed, this);
-
- }
-
- /**
- * A reference to the currently running Game.
- * @property game
- * @type {Phaser.Game}
- */
- public game: Phaser.Game;
-
- /**
- * The time at which the Game instance started.
- * @property _started
- * @private
- * @type {Number}
- */
- private _started: number;
-
- /**
- * Number of milliseconds elapsed since the last frame update.
- * @property elapsed
- * @public
- * @type {Number}
- */
- //public elapsed: number = 0;
-
- /**
- * The elapsed time calculated for the physics motion updates.
- * @property physicsElapsed
- * @public
- * @type {Number}
- */
- public physicsElapsed: number = 0;
-
- /**
- * Game time counter.
- * @property time
- * @public
- * @type {Number}
- */
- public time: number = 0;
-
- /**
- * Records how long the game has been paused for. Is reset each time the game pauses.
- * @property pausedTime
- * @public
- * @type {Number}
- */
- public pausedTime: number = 0;
-
- /**
- * The time right now.
- * @property now
- * @public
- * @type {Number}
- */
- public now: number = 0;
-
- /**
- * Elapsed time since the last frame.
- * @property delta
- * @public
- * @type {Number}
- */
- public delta: number = 0;
-
- /**
- * The number of seconds that have elapsed since the game was started.
- * @method totalElapsedSeconds
- * @return {Number}
- */
- public get totalElapsedSeconds(): number {
-
- return (this.now - this._started) * 0.001;
-
- }
-
- /**
- * Frames per second.
- * @property fps
- * @public
- * @type {Number}
- */
- public fps: number = 0;
-
- /**
- * The lowest rate the fps has dropped to.
- * @property fpsMin
- * @public
- * @type {Number}
- */
- public fpsMin: number = 1000;
-
- /**
- * The highest rate the fps has reached (usually no higher than 60fps).
- * @property fpsMax
- * @public
- * @type {Number}
- */
- public fpsMax: number = 0;
-
- /**
- * The minimum amount of time the game has taken between two frames.
- * @property msMin
- * @public
- * @type {Number}
- */
- public msMin: number = 1000;
-
- /**
- * The maximum amount of time the game has taken between two frames.
- * @property msMax
- * @public
- * @type {Number}
- */
- public msMax: number = 0;
-
- /**
- * The number of frames record in the last second.
- * @property frames
- * @public
- * @type {Number}
- */
- public frames: number = 0;
-
- /**
- * The time (in ms) that the last second counter ticked over.
- * @property _timeLastSecond
- * @private
- * @type {Number}
- */
- private _timeLastSecond: number = 0;
-
- /**
- * Update clock and calculate the fps.
- * This is called automatically by Game._raf
- * @method update
- * @param {Number} raf The current timestamp, either performance.now or Date.now
- */
- public update(raf: number) {
-
- this.now = raf; // mark
- this.delta = this.now - this.time; // elapsedMS
-
- this.msMin = Math.min(this.msMin, this.delta);
- this.msMax = Math.max(this.msMax, this.delta);
-
- this.frames++;
-
- if (this.now > this._timeLastSecond + 1000)
- {
- this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond));
- this.fpsMin = Math.min(this.fpsMin, this.fps);
- this.fpsMax = Math.max(this.fpsMax, this.fps);
-
- this._timeLastSecond = this.now;
- this.frames = 0;
- }
-
- this.time = this.now; // _total
-
- this.physicsElapsed = 1.0 * (this.delta / 1000);
-
- // Paused?
- if (this.game.paused)
- {
- this.pausedTime = this.now - this._pauseStarted;
- }
-
- }
-
- /**
- * Called when the game enters a paused state.
- * @method gamePaused
- * @private
- */
- private gamePaused() {
- this._pauseStarted = this.now;
- }
-
- /**
- * Called when the game resumes from a paused state.
- * @method gameResumed
- * @private
- */
- private gameResumed() {
-
- // Level out the delta timer to avoid spikes
- this.delta = 0;
- this.physicsElapsed = 0;
- this.time = Date.now();
- this.pauseDuration = this.pausedTime;
-
- }
-
- /**
- * Records how long the game was paused for in miliseconds.
- * @property pauseDuration
- * @public
- * @type {Number}
- */
- public pauseDuration: number = 0;
-
- /**
- * The time the game started being paused.
- * @property _pauseStarted
- * @private
- * @type {Number}
- */
- private _pauseStarted: number = 0;
-
- /**
- * How long has passed since the given time.
- * @method elapsedSince
- * @param {Number} since The time you want to measure against.
- * @return {Number} The difference between the given time and now.
- */
- public elapsedSince(since: number): number {
-
- return this.now - since;
-
- }
-
- /**
- * How long has passed since the given time (in seconds).
- * @method elapsedSecondsSince
- * @param {Number} since The time you want to measure (in seconds).
- * @return {Number} Duration between given time and now (in seconds).
- */
- public elapsedSecondsSince(since: number): number {
-
- return (this.now - since) * 0.001;
-
- }
-
- /**
- * Resets the private _started value to now.
- * @method reset
- */
- public reset() {
-
- this._started = this.now;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/tweens/Tween.ts b/wip/TS Source/tweens/Tween.ts
deleted file mode 100644
index 38f15f62..00000000
--- a/wip/TS Source/tweens/Tween.ts
+++ /dev/null
@@ -1,448 +0,0 @@
-///
-
-/**
-* Phaser - Tween
-*
-* Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser
-*/
-
-module Phaser {
-
- export class Tween {
-
- /**
- * Tween constructor
- * Create a new Tween.
- *
- * @param object {object} Target object will be affected by this tween.
- * @param game {Phaser.Game} Current game instance.
- */
- constructor(object, game: Phaser.Game) {
-
- this._object = object;
-
- this.game = game;
- this._manager = this.game.tweens;
- this._interpolationFunction = this.game.math.linearInterpolation;
- this._easingFunction = Phaser.Easing.Linear.None;
-
- this._chainedTweens = [];
- this.onStart = new Phaser.Signal;
- this.onUpdate = new Phaser.Signal;
- this.onComplete = new Phaser.Signal;
-
- }
-
- /**
- * Local reference to Game.
- */
- public game: Phaser.Game;
-
- /**
- * Manager of this tween.
- * @type {Phaser.TweenManager}
- */
- private _manager: Phaser.TweenManager;
-
- /**
- * Reference to the target object.
- * @type {object}
- */
- private _object = null;
-
- private _pausedTime: number = 0;
-
- /**
- * Start values container.
- * @type {object}
- */
- private _valuesStart = {};
-
- /**
- * End values container.
- * @type {object}
- */
- private _valuesEnd = {};
-
- /**
- * How long this tween will perform.
- * @type {number}
- */
- private _duration: number = 1000;
- private _delayTime: number = 0;
- private _startTime: number = null;
-
- // Temp vars to avoid gc spikes
- private _tempElapsed: number;
- private _tempValue;
-
- /**
- * Will this tween automatically restart when it completes?
- * @type {bool}
- */
- private _loop: bool = false;
-
- /**
- * A yoyo tween is one that plays once fully, then reverses back to the original tween values before completing.
- * @type {bool}
- */
- private _yoyo: bool = false;
- private _yoyoCount: number = 0;
-
- /**
- * Easing function which actually updating this tween.
- * @type {function}
- */
- private _easingFunction;
- private _interpolationFunction;
-
- /**
- * Contains chained tweens.
- * @type {Tweens[]}
- */
- private _chainedTweens = [];
-
- /**
- * Signal to be dispatched when this tween start.
- * @type {Phaser.Signal}
- */
- public onStart: Phaser.Signal;
-
- /**
- * Signal to be dispatched when this tween updating.
- * @type {Phaser.Signal}
- */
- public onUpdate: Phaser.Signal;
-
- /**
- * Signal to be dispatched when this tween completed.
- * @type {Phaser.Signal}
- */
- public onComplete: Phaser.Signal;
-
- /**
- * Configure the Tween
- * @param properties {object} Propertis you want to tween.
- * @param [duration] {number} duration of this tween.
- * @param [ease] {any} Easing function.
- * @param [autoStart] {bool} Whether this tween will start automatically or not.
- * @param [delay] {number} delay before this tween will start, defaults to 0 (no delay)
- * @param [loop] {bool} Should the tween automatically restart once complete? (ignores any chained tweens)
- * @return {Tween} Itself.
- */
- public to(properties, duration: number = 1000, ease: any = null, autoStart: bool = false, delay: number = 0, loop: bool = false, yoyo: bool = false): Phaser.Tween {
-
- this._duration = duration;
-
- // If properties isn't an object this will fail, sanity check it here somehow?
- this._valuesEnd = properties;
-
- if (ease !== null)
- {
- this._easingFunction = ease;
- }
-
- if (delay > 0)
- {
- this._delayTime = delay;
- }
-
- this._loop = loop;
- this._yoyo = yoyo;
- this._yoyoCount = 0;
-
- if (autoStart === true)
- {
- return this.start();
- }
- else
- {
- return this;
- }
-
- }
-
- public loop(value: bool): Phaser.Tween {
-
- this._loop = value;
- return this;
-
- }
-
- public yoyo(value: bool): Phaser.Tween {
-
- this._yoyo = value;
- this._yoyoCount = 0;
- return this;
-
- }
-
- public isRunning: bool = false;
-
- /**
- * Start to tween.
- */
- public start(looped: bool = false): Phaser.Tween {
-
- if (this.game === null || this._object === null)
- {
- return;
- }
-
- if (looped == false)
- {
- this._manager.add(this);
-
- this.onStart.dispatch(this._object);
- }
-
- this._startTime = this.game.time.now + this._delayTime;
- this.isRunning = true;
-
- for (var property in this._valuesEnd)
- {
- // This prevents the interpolation of null values or of non-existing properties
- if (this._object[property] === null || !(property in this._object))
- {
- throw Error('Phaser.Tween interpolation of null value of non-existing property');
- continue;
- }
-
- // check if an Array was provided as property value
- if (this._valuesEnd[property] instanceof Array)
- {
- if (this._valuesEnd[property].length === 0)
- {
- continue;
- }
-
- // create a local copy of the Array with the start value at the front
- this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]);
- }
-
- if (looped == false)
- {
- this._valuesStart[property] = this._object[property];
- }
-
- }
-
- return this;
-
- }
-
- public reverse() {
-
- var tempObj = {};
-
- for (var property in this._valuesStart)
- {
- tempObj[property] = this._valuesStart[property];
- this._valuesStart[property] = this._valuesEnd[property];
- this._valuesEnd[property] = tempObj[property];
- }
-
- this._yoyoCount++;
-
- return this.start(true);
-
- }
-
- public reset(): Phaser.Tween {
-
- // Reset the properties back to what they were before
- for (var property in this._valuesStart)
- {
- this._object[property] = this._valuesStart[property];
- }
-
- return this.start(true);
-
- }
-
- public clear(): Phaser.Tween {
-
- this._chainedTweens = [];
-
- this.onStart.removeAll();
- this.onUpdate.removeAll();
- this.onComplete.removeAll();
-
- return this;
-
- }
-
- /**
- * Stop tweening.
- */
- public stop(): Phaser.Tween {
-
- if (this._manager !== null)
- {
- this._manager.remove(this);
- }
-
- this.isRunning = false;
-
- this.onComplete.dispose();
-
- return this;
-
- }
-
- public set parent(value: Phaser.Game) {
-
- this.game = value;
- this._manager = this.game.tweens;
-
- }
-
- public set delay(amount: number) {
- this._delayTime = amount;
- }
-
- public get delay(): number {
- return this._delayTime;
- }
-
- public set easing(easing) {
- this._easingFunction = easing;
- }
-
- public get easing() {
- return this._easingFunction;
- }
-
- public set interpolation(interpolation) {
- this._interpolationFunction = interpolation;
- }
-
- public get interpolation() {
- return this._interpolationFunction;
- }
-
- /**
- * Add another chained tween, which will start automatically when the one before it completes.
- * @param tween {Phaser.Tween} Tween object you want to chain with this.
- * @return {Phaser.Tween} Itselfe.
- */
- public chain(tween: Phaser.Tween): Phaser.Tween {
-
- this._chainedTweens.push(tween);
-
- return this;
-
- }
-
- public pause() {
- this._paused = true;
- }
-
- public resume() {
-
- this._paused = false;
- this._startTime += this.game.time.pauseDuration;
-
- }
-
- private _paused: bool;
-
- /**
- * Update tweening.
- * @param time {number} Current time from game clock.
- * @return {bool} Return false if this completed and no need to update, otherwise return true.
- */
- public update(time: number) {
-
- if (this._paused || time < this._startTime)
- {
- return true;
- }
-
- this._tempElapsed = (time - this._startTime) / this._duration;
- this._tempElapsed = this._tempElapsed > 1 ? 1 : this._tempElapsed;
-
- this._tempValue = this._easingFunction(this._tempElapsed);
-
- for (var property in this._valuesStart)
- {
- // Add checks for object, array, numeric up front
- if (this._valuesEnd[property] instanceof Array)
- {
- this._object[property] = this._interpolationFunction(this._valuesEnd[property], this._tempValue);
- }
- else
- {
- this._object[property] = this._valuesStart[property] + (this._valuesEnd[property] - this._valuesStart[property]) * this._tempValue;
- }
- }
-
- this.onUpdate.dispatch(this._object, this._tempValue);
-
- if (this._tempElapsed == 1)
- {
- // Yoyo?
- if (this._yoyo)
- {
- if (this._yoyoCount == 0)
- {
- // Reverse the tween
- this.reverse();
- return true;
- }
- else
- {
- // We've yoyo'd once already, quit?
- if (this._loop == false)
- {
- this.onComplete.dispatch(this._object);
-
- for (var i = 0; i < this._chainedTweens.length; i++)
- {
- this._chainedTweens[i].start();
- }
-
- return false;
- }
- else
- {
- // YoYo and Loop are both on
- this._yoyoCount = 0;
- this.reverse();
- return true;
- }
- }
- }
-
- // Loop?
- if (this._loop)
- {
- this._yoyoCount = 0;
- this.reset();
- return true;
- }
- else
- {
- this.onComplete.dispatch(this._object);
-
- for (var i = 0; i < this._chainedTweens.length; i++)
- {
- this._chainedTweens[i].start();
- }
-
- if (this._chainedTweens.length == 0)
- {
- this.isRunning = false;
- }
-
- return false;
- }
-
- }
-
- return true;
-
- }
-
- }
-}
diff --git a/wip/TS Source/tweens/TweenManager.ts b/wip/TS Source/tweens/TweenManager.ts
deleted file mode 100644
index 837b368e..00000000
--- a/wip/TS Source/tweens/TweenManager.ts
+++ /dev/null
@@ -1,183 +0,0 @@
-///
-
-/**
-* Phaser - TweenManager
-*
-* The Game has a single instance of the TweenManager through which all Tween objects are created and updated.
-* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
-* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com).
-* I converted it to TypeScript, swapped the callbacks for signals and patched a few issues with regard
-* to properties and completion errors. Please see https://github.com/sole/tween.js for a full list of contributors.
-*/
-
-module Phaser {
-
- export class TweenManager {
-
- /**
- * TweenManager constructor
- * @param game {Game} A reference to the current Game.
- */
- constructor(game: Phaser.Game) {
-
- this.game = game;
-
- this._tweens = [];
-
- this.game.onPause.add(this.pauseAll, this);
- this.game.onResume.add(this.resumeAll, this);
-
- }
-
- /**
- * Local reference to Game
- */
- public game: Phaser.Game;
-
- /**
- * Local private array which is the container of all tween objects.
- */
- private _tweens: Phaser.Tween[];
-
- /**
- * Get all the tween objects in an array.
- * @return {Phaser.Tween[]} Array with all tween objects.
- */
- public getAll() {
-
- return this._tweens;
-
- }
-
- /**
- * Remove all tween objects.
- */
- public removeAll() {
-
- this._tweens.length = 0;
-
- }
-
- /**
- * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
- *
- * @param obj {object} Object the tween will be run on.
- * @param [localReference] {bool} If true the tween will be stored in the object.tween property so long as it exists. If already set it'll be over-written.
- * @return {Phaser.Tween} The newly created tween object.
- */
- public create(object, localReference:bool = false): Phaser.Tween {
-
- if (localReference)
- {
- object['tween'] = new Phaser.Tween(object, this.game);
- return object['tween'];
- }
- else
- {
- return new Phaser.Tween(object, this.game);
- }
-
- }
-
- /**
- * Add a new tween into the TweenManager.
- *
- * @param tween {Phaser.Tween} The tween object you want to add.
- * @return {Phaser.Tween} The tween object you added to the manager.
- */
- public add(tween: Phaser.Tween) {
-
- tween.parent = this.game;
-
- this._tweens.push(tween);
-
- return tween;
-
- }
-
- /**
- * Remove a tween from this manager.
- *
- * @param tween {Phaser.Tween} The tween object you want to remove.
- */
- public remove(tween: Phaser.Tween) {
-
- var i = this._tweens.indexOf(tween);
-
- if (i !== -1)
- {
- this._tweens.splice(i, 1);
- }
-
- }
-
- /**
- * Update all the tween objects you added to this manager.
- *
- * @return {bool} Return false if there's no tween to update, otherwise return true.
- */
- public update() {
-
- if (this._tweens.length === 0)
- {
- return false;
- }
-
- var i = 0;
- var numTweens = this._tweens.length;
-
- while (i < numTweens)
- {
- if (this._tweens[i].update(this.game.time.now))
- {
- i++;
- }
- else
- {
- this._tweens.splice(i, 1);
- numTweens--;
- }
- }
-
- return true;
-
- }
-
- public pauseAll() {
-
- if (this._tweens.length === 0)
- {
- return false;
- }
-
- var i = 0;
- var numTweens = this._tweens.length;
-
- while (i < numTweens)
- {
- this._tweens[i].pause();
- i++;
- }
-
- }
-
- public resumeAll() {
-
- if (this._tweens.length === 0)
- {
- return false;
- }
-
- var i = 0;
- var numTweens = this._tweens.length;
-
- while (i < numTweens)
- {
- this._tweens[i].resume();
- i++;
- }
-
- }
-
- }
-}
diff --git a/wip/TS Source/tweens/easing/Back.ts b/wip/TS Source/tweens/easing/Back.ts
deleted file mode 100644
index f08ed2c7..00000000
--- a/wip/TS Source/tweens/easing/Back.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Back easing methods.
- *
- * @class Back
- */
- export class Back {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- var s = 1.70158;
- return k * k * ((s + 1) * k - s);
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- var s = 1.70158;
- return --k * k * ((s + 1) * k + s) + 1;
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- var s = 1.70158 * 1.525;
- if ((k *= 2) < 1) return 0.5 * (k * k * ((s + 1) * k - s));
- return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Bounce.ts b/wip/TS Source/tweens/easing/Bounce.ts
deleted file mode 100644
index 8391f01d..00000000
--- a/wip/TS Source/tweens/easing/Bounce.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Bounce easing methods.
- *
- * @class Bounce
- */
- export class Bounce {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- return 1 - Phaser.Easing.Bounce.Out(1 - k);
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- if (k < (1 / 2.75))
- {
- return 7.5625 * k * k;
- }
- else if (k < (2 / 2.75))
- {
- return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
- }
- else if (k < (2.5 / 2.75))
- {
- return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
- }
- else
- {
- return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
- }
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- if (k < 0.5) return Phaser.Easing.Bounce.In(k * 2) * 0.5;
- return Phaser.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Circular.ts b/wip/TS Source/tweens/easing/Circular.ts
deleted file mode 100644
index 730724d2..00000000
--- a/wip/TS Source/tweens/easing/Circular.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-///
-
-/**
-* Phaser - Easing - Circular
-*
-* For use with Phaser.Tween
-*/
-
-module Phaser.Easing {
-
- export class Circular {
-
- public static In(k) {
-
- return 1 - Math.sqrt(1 - k * k);
-
- }
-
- public static Out(k) {
-
- return Math.sqrt(1 - (--k * k));
-
- }
-
- public static InOut(k) {
-
- if ((k *= 2) < 1) return -0.5 * (Math.sqrt(1 - k * k) - 1);
- return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Cubic.ts b/wip/TS Source/tweens/easing/Cubic.ts
deleted file mode 100644
index 5ce27eaa..00000000
--- a/wip/TS Source/tweens/easing/Cubic.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Cubic easing methods.
- *
- * @class Cubic
- */
- export class Cubic {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- return k * k * k;
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- return --k * k * k + 1;
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- if ((k *= 2) < 1) return 0.5 * k * k * k;
- return 0.5 * ((k -= 2) * k * k + 2);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Elastic.ts b/wip/TS Source/tweens/easing/Elastic.ts
deleted file mode 100644
index 0f8d3889..00000000
--- a/wip/TS Source/tweens/easing/Elastic.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Elastic easing methods.
- *
- * @class Elastic
- */
- export class Elastic {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- var s, a = 0.1, p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!a || a < 1) { a = 1; s = p / 4; }
- else s = p * Math.asin(1 / a) / (2 * Math.PI);
- return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- var s, a = 0.1, p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!a || a < 1) { a = 1; s = p / 4; }
- else s = p * Math.asin(1 / a) / (2 * Math.PI);
- return (a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1);
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- var s, a = 0.1, p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!a || a < 1) { a = 1; s = p / 4; }
- else s = p * Math.asin(1 / a) / (2 * Math.PI);
- if ((k *= 2) < 1) return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Exponential.ts b/wip/TS Source/tweens/easing/Exponential.ts
deleted file mode 100644
index 60f50908..00000000
--- a/wip/TS Source/tweens/easing/Exponential.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Exponential easing methods.
- *
- * @class Exponential
- */
- export class Exponential {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- return k === 0 ? 0 : Math.pow(1024, k - 1);
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- if (k === 0) return 0;
- if (k === 1) return 1;
- if ((k *= 2) < 1) return 0.5 * Math.pow(1024, k - 1);
- return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Linear.ts b/wip/TS Source/tweens/easing/Linear.ts
deleted file mode 100644
index 5e40abbb..00000000
--- a/wip/TS Source/tweens/easing/Linear.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Linear easing methods.
- *
- * @class Linear
- */
- export class Linear {
-
- /**
- * A Linear Ease only has a None method.
- *
- * @method None
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static None(k) {
-
- return k;
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Quadratic.ts b/wip/TS Source/tweens/easing/Quadratic.ts
deleted file mode 100644
index e5ccaa83..00000000
--- a/wip/TS Source/tweens/easing/Quadratic.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Quadratic easing methods.
- *
- * @class Quadratic
- */
- export class Quadratic {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- return k * k;
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- return k * (2 - k);
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- if ((k *= 2) < 1) return 0.5 * k * k;
- return -0.5 * (--k * (k - 2) - 1);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Quartic.ts b/wip/TS Source/tweens/easing/Quartic.ts
deleted file mode 100644
index 008cd073..00000000
--- a/wip/TS Source/tweens/easing/Quartic.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Quartic easing methods.
- *
- * @class Quartic
- */
- export class Quartic {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- return k * k * k * k;
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- return 1 - (--k * k * k * k);
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- if ((k *= 2) < 1) return 0.5 * k * k * k * k;
- return -0.5 * ((k -= 2) * k * k * k - 2);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Quintic.ts b/wip/TS Source/tweens/easing/Quintic.ts
deleted file mode 100644
index 03a95108..00000000
--- a/wip/TS Source/tweens/easing/Quintic.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Quintic easing methods.
- *
- * @class Quintic
- */
- export class Quintic {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- return k * k * k * k * k;
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- return --k * k * k * k * k + 1;
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- if ((k *= 2) < 1) return 0.5 * k * k * k * k * k;
- return 0.5 * ((k -= 2) * k * k * k * k + 2);
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/tweens/easing/Sinusoidal.ts b/wip/TS Source/tweens/easing/Sinusoidal.ts
deleted file mode 100644
index fe52017e..00000000
--- a/wip/TS Source/tweens/easing/Sinusoidal.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @author sole (http://soledadpenades.com), tween.js
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser.Easing {
-
- /**
- * Sinusoidal easing methods.
- *
- * @class Sinusoidal
- */
- export class Sinusoidal {
-
- /**
- * The In ease method.
- *
- * @method In
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static In(k) {
-
- return 1 - Math.cos(k * Math.PI / 2);
-
- }
-
- /**
- * The Out ease method.
- *
- * @method Out
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static Out(k) {
-
- return Math.sin(k * Math.PI / 2);
-
- }
-
- /**
- * The InOut ease method.
- *
- * @method InOut
- * @param {Number} k The value to ease.
- * @return {Number} The eased value.
- */
- public static InOut(k) {
-
- return 0.5 * (1 - Math.cos(Math.PI * k));
-
- }
-
- }
-
-}
diff --git a/wip/TS Source/ui/Button.ts b/wip/TS Source/ui/Button.ts
deleted file mode 100644
index b9745f42..00000000
--- a/wip/TS Source/ui/Button.ts
+++ /dev/null
@@ -1,210 +0,0 @@
-///
-
-/**
-* Phaser - UI - Button
-*/
-
-module Phaser.UI {
-
- export class Button extends Phaser.Sprite {
-
- /**
- * Create a new Button object.
- *
- * @param game {Phaser.Game} Current game instance.
- * @param [x] {number} X position of the button.
- * @param [y] {number} Y position of the button.
- * @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this button.
- * @param [callback] {function} The function to call when this button is pressed
- * @param [callbackContext] {object} The context in which the callback will be called (usually 'this')
- * @param [overFrame] {string|number} This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
- * @param [outFrame] {string|number} This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
- * @param [downFrame] {string|number} This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
- */
- constructor(game: Phaser.Game, x: number = 0, y: number = 0, key: string = null, callback = null, callbackContext = null, overFrame = null, outFrame = null, downFrame = null) {
-
- super(game, x, y, key, outFrame);
-
- this.type = Phaser.Types.BUTTON;
-
- if (typeof overFrame == 'string')
- {
- this._onOverFrameName = overFrame;
- }
- else
- {
- this._onOverFrameID = overFrame;
- }
-
- if (typeof outFrame == 'string')
- {
- this._onOutFrameName = outFrame;
- this._onUpFrameName = outFrame;
- }
- else
- {
- this._onOutFrameID = outFrame;
- this._onUpFrameID = outFrame;
- }
-
- if (typeof downFrame == 'string')
- {
- this._onDownFrameName = downFrame;
- }
- else
- {
- this._onDownFrameID = downFrame;
- }
-
- // These are the signals the game will subscribe to
- this.onInputOver = new Phaser.Signal;
- this.onInputOut = new Phaser.Signal;
- this.onInputDown = new Phaser.Signal;
- this.onInputUp = new Phaser.Signal;
-
- // Set a default signal for them
- if (callback)
- {
- this.onInputUp.add(callback, callbackContext);
- }
-
- this.input.start(0, false, true);
-
- // Redirect the input events to here so we can handle animation updates, etc
- this.events.onInputOver.add(this.onInputOverHandler, this);
- this.events.onInputOut.add(this.onInputOutHandler, this);
- this.events.onInputDown.add(this.onInputDownHandler, this);
- this.events.onInputUp.add(this.onInputUpHandler, this);
-
- }
-
- private _onOverFrameName = null;
- private _onOutFrameName = null;
- private _onDownFrameName = null;
- private _onUpFrameName = null;
- private _onOverFrameID = null;
- private _onOutFrameID = null;
- private _onDownFrameID = null;
- private _onUpFrameID = null;
-
- /**
- * Dispatched when a pointer moves over an Input enabled sprite.
- */
- public onInputOver: Phaser.Signal;
-
- /**
- * Dispatched when a pointer moves out of an Input enabled sprite.
- */
- public onInputOut: Phaser.Signal;
-
- /**
- * Dispatched when a pointer is pressed down on an Input enabled sprite.
- */
- public onInputDown: Phaser.Signal;
-
- /**
- * Dispatched when a pointer is released over an Input enabled sprite
- */
- public onInputUp: Phaser.Signal;
-
- // TODO
- //public tabIndex: number;
- //public tabEnabled: bool;
-
- // ENTER or SPACE can activate this button if it has focus
-
- private onInputOverHandler(pointer: Phaser.Pointer) {
-
- if (this._onOverFrameName != null)
- {
- this.frameName = this._onOverFrameName;
- }
- else if (this._onOverFrameID != null)
- {
- this.frame = this._onOverFrameID;
- }
-
- if (this.onInputOver)
- {
- this.onInputOver.dispatch(this, pointer);
- }
-
- }
-
- private onInputOutHandler(pointer: Phaser.Pointer) {
-
- if (this._onOutFrameName != null)
- {
- this.frameName = this._onOutFrameName;
- }
- else if (this._onOutFrameID != null)
- {
- this.frame = this._onOutFrameID;
- }
-
- if (this.onInputOut)
- {
- this.onInputOut.dispatch(this, pointer);
- }
-
- }
-
- private onInputDownHandler(pointer: Phaser.Pointer) {
-
- //console.log('Button onInputDownHandler: ' + Date.now());
-
- if (this._onDownFrameName != null)
- {
- this.frameName = this._onDownFrameName;
- }
- else if (this._onDownFrameID != null)
- {
- this.frame = this._onDownFrameID;
- }
-
- if (this.onInputDown)
- {
- this.onInputDown.dispatch(this, pointer);
- }
-
- }
-
- private onInputUpHandler(pointer: Phaser.Pointer) {
-
- //console.log('Button onInputUpHandler: ' + Date.now());
-
- if (this._onUpFrameName != null)
- {
- this.frameName = this._onUpFrameName;
- }
- else if (this._onUpFrameID != null)
- {
- this.frame = this._onUpFrameID;
- }
-
- if (this.onInputUp)
- {
- this.onInputUp.dispatch(this, pointer);
- }
-
- }
-
- public set priorityID(value: number) {
- this.input.priorityID = value;
- }
-
- public get priorityID(): number {
- return this.input.priorityID;
- }
-
- public set useHandCursor(value: bool) {
- this.input.useHandCursor = value;
- }
-
- public get useHandCursor(): bool {
- return this.input.useHandCursor;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/utils/CanvasUtils.ts b/wip/TS Source/utils/CanvasUtils.ts
deleted file mode 100644
index e47839fa..00000000
--- a/wip/TS Source/utils/CanvasUtils.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- /**
- * A collection of methods useful for manipulating canvas objects.
- *
- * @class CanvasUtils
- */
- export class CanvasUtils {
-
- /**
- * Returns the aspect ratio of the given canvas.
- *
- * @method getAspectRatio
- * @param {HTMLCanvasElement} canvas The canvas to get the aspect ratio from.
- * @return {Number} Returns true on success
- */
- public static getAspectRatio(canvas: HTMLCanvasElement): number {
- return canvas.width / canvas.height;
- }
-
- /**
- * Sets the background color behind the canvas. This changes the canvas style property.
- *
- * @method setBackgroundColor
- * @param {HTMLCanvasElement} canvas The canvas to set the background color on.
- * @param {String} color The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- public static setBackgroundColor(canvas: HTMLCanvasElement, color: string = 'rgb(0,0,0)'): HTMLCanvasElement {
-
- canvas.style.backgroundColor = color;
- return canvas;
-
- }
-
- /**
- * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
- *
- * @method setTouchAction
- * @param {HTMLCanvasElement} canvas The canvas to set the touch action on.
- * @param {String} value The touch action to set. Defaults to 'none'.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- public static setTouchAction(canvas: HTMLCanvasElement, value: string= 'none'): HTMLCanvasElement {
-
- canvas.style.msTouchAction = value;
- canvas.style['ms-touch-action'] = value;
- canvas.style['touch-action'] = value;
-
- return canvas;
-
- }
-
- /**
- * Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent.
- * If no parent is given it will be added as a child of the document.body.
- *
- * @method addToDOM
- * @param {HTMLCanvasElement} canvas The canvas to set the touch action on.
- * @param {String} parent The DOM element to add the canvas to. Defaults to ''.
- * @param {bool} overflowHidden If set to true it will add the overflow='hidden' style to the parent DOM element.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- public static addToDOM(canvas: HTMLCanvasElement, parent: string = '', overflowHidden: bool = true): HTMLCanvasElement {
-
- if ((parent !== '' || parent !== null) && document.getElementById(parent))
- {
- document.getElementById(parent).appendChild(canvas);
-
- if (overflowHidden)
- {
- document.getElementById(parent).style.overflow = 'hidden';
- }
- }
- else
- {
- document.body.appendChild(canvas);
- }
-
- return canvas;
-
- }
-
- /**
- * Sets the transform of the given canvas to the matrix values provided.
- *
- * @method setTransform
- * @param {CanvasRenderingContext2D} context The context to set the transform on.
- * @param {Number} translateX The value to translate horizontally by.
- * @param {Number} translateY The value to translate vertically by.
- * @param {Number} scaleX The value to scale horizontally by.
- * @param {Number} scaleY The value to scale vertically by.
- * @param {Number} skewX The value to skew horizontaly by.
- * @param {Number} skewY The value to skew vertically by.
- * @return {CanvasRenderingContext2D} Returns the source context.
- */
- public static setTransform(context: CanvasRenderingContext2D, translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number): CanvasRenderingContext2D {
-
- context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
-
- return context;
-
- }
-
- /**
- * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing.
- * By default browsers have image smoothing enabled, which isn't always what you visually want, especially
- * when using pixel art in a game. Note that this sets the property on the context itself, so that any image
- * drawn to the context will be affected. This sets the property across all current browsers but support is
- * patchy on earlier browsers, especially on mobile.
- *
- * @method setSmoothingEnabled
- * @param {CanvasRenderingContext2D} context The context to enable or disable the image smoothing on.
- * @param {bool} overflowHidden If set to true it will enable image smoothing, false will disable it.
- * @return {CanvasRenderingContext2D} Returns the source context.
- */
- public static setSmoothingEnabled(context: CanvasRenderingContext2D, value: bool): CanvasRenderingContext2D {
-
- context['imageSmoothingEnabled'] = value;
- context['mozImageSmoothingEnabled'] = value;
- context['oImageSmoothingEnabled'] = value;
- context['webkitImageSmoothingEnabled'] = value;
- context['msImageSmoothingEnabled'] = value;
- return context;
-
- }
-
- /**
- * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast on webkit').
- * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.
- *
- * @method setImageRenderingCrisp
- * @param {HTMLCanvasElement} canvas The canvas to set image-rendering crisp on.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- public static setImageRenderingCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement {
-
- canvas.style['image-rendering'] = 'crisp-edges';
- canvas.style['image-rendering'] = '-moz-crisp-edges';
- canvas.style['image-rendering'] = '-webkit-optimize-contrast';
- canvas.style.msInterpolationMode = 'nearest-neighbor';
- return canvas;
-
- }
-
- /**
- * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto').
- * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.
- *
- * @method setImageRenderingBicubic
- * @param {HTMLCanvasElement} canvas The canvas to set image-rendering bicubic on.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- public static setImageRenderingBicubic(canvas: HTMLCanvasElement): HTMLCanvasElement {
-
- canvas.style['image-rendering'] = 'auto';
- canvas.style.msInterpolationMode = 'bicubic';
- return canvas;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/utils/CircleUtils.ts b/wip/TS Source/utils/CircleUtils.ts
deleted file mode 100644
index 9e5687fe..00000000
--- a/wip/TS Source/utils/CircleUtils.ts
+++ /dev/null
@@ -1,184 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- /**
- * A collection of methods useful for manipulating and comparing Circle objects.
- *
- * @class CircleUtils
- */
- export class CircleUtils {
-
- /**
- * Returns a new Circle object with the same values for the x, y, width, and height properties as the given Circle object.
- * @method clone
- * @param {Phaser.Circle} a The Circle object to be cloned.
- * @param {Phaser.Circle} out Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.
- * @return {Phaser.Circle} The cloned Circle object.
- */
- public static clone(a: Phaser.Circle, out: Phaser.Circle = new Phaser.Circle): Phaser.Circle {
- return out.setTo(a.x, a.y, a.diameter);
- }
-
- /**
- * Return true if the given x/y coordinates are within the Circle object.
- * @method contains
- * @param {Phaser.Circle} a The Circle to be checked.
- * @param {Number} x The X value of the coordinate to test.
- * @param {Number} y The Y value of the coordinate to test.
- * @return {bool} True if the coordinates are within this circle, otherwise false.
- */
- public static contains(a: Phaser.Circle, x: number, y: number): bool {
-
- // Check if x/y are within the bounds first
- if (x >= a.left && x <= a.right && y >= a.top && y <= a.bottom)
- {
- var dx: number = (a.x - x) * (a.x - x);
- var dy: number = (a.y - y) * (a.y - y);
- return (dx + dy) <= (a.radius * a.radius);
- }
-
- return false;
-
- }
-
- /**
- * Return true if the coordinates of the given Point object are within this Circle object.
- * @method containsPoint
- * @param {Phaser.Circle} a The Circle object.
- * @param {Phaser.Point} point The Point object to test.
- * @return {bool} True if the coordinates are within this circle, otherwise false.
- */
- public static containsPoint(a: Phaser.Circle, point: Phaser.Point): bool {
- return CircleUtils.contains(a, point.x, point.y);
- }
-
- /**
- * Return true if the given Circle is contained entirely within this Circle object.
- * @method containsCircle
- * @param {Phaser.Circle} a The Circle object to test.
- * @param {Phaser.Circle} b The Circle object to test.
- * @return {bool} True if Circle B is contained entirely inside of Circle A, otherwise false.
- */
- public static containsCircle(a: Phaser.Circle, b: Phaser.Circle): bool {
- //return ((a.radius + b.radius) * (a.radius + b.radius)) >= Collision.distanceSquared(a.x, a.y, b.x, b.y);
- return true;
- }
-
- /**
- * Returns the distance from the center of the Circle object to the given object
- * (can be Circle, Point or anything with x/y properties)
- * @method distanceBetween
- * @param {Phaser.Circle} a The Circle object.
- * @param {Phaser.Circle} b The target object. Must have visible x and y properties that represent the center of the object.
- * @param {bool} [optional] round Round the distance to the nearest integer (default false)
- * @return {Number} The distance between this Point object and the destination Point object.
- */
- public static distanceBetween(a: Phaser.Circle, target: any, round: bool = false): number {
-
- var dx = a.x - target.x;
- var dy = a.y - target.y;
-
- if (round === true)
- {
- return Math.round(Math.sqrt(dx * dx + dy * dy));
- }
- else
- {
- return Math.sqrt(dx * dx + dy * dy);
- }
-
- }
-
- /**
- * Determines whether the two Circle objects match. This method compares the x, y and diameter properties.
- * @method equals
- * @param {Phaser.Circle} a The first Circle object.
- * @param {Phaser.Circle} b The second Circle object.
- * @return {bool} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false.
- */
- public static equals(a: Phaser.Circle, b: Phaser.Circle): bool {
- return (a.x == b.x && a.y == b.y && a.diameter == b.diameter);
- }
-
- /**
- * Determines whether the two Circle objects intersect.
- * This method checks the radius distances between the two Circle objects to see if they intersect.
- * @method intersects
- * @param {Phaser.Circle} a The first Circle object.
- * @param {Phaser.Circle} b The second Circle object.
- * @return {bool} A value of true if the specified object intersects with this Circle object; otherwise false.
- */
- public static intersects(a: Phaser.Circle, b: Phaser.Circle): bool {
- return (Phaser.CircleUtils.distanceBetween(a, b) <= (a.radius + b.radius));
- }
-
- /**
- * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
- * @method circumferencePoint
- * @param {Phaser.Circle} a The first Circle object.
- * @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from.
- * @param {bool} asDegrees Is the given angle in radians (false) or degrees (true)?
- * @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created.
- * @return {Phaser.Point} The Point object holding the result.
- */
- public static circumferencePoint(a: Phaser.Circle, angle: number, asDegrees: bool = false, out: Phaser.Point = new Phaser.Point): Phaser.Point {
-
- if (asDegrees === true)
- {
- angle = angle * Phaser.GameMath.DEG_TO_RAD;
- }
-
- return out.setTo(a.x + a.radius * Math.cos(angle), a.y + a.radius * Math.sin(angle));
-
- }
-
- /**
- * Checks if the given Circle and Rectangle objects intersect.
- * @method intersectsRectangle
- * @param {Phaser.Circle} c The Circle object to test.
- * @param {Phaser.Rectangle} r The Rectangle object to test.
- * @return {bool} True if the two objects intersect, otherwise false.
- */
- public static intersectsRectangle(c: Phaser.Circle, r: Phaser.Rectangle): bool {
-
- var cx: number = Math.abs(c.x - r.x - r.halfWidth);
- var xDist: number = r.halfWidth + c.radius;
-
- if (cx > xDist)
- {
- return false;
- }
-
- var cy: number = Math.abs(c.y - r.y - r.halfHeight);
- var yDist: number = r.halfHeight + c.radius;
-
- if (cy > yDist)
- {
- return false;
- }
-
- if (cx <= r.halfWidth || cy <= r.halfHeight)
- {
- return true;
- }
-
- var xCornerDist: number = cx - r.halfWidth;
- var yCornerDist: number = cy - r.halfHeight;
- var xCornerDistSq = xCornerDist * xCornerDist;
- var yCornerDistSq = yCornerDist * yCornerDist;
- var maxCornerDistSq = c.radius * c.radius;
-
- return xCornerDistSq + yCornerDistSq <= maxCornerDistSq;
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/utils/ColorUtils.ts b/wip/TS Source/utils/ColorUtils.ts
deleted file mode 100644
index 1325f9dc..00000000
--- a/wip/TS Source/utils/ColorUtils.ts
+++ /dev/null
@@ -1,586 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- /**
- * A collection of methods useful for manipulating and comparing colors.
- *
- * @class ColorUtils
- */
- export class ColorUtils {
-
- /**
- * A reference to the currently running Game.
- * @property game
- * @type {Phaser.Game}
- */
- public static game: Phaser.Game;
-
- /**
- * Given an alpha and 3 color values this will return an integer representation of it
- *
- * @method getColor32
- * @param {Number} alpha The Alpha value (between 0 and 255)
- * @param {Number} red The Red channel value (between 0 and 255)
- * @param {Number} green The Green channel value (between 0 and 255)
- * @param {Number} blue The Blue channel value (between 0 and 255)
- * @return {Number} A native color value integer (format: 0xAARRGGBB)
- */
- public static getColor32(alpha: number, red: number, green: number, blue: number): number {
- return alpha << 24 | red << 16 | green << 8 | blue;
- }
-
- /**
- * Given 3 color values this will return an integer representation of it.
- *
- * @method getColor
- * @param {Number} red The Red channel value (between 0 and 255)
- * @param {Number} green The Green channel value (between 0 and 255)
- * @param {Number} blue The Blue channel value (between 0 and 255)
- * @return {Number} A native color value integer (format: 0xRRGGBB)
- */
- public static getColor(red: number, green: number, blue: number): number {
- return red << 16 | green << 8 | blue;
- }
-
- /**
- * Get HSV color wheel values in an array which will be 360 elements in size.
- *
- * @method getHSVColorWheel
- * @param {Number} alpha Alpha value for each color of the color wheel, between 0 (transparent) and 255 (opaque)
- * @return {Array} An array containing 360 elements corresponding to the HSV color wheel.
- */
- public static getHSVColorWheel(alpha: number = 255):number[] {
-
- var colors = [];
-
- for (var c: number = 0; c <= 359; c++)
- {
- colors[c] = Phaser.ColorUtils.getWebRGB(Phaser.ColorUtils.HSVtoRGB(c, 1.0, 1.0, alpha));
- }
-
- return colors;
-
- }
-
- /**
- * Converts the given hex string into an object containing the RGB values.
- *
- * @method hexToRGB
- * @param {String} The string hex color to convert.
- * @return {Object} An object with 3 properties: r,g and b.
- */
- public static hexToRGB(h: string) {
-
- var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h;
- var r = parseInt(hex16.substring(0, 2), 16);
- var g = parseInt(hex16.substring(2, 4), 16);
- var b = parseInt(hex16.substring(4, 6), 16);
-
- return {
- r: r,
- g: g,
- b: b
- }
-
- }
-
- /**
- * Returns a Complementary Color Harmony for the given color.
- *
A complementary hue is one directly opposite the color given on the color wheel
- *
Value returned in 0xAARRGGBB format with Alpha set to 255.
- *
- * @method getComplementHarmony
- * @param {Number} color The color to base the harmony on.
- * @return {Number} 0xAARRGGBB format color value.
- */
- public static getComplementHarmony(color: number): number {
-
- var hsv: any = Phaser.ColorUtils.RGBtoHSV(color);
-
- var opposite: number = Phaser.ColorUtils.game.math.wrapValue(hsv.hue, 180, 359);
-
- return Phaser.ColorUtils.HSVtoRGB(opposite, 1.0, 1.0);
-
- }
-
- /**
- * Returns an Analogous Color Harmony for the given color.
- *
An Analogous harmony are hues adjacent to each other on the color wheel
- *
Values returned in 0xAARRGGBB format with Alpha set to 255.
- *
- * @method getAnalogousHarmony
- * @param {Number} color The color to base the harmony on.
- * @param {Number} threshold Control how adjacent the colors will be (default +- 30 degrees)
- * @return {Object} Object containing 3 properties: color1 (the original color), color2 (the warmer analogous color) and color3 (the colder analogous color)
- */
- public static getAnalogousHarmony(color: number, threshold: number = 30) {
-
- var hsv: any = Phaser.ColorUtils.RGBtoHSV(color);
-
- if (threshold > 359 || threshold < 0)
- {
- throw Error("Color Warning: Invalid threshold given to getAnalogousHarmony()");
- }
-
- var warmer: number = Phaser.ColorUtils.game.math.wrapValue(hsv.hue, 359 - threshold, 359);
- var colder: number = Phaser.ColorUtils.game.math.wrapValue(hsv.hue, threshold, 359);
-
- return { color1: color, color2: Phaser.ColorUtils.HSVtoRGB(warmer, 1.0, 1.0), color3: Phaser.ColorUtils.HSVtoRGB(colder, 1.0, 1.0), hue1: hsv.hue, hue2: warmer, hue3: colder }
-
- }
-
- /**
- * Returns an Split Complement Color Harmony for the given color.
- *
A Split Complement harmony are the two hues on either side of the color's Complement
- *
Values returned in 0xAARRGGBB format with Alpha set to 255.
- *
- * @method getSplitComplementHarmony
- * @param {Number} color The color to base the harmony on
- * @param {Number} threshold Control how adjacent the colors will be to the Complement (default +- 30 degrees)
- * @return {Object} An object containing 3 properties: color1 (the original color), color2 (the warmer analogous color) and color3 (the colder analogous color)
- */
- public static getSplitComplementHarmony(color: number, threshold: number = 30): any {
-
- var hsv: any = Phaser.ColorUtils.RGBtoHSV(color);
-
- if (threshold >= 359 || threshold <= 0)
- {
- throw Error("Phaser.ColorUtils Warning: Invalid threshold given to getSplitComplementHarmony()");
- }
-
- var opposite: number = Phaser.ColorUtils.game.math.wrapValue(hsv.hue, 180, 359);
-
- var warmer: number = Phaser.ColorUtils.game.math.wrapValue(hsv.hue, opposite - threshold, 359);
- var colder: number = Phaser.ColorUtils.game.math.wrapValue(hsv.hue, opposite + threshold, 359);
-
- return { color1: color, color2: Phaser.ColorUtils.HSVtoRGB(warmer, hsv.saturation, hsv.value), color3: Phaser.ColorUtils.HSVtoRGB(colder, hsv.saturation, hsv.value), hue1: hsv.hue, hue2: warmer, hue3: colder }
- }
-
- /**
- * Returns a Triadic Color Harmony for the given color.
- *
A Triadic harmony are 3 hues equidistant from each other on the color wheel
- *
Values returned in 0xAARRGGBB format with Alpha set to 255.
- *
- * @method getTriadicHarmony
- * @param {Number} color The color to base the harmony on.
- * @return {Object} An Object containing 3 properties: color1 (the original color), color2 and color3 (the equidistant colors)
- */
- public static getTriadicHarmony(color: number): any {
-
- var hsv: any = Phaser.ColorUtils.RGBtoHSV(color);
-
- var triadic1: number = Phaser.ColorUtils.game.math.wrapValue(hsv.hue, 120, 359);
- var triadic2: number = Phaser.ColorUtils.game.math.wrapValue(triadic1, 120, 359);
-
- return { color1: color, color2: Phaser.ColorUtils.HSVtoRGB(triadic1, 1.0, 1.0), color3: Phaser.ColorUtils.HSVtoRGB(triadic2, 1.0, 1.0) }
-
- }
-
- /**
- * Returns a string containing handy information about the given color including string hex value,
- * RGB format information and HSL information. Each section starts on a newline, 3 lines in total.
- *
- * @method getColorInfo
- * @param {Number} color A color value in the format 0xAARRGGBB
- * @return {String} string containing the 3 lines of information
- */
- public static getColorInfo(color: number): string {
-
- var argb: any = Phaser.ColorUtils.getRGB(color);
- var hsl: any = Phaser.ColorUtils.RGBtoHSV(color);
-
- // Hex format
- var result: string = Phaser.ColorUtils.RGBtoHexstring(color) + "\n";
-
- // RGB format
- result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n";
-
- // HSL info
- result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness);
-
- return result;
-
- }
-
- /**
- * Return a string representation of the color in the format 0xAARRGGBB
- *
- * @method RGBtoHexstring
- * @param {Number} color The color to get the string representation for
- * @return {String A string of length 10 characters in the format 0xAARRGGBB
- */
- public static RGBtoHexstring(color: number): string {
-
- var argb: any = Phaser.ColorUtils.getRGB(color);
-
- return "0x" + Phaser.ColorUtils.colorToHexstring(argb.alpha) + Phaser.ColorUtils.colorToHexstring(argb.red) + Phaser.ColorUtils.colorToHexstring(argb.green) + Phaser.ColorUtils.colorToHexstring(argb.blue);
-
- }
-
- /**
- * Return a string representation of the color in the format #RRGGBB
- *
- * @method RGBtoWebstring
- * @param {Number} color The color to get the string representation for
- * @return {String} A string of length 10 characters in the format 0xAARRGGBB
- */
- public static RGBtoWebstring(color: number): string {
-
- var argb: any = Phaser.ColorUtils.getRGB(color);
-
- return "#" + Phaser.ColorUtils.colorToHexstring(argb.red) + Phaser.ColorUtils.colorToHexstring(argb.green) + Phaser.ColorUtils.colorToHexstring(argb.blue);
-
- }
-
- /**
- * Return a string containing a hex representation of the given color
- *
- * @method colorToHexstring
- * @param {Number} color The color channel to get the hex value for, must be a value between 0 and 255)
- * @return {String} A string of length 2 characters, i.e. 255 = FF, 0 = 00
- */
- public static colorToHexstring(color: number): string {
-
- var digits: string = "0123456789ABCDEF";
-
- var lsd: number = color % 16;
- var msd: number = (color - lsd) / 16;
-
- var hexified: string = digits.charAt(msd) + digits.charAt(lsd);
-
- return hexified;
-
- }
-
- /**
- * Convert a HSV (hue, saturation, lightness) color space value to an RGB color
- *
- * @method HSVtoRGB
- * @param {Number} h Hue degree, between 0 and 359
- * @param {Number} s Saturation, between 0.0 (grey) and 1.0
- * @param {Number} v Value, between 0.0 (black) and 1.0
- * @param {Number} alpha Alpha value to set per color (between 0 and 255)
- * @return {Number} 32-bit ARGB color value (0xAARRGGBB)
- */
- static HSVtoRGB(h: number, s: number, v: number, alpha: number = 255): number {
-
- var result: number;
-
- if (s == 0.0)
- {
- result = Phaser.ColorUtils.getColor32(alpha, v * 255, v * 255, v * 255);
- }
- else
- {
- h = h / 60.0;
- var f: number = h - Math.floor(h);
- var p: number = v * (1.0 - s);
- var q: number = v * (1.0 - s * f);
- var t: number = v * (1.0 - s * (1.0 - f));
-
- switch (Math.floor(h))
- {
- case 0:
- result = Phaser.ColorUtils.getColor32(alpha, v * 255, t * 255, p * 255);
- break;
-
- case 1:
- result = Phaser.ColorUtils.getColor32(alpha, q * 255, v * 255, p * 255);
- break;
-
- case 2:
- result = Phaser.ColorUtils.getColor32(alpha, p * 255, v * 255, t * 255);
- break;
-
- case 3:
- result = Phaser.ColorUtils.getColor32(alpha, p * 255, q * 255, v * 255);
- break;
-
- case 4:
- result = Phaser.ColorUtils.getColor32(alpha, t * 255, p * 255, v * 255);
- break;
-
- case 5:
- result = Phaser.ColorUtils.getColor32(alpha, v * 255, p * 255, q * 255);
- break;
-
- default:
- throw new Error("Phaser.ColorUtils.HSVtoRGB : Unknown color");
- }
- }
-
- return result;
-
- }
-
- /**
- * Convert an RGB color value to an object containing the HSV color space values: Hue, Saturation and Lightness
- *
- * @method RGBtoHSV
- * @param {Number} color In format 0xRRGGBB
- * @return {Object} An Object with the properties hue (from 0 to 360), saturation (from 0 to 1.0) and lightness (from 0 to 1.0, also available under .value)
- */
- public static RGBtoHSV(color: number): any {
-
- var rgb: any = Phaser.ColorUtils.getRGB(color);
-
- var red: number = rgb.red / 255;
- var green: number = rgb.green / 255;
- var blue: number = rgb.blue / 255;
-
- var min: number = Math.min(red, green, blue);
- var max: number = Math.max(red, green, blue);
- var delta: number = max - min;
- var lightness: number = (max + min) / 2;
- var hue: number;
- var saturation: number;
-
- // Grey color, no chroma
- if (delta == 0)
- {
- hue = 0;
- saturation = 0;
- }
- else
- {
- if (lightness < 0.5)
- {
- saturation = delta / (max + min);
- }
- else
- {
- saturation = delta / (2 - max - min);
- }
-
- var delta_r: number = (((max - red) / 6) + (delta / 2)) / delta;
- var delta_g: number = (((max - green) / 6) + (delta / 2)) / delta;
- var delta_b: number = (((max - blue) / 6) + (delta / 2)) / delta;
-
- if (red == max)
- {
- hue = delta_b - delta_g;
- }
- else if (green == max)
- {
- hue = (1 / 3) + delta_r - delta_b;
- }
- else if (blue == max)
- {
- hue = (2 / 3) + delta_g - delta_r;
- }
-
- if (hue < 0)
- {
- hue += 1;
- }
-
- if (hue > 1)
- {
- hue -= 1;
- }
- }
-
- // Keep the value with 0 to 359
- hue *= 360;
- hue = Math.round(hue);
-
- return { hue: hue, saturation: saturation, lightness: lightness, value: lightness };
-
- }
-
- /**
- * Interpolates the two given colours based on the supplied step and currentStep properties.
- * @method interpolateColor
- * @param {Number} color1
- * @param {Number} color2
- * @param {Number} steps
- * @param {Number} currentStep
- * @param {Number} alpha
- * @return {Number} The interpolated color value.
- */
- public static interpolateColor(color1: number, color2: number, steps: number, currentStep: number, alpha: number = 255): number {
-
- var src1: any = Phaser.ColorUtils.getRGB(color1);
- var src2: any = Phaser.ColorUtils.getRGB(color2);
-
- var r: number = (((src2.red - src1.red) * currentStep) / steps) + src1.red;
- var g: number = (((src2.green - src1.green) * currentStep) / steps) + src1.green;
- var b: number = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue;
-
- return Phaser.ColorUtils.getColor32(alpha, r, g, b);
-
- }
-
- /**
- * Interpolates the two given colours based on the supplied step and currentStep properties.
- * @method interpolateColorWithRGB
- * @param {Number} color
- * @param {Number} r
- * @param {Number} g
- * @param {Number} b
- * @param {Number} steps
- * @param {Number} currentStep
- * @return {Number} The interpolated color value.
- */
- public static interpolateColorWithRGB(color: number, r: number, g: number, b: number, steps: number, currentStep: number): number {
-
- var src: any = Phaser.ColorUtils.getRGB(color);
-
- var or: number = (((r - src.red) * currentStep) / steps) + src.red;
- var og: number = (((g - src.green) * currentStep) / steps) + src.green;
- var ob: number = (((b - src.blue) * currentStep) / steps) + src.blue;
-
- return Phaser.ColorUtils.getColor(or, og, ob);
-
- }
-
- /**
- * Interpolates the two given colours based on the supplied step and currentStep properties.
- * @method interpolateRGB
- * @param {Number} r1
- * @param {Number} g1
- * @param {Number} b1
- * @param {Number} r2
- * @param {Number} g2
- * @param {Number} b2
- * @param {Number} steps
- * @param {Number} currentStep
- * @return {Number} The interpolated color value.
- */
- public static interpolateRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, steps: number, currentStep: number): number {
-
- var r: number = (((r2 - r1) * currentStep) / steps) + r1;
- var g: number = (((g2 - g1) * currentStep) / steps) + g1;
- var b: number = (((b2 - b1) * currentStep) / steps) + b1;
-
- return Phaser.ColorUtils.getColor(r, g, b);
-
- }
-
- /**
- * Returns a random color value between black and white
- *
Set the min value to start each channel from the given offset.
- *
Set the max value to restrict the maximum color used per channel
- *
- * @method getRandomColor
- * @param {Number} min The lowest value to use for the color
- * @param {Number} max The highest value to use for the color
- * @param {Number} alpha The alpha value of the returning color (default 255 = fully opaque)
- * @return {Number} 32-bit color value with alpha
- */
- public static getRandomColor(min: number = 0, max: number = 255, alpha: number = 255): number {
-
- // Sanity checks
- if (max > 255)
- {
- return Phaser.ColorUtils.getColor(255, 255, 255);
- }
-
- if (min > max)
- {
- return Phaser.ColorUtils.getColor(255, 255, 255);
- }
-
- var red: number = min + Math.round(Math.random() * (max - min));
- var green: number = min + Math.round(Math.random() * (max - min));
- var blue: number = min + Math.round(Math.random() * (max - min));
-
- return Phaser.ColorUtils.getColor32(alpha, red, green, blue);
-
- }
-
- /**
- * Return the component parts of a color as an Object with the properties alpha, red, green, blue
- *
- *
Alpha will only be set if it exist in the given color (0xAARRGGBB)
- *
- * @method getRGB
- * @param {Number} color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB)
- * @return {Object} An Object with properties: alpha, red, green, blue
- */
- public static getRGB(color: number): any {
- return { alpha: color >>> 24, red: color >> 16 & 0xFF, green: color >> 8 & 0xFF, blue: color & 0xFF };
- }
-
- /**
- * Returns a CSS friendly string value from the given color.
- * @method getWebRGB
- * @param {Number} color
- * @return {String} A string in the format: 'rgba(r,g,b,a)'
- */
- public static getWebRGB(color: number): any {
-
- var alpha: number = (color >>> 24) / 255;
- var red: number = color >> 16 & 0xFF;
- var green: number = color >> 8 & 0xFF;
- var blue: number = color & 0xFF;
-
- return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')';
-
- }
-
- /**
- * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255
- *
- * @method getAlpha
- * @param {Number} color In the format 0xAARRGGBB
- * @return {Number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent))
- */
- public static getAlpha(color: number): number {
- return color >>> 24;
- }
-
- /**
- * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1
- *
- * @method getAlphaFloat
- * @param {Number} color In the format 0xAARRGGBB
- * @return {Number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent))
- */
- public static getAlphaFloat(color: number): number {
- return (color >>> 24) / 255;
- }
-
- /**
- * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255
- *
- * @method getRed
- * @param {Number} color In the format 0xAARRGGBB
- * @return {Number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red)
- */
- public static getRed(color: number): number {
- return color >> 16 & 0xFF;
- }
-
- /**
- * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255
- *
- * @method getGreen
- * @param {Number} color In the format 0xAARRGGBB
- * @return {Number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green)
- */
- public static getGreen(color: number): number {
- return color >> 8 & 0xFF;
- }
-
- /**
- * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255
- *
- * @method getBlue
- * @param {Number} color In the format 0xAARRGGBB
- * @return {Number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue)
- */
- public static getBlue(color: number): number {
- return color & 0xFF;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/utils/DebugUtils.ts b/wip/TS Source/utils/DebugUtils.ts
deleted file mode 100644
index a96cc997..00000000
--- a/wip/TS Source/utils/DebugUtils.ts
+++ /dev/null
@@ -1,441 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- /**
- * A collection of methods for displaying debug information about game objects.
- *
- * @class DebugUtils
- */
- export class DebugUtils {
-
- /**
- * A reference to the currently running Game.
- * @property game
- * @type {Phaser.Game}
- */
- public static game: Phaser.Game;
-
- /**
- * The context to which the debug info will be drawn.
- * Defaults to the Game.Stage.context, but can be redirected anywhere.
- * @property context
- * @type {CanvasRenderingContext2D}
- */
- public static context: CanvasRenderingContext2D;
-
- /**
- * An internally used value that holds the X value of the debug text to be rendered.
- * @property currentX
- * @type {Number}
- */
- public static currentX: number;
-
- /**
- * An internally used value that holds the Y value of the debug text to be rendered.
- * @property currentY
- * @type {Number}
- */
- public static currentY: number;
-
- /**
- * The font of the debug text to be rendered.
- * @property font
- * @type {String}
- */
- public static font: string = '14px Courier';
-
- /**
- * The height in pixels of a line of debug text. If you adjust the font size then adjust this accordingly.
- * @property lineHeight
- * @type {Number}
- */
- public static lineHeight: number = 16;
-
- /**
- * The color of the debug text to be rendered in CSS string format (i.e. 'rgb(r,g,b)')
- * @property font
- * @type {String}
- */
- public static currentColor: string;
-
- /**
- * If set to true this will render a shadow below any debug text, often making it easier to read.
- * @property renderShadow
- * @type {bool}
- */
- public static renderShadow: bool = true;
-
- /**
- * Internal method that resets the debug output values.
- * @method start
- * @param {Number} x The X value the debug info will start from.
- * @param {Number} y The Y value the debug info will start from.
- * @param {String} color The color the debug info will drawn in.
- */
- public static start(x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- Phaser.DebugUtils.currentX = x;
- Phaser.DebugUtils.currentY = y;
- Phaser.DebugUtils.currentColor = color;
-
- Phaser.DebugUtils.context.fillStyle = color;
- Phaser.DebugUtils.context.font = Phaser.DebugUtils.font;
-
- }
-
- /**
- * Internal method that outputs a single line of text.
- * @method line
- * @param {String} text The line of text to draw.
- * @param {Number} x The X value the debug info will start from.
- * @param {Number} y The Y value the debug info will start from.
- */
- public static line(text: string, x:number = null, y:number = null) {
-
- if (x !== null)
- {
- Phaser.DebugUtils.currentX = x;
- }
-
- if (y !== null)
- {
- Phaser.DebugUtils.currentY = y;
- }
-
- if (Phaser.DebugUtils.renderShadow)
- {
- Phaser.DebugUtils.context.fillStyle = 'rgb(0,0,0)';
- Phaser.DebugUtils.context.fillText(text, Phaser.DebugUtils.currentX + 1, Phaser.DebugUtils.currentY + 1);
- Phaser.DebugUtils.context.fillStyle = Phaser.DebugUtils.currentColor;
- }
-
- Phaser.DebugUtils.context.fillText(text, Phaser.DebugUtils.currentX, Phaser.DebugUtils.currentY);
-
- Phaser.DebugUtils.currentY += Phaser.DebugUtils.lineHeight;
-
- }
-
- public static renderSpriteCorners(sprite: Phaser.Sprite, color: string = 'rgb(255,0,255)') {
-
- Phaser.DebugUtils.start(0, 0, color);
-
- Phaser.DebugUtils.line('x: ' + Math.floor(sprite.transform.upperLeft.x) + ' y: ' + Math.floor(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
- Phaser.DebugUtils.line('x: ' + Math.floor(sprite.transform.upperRight.x) + ' y: ' + Math.floor(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
- Phaser.DebugUtils.line('x: ' + Math.floor(sprite.transform.bottomLeft.x) + ' y: ' + Math.floor(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
- Phaser.DebugUtils.line('x: ' + Math.floor(sprite.transform.bottomRight.x) + ' y: ' + Math.floor(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
-
- }
-
- /**
- * Render debug infos. (including id, position, rotation, scrolling factor, worldBounds and some other properties)
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- public static renderSoundInfo(sound: Phaser.Sound, x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- Phaser.DebugUtils.start(x, y, color);
-
- Phaser.DebugUtils.line('Sound: ' + sound.key + ' Locked: ' + sound.game.sound.touchLocked + ' Pending Playback: ' + sound.pendingPlayback);
- Phaser.DebugUtils.line('Decoded: ' + sound.isDecoded + ' Decoding: ' + sound.isDecoding);
- Phaser.DebugUtils.line('Total Duration: ' + sound.totalDuration + ' Playing: ' + sound.isPlaying);
- Phaser.DebugUtils.line('Time: ' + sound.currentTime);
- Phaser.DebugUtils.line('Volume: ' + sound.volume + ' Muted: ' + sound.mute);
- Phaser.DebugUtils.line('WebAudio: ' + sound.usingWebAudio + ' Audio: ' + sound.usingAudioTag);
-
- if (sound.currentMarker !== '')
- {
- Phaser.DebugUtils.line('Marker: ' + sound.currentMarker + ' Duration: ' + sound.duration);
- Phaser.DebugUtils.line('Start: ' + sound.markers[sound.currentMarker].start + ' Stop: ' + sound.markers[sound.currentMarker].stop);
- Phaser.DebugUtils.line('Position: ' + sound.position);
- }
-
- }
-
- /**
- * Render debug infos. (including id, position, rotation, scrolling factor, worldBounds and some other properties)
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- static renderCameraInfo(camera: Phaser.Camera, x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- Phaser.DebugUtils.start(x, y, color);
- Phaser.DebugUtils.line('Camera ID: ' + camera.ID + ' (' + camera.screenView.width + ' x ' + camera.screenView.height + ')');
- Phaser.DebugUtils.line('X: ' + camera.x + ' Y: ' + camera.y + ' Rotation: ' + camera.transform.rotation);
- Phaser.DebugUtils.line('WorldView X: ' + camera.worldView.x + ' Y: ' + camera.worldView.y + ' W: ' + camera.worldView.width + ' H: ' + camera.worldView.height);
- Phaser.DebugUtils.line('ScreenView X: ' + camera.screenView.x + ' Y: ' + camera.screenView.y + ' W: ' + camera.screenView.width + ' H: ' + camera.screenView.height);
-
- if (camera.worldBounds)
- {
- Phaser.DebugUtils.line('Bounds: ' + camera.worldBounds.width + ' x ' + camera.worldBounds.height);
- }
-
- }
-
- /**
- * Renders the Pointer.circle object onto the stage in green if down or red if up.
- * @method renderDebug
- */
- static renderPointer(pointer: Phaser.Pointer, hideIfUp: bool = false, downColor: string = 'rgba(0,255,0,0.5)', upColor: string = 'rgba(255,0,0,0.5)', color: string = 'rgb(255,255,255)') {
-
- if (hideIfUp == true && pointer.isUp == true)
- {
- return;
- }
-
- Phaser.DebugUtils.context.beginPath();
- Phaser.DebugUtils.context.arc(pointer.x, pointer.y, pointer.circle.radius, 0, Math.PI * 2);
-
- if (pointer.active)
- {
- Phaser.DebugUtils.context.fillStyle = downColor;
- }
- else
- {
- Phaser.DebugUtils.context.fillStyle = upColor;
- }
-
- Phaser.DebugUtils.context.fill();
- Phaser.DebugUtils.context.closePath();
-
- // Render the points
- Phaser.DebugUtils.context.beginPath();
- Phaser.DebugUtils.context.moveTo(pointer.positionDown.x, pointer.positionDown.y);
- Phaser.DebugUtils.context.lineTo(pointer.position.x, pointer.position.y);
- Phaser.DebugUtils.context.lineWidth = 2;
- Phaser.DebugUtils.context.stroke();
- Phaser.DebugUtils.context.closePath();
-
- // Render the text
- Phaser.DebugUtils.start(pointer.x, pointer.y - 100, color);
-
- Phaser.DebugUtils.line('ID: ' + pointer.id + " Active: " + pointer.active);
- Phaser.DebugUtils.line('World X: ' + pointer.worldX + " World Y: " + pointer.worldY);
- Phaser.DebugUtils.line('Screen X: ' + pointer.x + " Screen Y: " + pointer.y);
- Phaser.DebugUtils.line('Duration: ' + pointer.duration + " ms");
-
- }
-
- /**
- * Render Sprite Input Debug information
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- static renderSpriteInputInfo(sprite: Phaser.Sprite, x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- Phaser.DebugUtils.start(x, y, color);
-
- Phaser.DebugUtils.line('Sprite Input: (' + sprite.width + ' x ' + sprite.height + ')');
- Phaser.DebugUtils.line('x: ' + sprite.input.pointerX().toFixed(1) + ' y: ' + sprite.input.pointerY().toFixed(1));
- Phaser.DebugUtils.line('over: ' + sprite.input.pointerOver() + ' duration: ' + sprite.input.overDuration().toFixed(0));
- Phaser.DebugUtils.line('down: ' + sprite.input.pointerDown() + ' duration: ' + sprite.input.downDuration().toFixed(0));
- Phaser.DebugUtils.line('just over: ' + sprite.input.justOver() + ' just out: ' + sprite.input.justOut());
-
- }
-
- /**
- * Render debug information about the Input object.
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- static renderInputInfo(x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- Phaser.DebugUtils.start(x, y, color);
-
- if (Phaser.DebugUtils.game.input.camera)
- {
- Phaser.DebugUtils.line('Input - Camera: ' + Phaser.DebugUtils.game.input.camera.ID);
- }
- else
- {
- Phaser.DebugUtils.line('Input - Camera: null');
- }
-
- Phaser.DebugUtils.line('X: ' + Phaser.DebugUtils.game.input.x + ' Y: ' + Phaser.DebugUtils.game.input.y);
- Phaser.DebugUtils.line('World X: ' + Phaser.DebugUtils.game.input.worldX + ' World Y: ' + Phaser.DebugUtils.game.input.worldY);
- Phaser.DebugUtils.line('Scale X: ' + Phaser.DebugUtils.game.input.scale.x.toFixed(1) + ' Scale Y: ' + Phaser.DebugUtils.game.input.scale.x.toFixed(1));
- Phaser.DebugUtils.line('Screen X: ' + Phaser.DebugUtils.game.input.activePointer.screenX + ' Screen Y: ' + Phaser.DebugUtils.game.input.activePointer.screenY);
-
- }
-
- static renderSpriteWorldView(sprite: Phaser.Sprite, x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- Phaser.DebugUtils.start(x, y, color);
- Phaser.DebugUtils.line('Sprite World Coords (' + sprite.width + ' x ' + sprite.height + ')');
- Phaser.DebugUtils.line('x: ' + sprite.worldView.x + ' y: ' + sprite.worldView.y);
- Phaser.DebugUtils.line('bottom: ' + sprite.worldView.bottom + ' right: ' + sprite.worldView.right.toFixed(1));
-
- }
-
- static renderSpriteWorldViewBounds(sprite: Phaser.Sprite, color: string = 'rgba(0,255,0,0.3)') {
-
- Phaser.DebugUtils.renderRectangle(sprite.worldView, color);
-
- }
-
- /**
- * Render debug infos. (including name, bounds info, position and some other properties)
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- static renderSpriteInfo(sprite: Phaser.Sprite, x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- Phaser.DebugUtils.start(x, y, color);
- Phaser.DebugUtils.line('Sprite: ' + ' (' + sprite.width + ' x ' + sprite.height + ') origin: ' + sprite.transform.origin.x + ' x ' + sprite.transform.origin.y);
- Phaser.DebugUtils.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1));
- Phaser.DebugUtils.line('wx: ' + sprite.worldView.x + ' wy: ' + sprite.worldView.y + ' ww: ' + sprite.worldView.width.toFixed(1) + ' wh: ' + sprite.worldView.height.toFixed(1) + ' wb: ' + sprite.worldView.bottom + ' wr: ' + sprite.worldView.right);
- Phaser.DebugUtils.line('sx: ' + sprite.transform.scale.x.toFixed(1) + ' sy: ' + sprite.transform.scale.y.toFixed(1));
- Phaser.DebugUtils.line('tx: ' + sprite.texture.width.toFixed(1) + ' ty: ' + sprite.texture.height.toFixed(1));
- Phaser.DebugUtils.line('center x: ' + sprite.transform.center.x + ' y: ' + sprite.transform.center.y);
- Phaser.DebugUtils.line('cameraView x: ' + sprite.cameraView.x + ' y: ' + sprite.cameraView.y + ' width: ' + sprite.cameraView.width + ' height: ' + sprite.cameraView.height);
- Phaser.DebugUtils.line('inCamera: ' + Phaser.DebugUtils.game.renderer.spriteRenderer.inCamera(Phaser.DebugUtils.game.camera, sprite));
-
- }
-
- static renderSpriteBounds(sprite: Phaser.Sprite, camera: Phaser.Camera = null, color: string = 'rgba(0,255,0,0.2)') {
-
- if (camera == null)
- {
- camera = Phaser.DebugUtils.game.camera;
- }
-
- var dx = sprite.worldView.x;
- var dy = sprite.worldView.y;
-
- Phaser.DebugUtils.context.fillStyle = color;
- Phaser.DebugUtils.context.fillRect(dx, dy, sprite.width, sprite.height);
-
- }
-
- static renderPixel(x: number, y: number, fillStyle: string = 'rgba(0,255,0,1)') {
-
- Phaser.DebugUtils.context.fillStyle = fillStyle;
- Phaser.DebugUtils.context.fillRect(x, y, 1, 1);
-
- }
-
- static renderPoint(point: Phaser.Point, fillStyle: string = 'rgba(0,255,0,1)') {
-
- Phaser.DebugUtils.context.fillStyle = fillStyle;
- Phaser.DebugUtils.context.fillRect(point.x, point.y, 1, 1);
-
- }
-
- static renderRectangle(rect: Phaser.Rectangle, fillStyle: string = 'rgba(0,255,0,0.3)') {
-
- Phaser.DebugUtils.context.fillStyle = fillStyle;
- Phaser.DebugUtils.context.fillRect(rect.x, rect.y, rect.width, rect.height);
-
- }
-
- static renderCircle(circle: Phaser.Circle, fillStyle: string = 'rgba(0,255,0,0.3)') {
-
- Phaser.DebugUtils.context.fillStyle = fillStyle;
- Phaser.DebugUtils.context.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2, false);
- Phaser.DebugUtils.context.fill();
-
- }
-
- /**
- * Render text
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- static renderText(text: string, x: number, y: number, color: string = 'rgb(255,255,255)', font: string = '16px Courier') {
-
- Phaser.DebugUtils.context.font = font;
- Phaser.DebugUtils.context.fillStyle = color;
- Phaser.DebugUtils.context.fillText(text, x, y);
-
- }
-
- /*
- public render(context:CanvasRenderingContext2D) {
-
- context.beginPath();
- context.strokeStyle = 'rgb(0,255,0)';
- context.strokeRect(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight, this.bounds.width, this.bounds.height);
- context.stroke();
- context.closePath();
-
- // center point
- context.fillStyle = 'rgb(0,255,0)';
- context.fillRect(this.position.x, this.position.y, 2, 2);
-
- if (this.touching & Phaser.Types.LEFT)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
- context.lineTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
- context.stroke();
- context.closePath();
- }
- if (this.touching & Phaser.Types.RIGHT)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
- context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
- context.stroke();
- context.closePath();
- }
-
- if (this.touching & Phaser.Types.UP)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
- context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
- context.stroke();
- context.closePath();
- }
- if (this.touching & Phaser.Types.DOWN)
- {
- context.beginPath();
- context.strokeStyle = 'rgb(255,0,0)';
- context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
- context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
- context.stroke();
- context.closePath();
- }
-
- }
- */
-
- /**
- * Render debug infos. (including name, bounds info, position and some other properties)
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- /*
- public renderDebugInfo(x: number, y: number, color: string = 'rgb(255,255,255)') {
-
- this.sprite.texture.context.fillStyle = color;
- this.sprite.texture.context.fillText('Sprite: (' + this.sprite.width + ' x ' + this.sprite.height + ')', x, y);
- //this.sprite.texture.context.fillText('x: ' + this._sprite.frameBounds.x.toFixed(1) + ' y: ' + this._sprite.frameBounds.y.toFixed(1) + ' rotation: ' + this._sprite.rotation.toFixed(1), x, y + 14);
- this.sprite.texture.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.sprite.transform.rotation.toFixed(0), x, y + 14);
- this.sprite.texture.context.fillText('vx: ' + this.velocity.x.toFixed(1) + ' vy: ' + this.velocity.y.toFixed(1), x, y + 28);
- this.sprite.texture.context.fillText('acx: ' + this.acceleration.x.toFixed(1) + ' acy: ' + this.acceleration.y.toFixed(1), x, y + 42);
- this.sprite.texture.context.fillText('angVx: ' + this.angularVelocity.toFixed(1) + ' angAc: ' + this.angularAcceleration.toFixed(1), x, y + 56);
-
- }
- */
-
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/utils/PointUtils.ts b/wip/TS Source/utils/PointUtils.ts
deleted file mode 100644
index 89e2b901..00000000
--- a/wip/TS Source/utils/PointUtils.ts
+++ /dev/null
@@ -1,225 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- /**
- * A collection of methods useful for manipulating and comparing Point objects.
- *
- * @class PointUtils
- */
- export class PointUtils {
-
- /**
- * Adds the coordinates of two points together to create a new point.
- * @method add
- * @param {Phaser.Point} a The first Point object.
- * @param {Phaser.Point} b The second Point object.
- * @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created.
- * @return {Phaser.Point} The new Point object.
- */
- public static add(a: Phaser.Point, b: Phaser.Point, out: Phaser.Point = new Phaser.Point): Phaser.Point {
- return out.setTo(a.x + b.x, a.y + b.y);
- }
-
- /**
- * Subtracts the coordinates of two points to create a new point.
- * @method subtract
- * @param {Phaser.Point} a The first Point object.
- * @param {Phaser.Point} b The second Point object.
- * @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created.
- * @return {Phaser.Point} The new Point object.
- */
- public static subtract(a: Phaser.Point, b: Phaser.Point, out: Phaser.Point = new Phaser.Point): Phaser.Point {
- return out.setTo(a.x - b.x, a.y - b.y);
- }
-
- /**
- * Multiplies the coordinates of two points to create a new point.
- * @method subtract
- * @param {Phaser.Point} a The first Point object.
- * @param {Phaser.Point} b The second Point object.
- * @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created.
- * @return {Phaser.Point} The new Point object.
- */
- public static multiply(a: Phaser.Point, b: Phaser.Point, out: Phaser.Point = new Phaser.Point): Phaser.Point {
- return out.setTo(a.x * b.x, a.y * b.y);
- }
-
- /**
- * Divides the coordinates of two points to create a new point.
- * @method subtract
- * @param {Phaser.Point} a The first Point object.
- * @param {Phaser.Point} b The second Point object.
- * @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created.
- * @return {Phaser.Point} The new Point object.
- */
- public static divide(a: Phaser.Point, b: Phaser.Point, out: Phaser.Point = new Phaser.Point): Phaser.Point {
- return out.setTo(a.x / b.x, a.y / b.y);
- }
-
- /**
- * Clamps the Point object values to be between the given min and max
- * @method clamp
- * @param {Phaser.Point} a The point.
- * @param {Number} min The minimum value to clamp this Point to
- * @param {Number} max The maximum value to clamp this Point to
- * @return {Phaser.Point} This Point object.
- */
- public static clamp(a: Phaser.Point, min: number, max: number): Phaser.Point {
-
- Phaser.PointUtils.clampX(a, min, max);
- Phaser.PointUtils.clampY(a, min, max);
- return a;
-
- }
-
- /**
- * Clamps the x value of the given Point object to be between the min and max values.
- * @method clampX
- * @param {Phaser.Point} a The point.
- * @param {Number} min The minimum value to clamp this Point to
- * @param {Number} max The maximum value to clamp this Point to
- * @return {Phaser.Point} This Point object.
- */
- public static clampX(a: Phaser.Point, min: number, max: number): Phaser.Point {
-
- a.x = Math.max(Math.min(a.x, max), min);
- return a;
-
- }
-
- /**
- * Clamps the y value of the given Point object to be between the min and max values.
- * @method clampY
- * @param {Phaser.Point} a The point.
- * @param {Number} min The minimum value to clamp this Point to
- * @param {Number} max The maximum value to clamp this Point to
- * @return {Phaser.Point} This Point object.
- */
- public static clampY(a: Phaser.Point, min: number, max: number): Phaser.Point {
-
- a.y = Math.max(Math.min(a.y, max), min);
- return a;
-
- }
-
- /**
- * Creates a copy of the given Point.
- * @method clone
- * @param {Phaser.Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
- * @return {Phaser.Point} The new Point object.
- */
- public static clone(a: Phaser.Point, output: Phaser.Point = new Phaser.Point): Phaser.Point {
- return output.setTo(a.x, a.y);
- }
-
- /**
- * Returns the distance between the two given Point objects.
- * @method distanceBetween
- * @param {Phaser.Point} a The first Point object.
- * @param {Phaser.Point} b The second Point object.
- * @param {bool} round Round the distance to the nearest integer (default false)
- * @return {Number} The distance between the two Point objects.
- */
- public static distanceBetween(a: Phaser.Point, b: Phaser.Point, round: bool = false): number {
-
- var dx = a.x - b.x;
- var dy = a.y - b.y;
-
- if (round === true)
- {
- return Math.round(Math.sqrt(dx * dx + dy * dy));
- }
- else
- {
- return Math.sqrt(dx * dx + dy * dy);
- }
-
- }
-
- /**
- * Determines whether the two given Point objects are equal. They are considered equal if they have the same x and y values.
- * @method equals
- * @param {Phaser.Point} a The first Point object.
- * @param {Phaser.Point} b The second Point object.
- * @return {bool} A value of true if the Points are equal, otherwise false.
- */
- public static equals(a: Phaser.Point, b: Phaser.Point): bool {
- return (a.x == b.x && a.y == b.y);
- }
-
- /**
- * Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2.
- * The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2).
- * @method interpolate
- * @param {Phaser.Point} pointA The first Point object.
- * @param {Phaser.Point} pointB The second Point object.
- * @param {Number} f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
- * @return {Phaser.Point} The new interpolated Point object.
- */
- //public static interpolate(pointA, pointB, f) {
- // TODO!
- //}
-
- /**
- * Converts a pair of polar coordinates to a Cartesian point coordinate.
- * @method polar
- * @param {Number} length The length coordinate of the polar pair.
- * @param {Number} angle The angle, in radians, of the polar pair.
- * @return {Phaser.Point} The new Cartesian Point object.
- */
- //public static polar(length, angle) {
- // TODO!
- //}
-
- /**
- * Rotates a Point around the x/y coordinates given to the desired angle.
- * @method rotate
- * @param {Phaser.Point} a The Point object to rotate.
- * @param {Number} x The x coordinate of the anchor point
- * @param {Number} y The y coordinate of the anchor point
- * @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to.
- * @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)?
- * @param {Number} distance An optional distance constraint between the Point and the anchor.
- * @return {Phaser.Point} The modified point object
- */
- public static rotate(a: Phaser.Point, x: number, y: number, angle: number, asDegrees: bool = false, distance: number = null): Phaser.Point {
-
- if (asDegrees)
- {
- angle = angle * Phaser.GameMath.DEG_TO_RAD;
- }
-
- // Get distance from origin (cx/cy) to this point
- if (distance === null)
- {
- distance = Math.sqrt(((x - a.x) * (x - a.x)) + ((y - a.y) * (y - a.y)));
- }
-
- return a.setTo(x + distance * Math.cos(angle), y + distance * Math.sin(angle));
-
- }
-
- /**
- * Rotates a Point around the given Point to the desired angle.
- * @method rotateAroundPoint
- * @param {Phaser.Point} a The Point object to rotate.
- * @param {Phaser.Point} b The Point object to serve as point of rotation.
- * @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to.
- * @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)?
- * @param {Number} distance An optional distance constraint between the Point and the anchor.
- * @return {Phaser.Point} The modified point object
- */
- public static rotateAroundPoint(a: Phaser.Point, b: Phaser.Point, angle: number, asDegrees: bool = false, distance: number = null): Phaser.Point {
- return Phaser.PointUtils.rotate(a, b.x, b.y, angle, asDegrees, distance);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/utils/RectangleUtils.ts b/wip/TS Source/utils/RectangleUtils.ts
deleted file mode 100644
index 53fba5e7..00000000
--- a/wip/TS Source/utils/RectangleUtils.ts
+++ /dev/null
@@ -1,211 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- /**
- * A collection of methods useful for manipulating and comparing Rectangle objects.
- *
- * @class RectangleUtils
- */
- export class RectangleUtils {
-
- /**
- * Get the location of the Rectangles top-left corner as a Point object.
- * @method getTopLeftAsPoint
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created.
- * @return {Phaser.Point} The new Point object.
- */
- public static getTopLeftAsPoint(a: Phaser.Rectangle, out: Phaser.Point = new Phaser.Point): Phaser.Point {
- return out.setTo(a.x, a.y);
- }
-
- /**
- * Get the location of the Rectangles bottom-right corner as a Point object.
- * @method getTopLeftAsPoint
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created.
- * @return {Phaser.Point} The new Point object.
- **/
- public static getBottomRightAsPoint(a: Phaser.Rectangle, out: Phaser.Point = new Phaser.Point): Phaser.Point {
- return out.setTo(a.right, a.bottom);
- }
-
- /**
- * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
- * @method inflate
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Number} dx The amount to be added to the left side of the Rectangle.
- * @param {Number} dy The amount to be added to the bottom side of the Rectangle.
- * @return {Phaser.Rectangle} This Rectangle object.
- */
- public static inflate(a: Phaser.Rectangle, dx: number, dy: number): Phaser.Rectangle {
-
- a.x -= dx;
- a.width += 2 * dx;
-
- a.y -= dy;
- a.height += 2 * dy;
-
- return a;
-
- }
-
- /**
- * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.
- * @method inflatePoint
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Phaser.Point} point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.
- * @return {Phaser.Rectangle} The Rectangle object.
- */
- public static inflatePoint(a: Phaser.Rectangle, point: Phaser.Point): Phaser.Rectangle {
- return Phaser.RectangleUtils.inflate(a, point.x, point.y);
- }
-
- /**
- * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
- * @method size
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Phaser.Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
- * @return {Phaser.Point} The size of the Rectangle object
- */
- public static size(a: Phaser.Rectangle, output: Phaser.Point = new Phaser.Point): Phaser.Point {
- return output.setTo(a.width, a.height);
- }
-
- /**
- * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
- * @method clone
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Phaser.Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
- * @return {Phaser.Rectangle}
- */
- public static clone(a: Phaser.Rectangle, output: Phaser.Rectangle = new Phaser.Rectangle): Phaser.Rectangle {
- return output.setTo(a.x, a.y, a.width, a.height);
- }
-
- /**
- * Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
- * @method contains
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Number} x The x coordinate of the point to test.
- * @param {Number} y The y coordinate of the point to test.
- * @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
- */
- public static contains(a: Phaser.Rectangle, x: number, y: number): bool {
- return (x >= a.x && x <= a.right && y >= a.y && y <= a.bottom);
- }
-
- /**
- * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
- * @method containsPoint
- * @param {Phaser.Rectangle} a The Rectangle object.
- * @param {Phaser.Point} point The point object being checked. Can be Point or any object with .x and .y values.
- * @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
- */
- public static containsPoint(a: Phaser.Rectangle, point: Phaser.Point): bool {
- return Phaser.RectangleUtils.contains(a, point.x, point.y);
- }
-
- /**
- * Determines whether the first Rectangle object is fully contained within the second Rectangle object.
- * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
- * @method containsRect
- * @param {Phaser.Rectangle} a The first Rectangle object.
- * @param {Phaser.Rectangle} b The second Rectangle object.
- * @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false.
- */
- public static containsRect(a: Phaser.Rectangle, b: Phaser.Rectangle): bool {
-
- // If the given rect has a larger volume than this one then it can never contain it
- if (a.volume > b.volume)
- {
- return false;
- }
-
- return (a.x >= b.x && a.y >= b.y && a.right <= b.right && a.bottom <= b.bottom);
-
- }
-
- /**
- * Determines whether the two Rectangles are equal.
- * This method compares the x, y, width and height properties of each Rectangle.
- * @method equals
- * @param {Phaser.Rectangle} a The first Rectangle object.
- * @param {Phaser.Rectangle} b The second Rectangle object.
- * @return {bool} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.
- */
- public static equals(a: Phaser.Rectangle, b: Phaser.Rectangle): bool {
- return (a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height);
- }
-
- /**
- * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
- * @method intersection
- * @param {Phaser.Rectangle} a The first Rectangle object.
- * @param {Phaser.Rectangle} b The second Rectangle object.
- * @param {Phaser.Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
- * @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.
- */
- public static intersection(a: Phaser.Rectangle, b: Phaser.Rectangle, out: Phaser.Rectangle = new Phaser.Rectangle): Phaser.Rectangle {
-
- if (Phaser.RectangleUtils.intersects(a, b))
- {
- out.x = Math.max(a.x, b.x);
- out.y = Math.max(a.y, b.y);
- out.width = Math.min(a.right, b.right) - out.x;
- out.height = Math.min(a.bottom, b.bottom) - out.y;
- }
-
- return out;
-
- }
-
- /**
- * Determines whether the two Rectangles intersect with each other.
- * This method checks the x, y, width, and height properties of the Rectangles.
- * @method intersects
- * @param {Phaser.Rectangle} a The first Rectangle object.
- * @param {Phaser.Rectangle} b The second Rectangle object.
- * @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0
- * @return {bool} A value of true if the specified object intersects with this Rectangle object; otherwise false.
- */
- public static intersects(a: Phaser.Rectangle, b: Phaser.Rectangle, tolerance: number = 0): bool {
- return !(a.left > b.right + tolerance || a.right < b.left - tolerance || a.top > b.bottom + tolerance || a.bottom < b.top - tolerance);
- }
-
- /**
- * Determines whether the object specified intersects (overlaps) with the given values.
- * @method intersectsRaw
- * @param {Number} left
- * @param {Number} right
- * @param {Number} top
- * @param {Number} bottomt
- * @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0
- * @return {bool} A value of true if the specified object intersects with the Rectangle; otherwise false.
- */
- public static intersectsRaw(a: Phaser.Rectangle, left: number, right: number, top: number, bottom: number, tolerance: number = 0): bool {
- return !(left > a.right + tolerance || right < a.left - tolerance || top > a.bottom + tolerance || bottom < a.top - tolerance);
- }
-
- /**
- * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.
- * @method union
- * @param {Phaser.Rectangle} a The first Rectangle object.
- * @param {Phaser.Rectangle} b The second Rectangle object.
- * @param {Phaser.Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
- * @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles.
- */
- public static union(a: Phaser.Rectangle, b: Phaser.Rectangle, out: Phaser.Rectangle = new Phaser.Rectangle): Phaser.Rectangle {
- return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right), Math.max(a.bottom, b.bottom));
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Source/utils/SpriteUtils.ts b/wip/TS Source/utils/SpriteUtils.ts
deleted file mode 100644
index 2f645cdf..00000000
--- a/wip/TS Source/utils/SpriteUtils.ts
+++ /dev/null
@@ -1,355 +0,0 @@
-///
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
-* @module Phaser
-*/
-module Phaser {
-
- /**
- * A collection of methods useful for manipulating and comparing Sprites.
- *
- * @class SpriteUtils
- */
- export class SpriteUtils {
-
- /**
- * A temporary internal variable.
- * @property _tempPoint
- * @type {Phaser.Point}
- */
- public static _tempPoint: Phaser.Point;
-
- /**
- * A temporary internal variable.
- * @property _sin
- * @type {Number}
- */
- public static _sin: number;
-
- /**
- * A temporary internal variable.
- * @property _cos
- * @type {Number}
- */
- public static _cos: number;
-
- /**
- * Updates a Sprites cameraView Rectangle based on the given camera, sprite world position and rotation.
- * @method updateCameraView
- * @param {Camera} camera The Camera to use in the view
- * @param {Sprite} sprite The Sprite that will have its cameraView property modified
- * @return {Rectangle} A reference to the Sprite.cameraView property
- */
- public static updateCameraView(camera: Phaser.Camera, sprite: Phaser.Sprite): Phaser.Rectangle {
-
- if (sprite.rotation == 0 || sprite.texture.renderRotation == false)
- {
- // Easy out
- sprite.cameraView.x = Math.floor(sprite.x - (camera.worldView.x * sprite.transform.scrollFactor.x) - (sprite.width * sprite.transform.origin.x));
- sprite.cameraView.y = Math.floor(sprite.y - (camera.worldView.y * sprite.transform.scrollFactor.y) - (sprite.height * sprite.transform.origin.y));
- sprite.cameraView.width = sprite.width;
- sprite.cameraView.height = sprite.height;
- }
- else
- {
- // If the sprite is rotated around its center we can use this quicker method:
- if (sprite.transform.origin.x == 0.5 && sprite.transform.origin.y == 0.5)
- {
- Phaser.SpriteUtils._sin = sprite.transform.sin;
- Phaser.SpriteUtils._cos = sprite.transform.cos;
-
- if (Phaser.SpriteUtils._sin < 0)
- {
- Phaser.SpriteUtils._sin = -Phaser.SpriteUtils._sin;
- }
-
- if (Phaser.SpriteUtils._cos < 0)
- {
- Phaser.SpriteUtils._cos = -Phaser.SpriteUtils._cos;
- }
-
- sprite.cameraView.width = Math.round(sprite.height * Phaser.SpriteUtils._sin + sprite.width * Phaser.SpriteUtils._cos);
- sprite.cameraView.height = Math.round(sprite.height * Phaser.SpriteUtils._cos + sprite.width * Phaser.SpriteUtils._sin);
- sprite.cameraView.x = Math.round(sprite.x - (camera.worldView.x * sprite.transform.scrollFactor.x) - (sprite.cameraView.width * sprite.transform.origin.x));
- sprite.cameraView.y = Math.round(sprite.y - (camera.worldView.y * sprite.transform.scrollFactor.y) - (sprite.cameraView.height * sprite.transform.origin.y));
- }
- else
- {
- sprite.cameraView.x = Math.min(sprite.transform.upperLeft.x, sprite.transform.upperRight.x, sprite.transform.bottomLeft.x, sprite.transform.bottomRight.x);
- sprite.cameraView.y = Math.min(sprite.transform.upperLeft.y, sprite.transform.upperRight.y, sprite.transform.bottomLeft.y, sprite.transform.bottomRight.y);
- sprite.cameraView.width = Math.max(sprite.transform.upperLeft.x, sprite.transform.upperRight.x, sprite.transform.bottomLeft.x, sprite.transform.bottomRight.x) - sprite.cameraView.x;
- sprite.cameraView.height = Math.max(sprite.transform.upperLeft.y, sprite.transform.upperRight.y, sprite.transform.bottomLeft.y, sprite.transform.bottomRight.y) - sprite.cameraView.y;
- }
- }
-
- return sprite.cameraView;
-
- }
-
- /**
- * Returns an array containing 4 Point objects corresponding to the 4 corners of the sprite bounds.
- * @method getAsPoints
- * @param {Sprite} sprite The Sprite that will have its cameraView property modified
- * @return {Array} An array of Point objects.
- */
- public static getAsPoints(sprite: Phaser.Sprite): Phaser.Point[] {
-
- var out: Phaser.Point[] = [];
-
- // top left
- out.push(new Phaser.Point(sprite.x, sprite.y));
-
- // top right
- out.push(new Phaser.Point(sprite.x + sprite.width, sprite.y));
-
- // bottom right
- out.push(new Phaser.Point(sprite.x + sprite.width, sprite.y + sprite.height));
-
- // bottom left
- out.push(new Phaser.Point(sprite.x, sprite.y + sprite.height));
-
- return out;
-
- }
-
- /**
- * Checks to see if some GameObject overlaps this GameObject or Group.
- * If the group has a LOT of things in it, it might be faster to use Collision.overlaps().
- * WARNING: Currently tilemaps do NOT support screen space overlap checks!
- *
- * @param objectOrGroup {object} The object or group being tested.
- * @param inScreenSpace {bool} Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
- * @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
- *
- * @return {bool} Whether or not the objects overlap this.
- */
- /*
- static overlaps(objectOrGroup, inScreenSpace: bool = false, camera: Camera = null): bool {
-
- if (objectOrGroup.isGroup)
- {
- var results: bool = false;
- var i: number = 0;
- var members = objectOrGroup.members;
-
- while (i < length)
- {
- if (this.overlaps(members[i++], inScreenSpace, camera))
- {
- results = true;
- }
- }
-
- return results;
-
- }
-
- if (!inScreenSpace)
- {
- return (objectOrGroup.x + objectOrGroup.width > this.x) && (objectOrGroup.x < this.x + this.width) &&
- (objectOrGroup.y + objectOrGroup.height > this.y) && (objectOrGroup.y < this.y + this.height);
- }
-
- if (camera == null)
- {
- camera = this.game.camera;
- }
-
- var objectScreenPos: Point = objectOrGroup.getScreenXY(null, camera);
-
- this.getScreenXY(this._point, camera);
-
- return (objectScreenPos.x + objectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
- (objectScreenPos.y + objectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
- }
- */
-
- public static overlapsPointer(sprite:Phaser.Sprite, pointer: Phaser.Pointer): bool {
-
- if (sprite.transform.scrollFactor.equals(1))
- {
- // We can do a world vs. world check
- return Phaser.SpriteUtils.overlapsXY(sprite, pointer.worldX, pointer.worldY);
- }
- else if (sprite.transform.scrollFactor.equals(0))
- {
- // scroll factor 0 means a screen view check, as the sprite will be absolutely positioned
- return Phaser.SpriteUtils.overlapsXY(sprite, pointer.x, pointer.y);
- }
- else
- {
- // If the sprite has a scroll factor other than 0 or 1 then we need to work out
- // what the pointers scroll factor values would be
- var px: number = pointer.worldX * sprite.transform.scrollFactor.x;
- var py: number = pointer.worldY * sprite.transform.scrollFactor.y;
- return Phaser.SpriteUtils.overlapsXY(sprite, px, py);
- }
-
- }
-
- /**
- * Checks to see if the given x and y coordinates overlaps this Sprite, taking scaling and rotation into account.
- * The coordinates must be given in world space, not local or camera space.
- *
- * @method overlapsXY
- * @param {Sprite} sprite The Sprite to check. It will take scaling and rotation into account, but NOT scroll factor.
- * @param {Number} x The x coordinate in world space.
- * @param {Number} y The y coordinate in world space.
- * @return {bool} Whether or not the point overlaps this object.
- */
- public static overlapsXY(sprite: Phaser.Sprite, x: number, y: number): bool {
-
- // if rotation == 0 then just do a rect check instead!
- //if (sprite.transform.rotation == 0)
- //{
- // return Phaser.RectangleUtils.contains(sprite.worldView, x, y);
- //}
-
- if ((x - sprite.transform.upperLeft.x) * (sprite.transform.upperRight.x - sprite.transform.upperLeft.x) + (y - sprite.transform.upperLeft.y) * (sprite.transform.upperRight.y - sprite.transform.upperLeft.y) < 0)
- {
- return false;
- }
-
- if ((x - sprite.transform.upperRight.x) * (sprite.transform.upperRight.x - sprite.transform.upperLeft.x) + (y - sprite.transform.upperRight.y) * (sprite.transform.upperRight.y - sprite.transform.upperLeft.y) > 0)
- {
- return false;
- }
-
- if ((x - sprite.transform.upperLeft.x) * (sprite.transform.bottomLeft.x - sprite.transform.upperLeft.x) + (y - sprite.transform.upperLeft.y) * (sprite.transform.bottomLeft.y - sprite.transform.upperLeft.y) < 0)
- {
- return false;
- }
-
- if ((x - sprite.transform.bottomLeft.x) * (sprite.transform.bottomLeft.x - sprite.transform.upperLeft.x) + (y - sprite.transform.bottomLeft.y) * (sprite.transform.bottomLeft.y - sprite.transform.upperLeft.y) > 0)
- {
- return false;
- }
-
- return true;
-
- }
-
- /**
- * Checks to see if the given point overlaps this Sprite, taking scaling and rotation into account.
- * The point must be given in world space, not local or camera space.
- *
- * @method overlapsPoint
- * @param {Sprite} sprite The Sprite to check. It will take scaling and rotation into account.
- * @param {Point} point The point in world space you want to check.
- * @return {bool} Whether or not the point overlaps this object.
- */
- public static overlapsPoint(sprite: Phaser.Sprite, point: Phaser.Point): bool {
- return Phaser.SpriteUtils.overlapsXY(sprite, point.x, point.y);
- }
-
- /**
- * Check and see if this object is currently on screen.
- *
- * @method onScreen
- * @param {Sprite} sprite The Sprite to check. It will take scaling and rotation into account.
- * @param {Camera} camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
- * @return {bool} Whether the object is on screen or not.
- */
- public static onScreen(sprite: Phaser.Sprite, camera: Phaser.Camera = null): bool {
-
- if (camera == null)
- {
- camera = sprite.game.camera;
- }
-
- Phaser.SpriteUtils.getScreenXY(sprite, SpriteUtils._tempPoint, camera);
-
- return (Phaser.SpriteUtils._tempPoint.x + sprite.width > 0) && (Phaser.SpriteUtils._tempPoint.x < camera.width) && (Phaser.SpriteUtils._tempPoint.y + sprite.height > 0) && (Phaser.SpriteUtils._tempPoint.y < camera.height);
-
- }
-
- /**
- * Call this to figure out the on-screen position of the object.
- *
- * @method getScreenXY
- * @param {Sprite} sprite The Sprite to check.
- * @param {Point} point Takes a Point object and assigns the post-scrolled X and Y values of this object to it.
- * @param {Camera} camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
- * @return {Point} The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object.
- */
- public static getScreenXY(sprite: Phaser.Sprite, point: Phaser.Point = null, camera: Phaser.Camera = null): Phaser.Point {
-
- if (point == null)
- {
- point = new Point();
- }
-
- if (camera == null)
- {
- camera = sprite.game.camera;
- }
-
- point.x = sprite.x - camera.x * sprite.transform.scrollFactor.x;
- point.y = sprite.y - camera.y * sprite.transform.scrollFactor.y;
- point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
- point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
-
- return point;
-
- }
-
- /**
- * Set the world bounds that this GameObject can exist within based on the size of the current game world.
- *
- * @param action {number} The action to take if the object hits the world bounds, either OUT_OF_BOUNDS_KILL or OUT_OF_BOUNDS_STOP
- */
- /*
- static setBoundsFromWorld(action: number = GameObject.OUT_OF_BOUNDS_STOP) {
-
- this.setBounds(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height);
- this.outOfBoundsAction = action;
-
- }
- */
-
- /**
- * Handy for reviving game objects. Resets their existence flags and position.
- *
- * @method reset
- * @param {Sprite} sprite The Sprite to reset.
- * @param {number} x The new X position of this object.
- * @param {number} y The new Y position of this object.
- * @return {Sprite} The reset Sprite object.
- */
- public static reset(sprite: Phaser.Sprite, x: number, y: number):Phaser.Sprite {
-
- sprite.revive();
- sprite.x = x;
- sprite.y = y;
- //sprite.body.velocity.x = 0;
- //sprite.body.velocity.y = 0;
- //sprite.body.position.x = x;
- //sprite.body.position.y = y;
-
- return sprite;
-
- }
-
- /**
- * Set the world bounds that this GameObject can exist within. By default a GameObject can exist anywhere
- * in the world. But by setting the bounds (which are given in world dimensions, not screen dimensions)
- * it can be stopped from leaving the world, or a section of it.
- *
- * @method setBounds
- * @param {number} x x position of the bound
- * @param {number} y y position of the bound
- * @param {number} width width of its bound
- * @param {number} height height of its bound
- */
- public static setBounds(x: number, y: number, width: number, height: number) {
-
- // Needed?
-
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/wip/TS Tests/audio/audio sprites 1.ts b/wip/TS Tests/audio/audio sprites 1.ts
deleted file mode 100644
index 71828853..00000000
--- a/wip/TS Tests/audio/audio sprites 1.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-///
-///
-///
-
-//var PhaserGlobal = { disableWebAudio: true };
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- game.load.audio('rabbit', ['assets/mp3/peter_rabbit.m4a', 'assets/mp3/peter_rabbit.mp3', 'assets/mp3/peter_rabbit.ogg']);
- game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
-
-
- }
-
- audioSprite: Phaser.Sound;
- button: Phaser.UI.Button;
- pause: Phaser.UI.Button;
-
- function create() {
-
- this.audioSprite = game.add.audio('rabbit');
- this.audioSprite.addMarker('title', 3.00, 5.00, 1, true);
- this.audioSprite.addMarker('help', 6.00, 12.00);
- this.audioSprite.addMarker('intro', 14.00, 19.00);
- this.audioSprite.addMarker('peter', 20.00, 21.50);
-
- this.button = game.add.button(game.stage.centerX, 400, 'button', playMusic, this, 2, 1, 0);
- //this.pause = game.add.button(200, 200, 'button', togglePause, this, 2, 1, 0);
-
- }
-
- function playMusic() {
- this.audioSprite.play('help');
- }
-
- function render() {
- Phaser.DebugUtils.renderSoundInfo(this.audioSprite, 32, 32);
- }
-
- function togglePause() {
-
- if (this.music.paused)
- {
- this.music.resume();
- }
- else
- {
- this.music.pause();
- }
-
- }
-
-
-})();
diff --git a/wip/TS Tests/audio/play sound 1.ts b/wip/TS Tests/audio/play sound 1.ts
deleted file mode 100644
index e51443a3..00000000
--- a/wip/TS Tests/audio/play sound 1.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-///
-///
-///
-
-//var PhaserGlobal = { fakeiOSTouchLock: true, disableWebAudio: true };
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- //game.load.audio('wizball', ['assets/mp3/oedipus_wizball_highscore.ogg', 'assets/mp3/oedipus_wizball_highscore.mp3']);
- game.load.audio('boden', ['assets/mp3/bodenstaendig_2000_in_rock_4bit.mp3']);
- game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
-
-
- }
-
- button: Phaser.UI.Button;
- music: Phaser.Sound;
- volumeUp: Phaser.UI.Button;
- volumeDown: Phaser.UI.Button;
- pause: Phaser.UI.Button;
-
- function create() {
-
- this.music = game.add.audio('boden');
-
- this.button = game.add.button(game.stage.centerX, 400, 'button', playMusic, this, 2, 1, 0);
- //this.volumeUp = game.add.button(0, 0, 'button', volUp, this, 2, 1, 0);
- //this.volumeDown = game.add.button(700, 0, 'button', volDown, this, 2, 1, 0);
- //this.pause = game.add.button(200, 200, 'button', togglePause, this, 2, 1, 0);
-
- }
-
- function render() {
- Phaser.DebugUtils.renderSoundInfo(this.music, 0, 300);
- }
-
- function togglePause() {
-
- if (this.music.paused)
- {
- this.music.resume();
- }
- else
- {
- this.music.pause();
- }
-
- }
-
- function volUp() {
- //game.sound.volume += 0.1;
- this.music.volume += 0.1;
- console.log('vol up', game.sound.volume);
- }
-
- function volDown() {
- //game.sound.volume -= 0.1;
- this.music.volume -= 0.1;
- console.log('vol down', game.sound.volume);
- }
-
- function playMusic() {
- this.music.play();
- }
-
-})();
diff --git a/wip/TS Tests/buttons/basic button 2.ts b/wip/TS Tests/buttons/basic button 2.ts
deleted file mode 100644
index 7d15f7fe..00000000
--- a/wip/TS Tests/buttons/basic button 2.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
- game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
-
-
- }
-
- image: Phaser.Sprite;
- button: Phaser.UI.Button;
-
- function create() {
-
- // This is just an image that we'll toggle the display of when you click the button
- this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
- this.image.transform.origin.setTo(0.5, 0);
-
- // This button is created from a texture atlas.
- // Instead of frame IDs (like with a sprite sheet) we can tell it to use frame names instead.
- // In this case our atlast frame names were called 'over', 'out' and 'down', but they could be anything you want.
- // The function "clickedIt" will be called when the button is clicked or touched
- this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 'over', 'out', 'down');
-
- // Just makes the button origin set to the middle, we only do this to center the button on-screen, no other reason
- this.button.transform.origin.setTo(0.5, 0.5);
-
- }
-
- function clickedIt() {
-
- if (this.image.visible == true)
- {
- this.image.visible = false;
- }
- else
- {
- this.image.visible = true;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/buttons/basic button.ts b/wip/TS Tests/buttons/basic button.ts
deleted file mode 100644
index 7155b823..00000000
--- a/wip/TS Tests/buttons/basic button.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
- game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
-
-
- }
-
- image: Phaser.Sprite;
- button: Phaser.UI.Button;
-
- function create() {
-
- // This is just an image that we'll toggle the display of when you click the button
- this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
- this.image.transform.origin.setTo(0.5, 0);
-
- // This button is created from a sprite sheet.
- // Frame 0 = the 'down' state
- // Frame 1 = the 'out' state
- // Frame 2 = the 'over' state
- // The function "clickedIt" will be called when the button is clicked or touched
- this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 2, 1, 0);
-
- // Just makes the button origin set to the middle, we only do this to center the button on-screen, no other reason
- this.button.transform.origin.setTo(0.5, 0.5);
-
- }
-
- function clickedIt() {
-
- if (this.image.visible == true)
- {
- this.image.visible = false;
- }
- else
- {
- this.image.visible = true;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/buttons/camera buttons.ts b/wip/TS Tests/buttons/camera buttons.ts
deleted file mode 100644
index 788fd8ba..00000000
--- a/wip/TS Tests/buttons/camera buttons.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
-
-
- }
-
- var button: Phaser.UI.Button;
- var secondCam: Phaser.Camera;
-
- function create() {
-
- button = game.add.button(200, 400, 'button', clickedIt, this, 2, 1, 0);
- button.origin.setTo(0.5, 0.5);
-
- game.camera.width = 400;
- game.camera.texture.opaque = true;
- game.camera.texture.backgroundColor = 'rgb(100,0,0)';
-
- secondCam = game.add.camera(400, 0, 400, 600);
- secondCam.texture.opaque = true;
- secondCam.texture.backgroundColor = 'rgb(0,100,0)';
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
- Phaser.DebugUtils.renderSpriteWorldView(button, 32, 200);
-
- }
-
- function clickedIt() {
-
- button.rotation += 10;
-
- }
-
-})();
diff --git a/wip/TS Tests/buttons/rotated buttons.ts b/wip/TS Tests/buttons/rotated buttons.ts
deleted file mode 100644
index 64914bf4..00000000
--- a/wip/TS Tests/buttons/rotated buttons.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
- game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
-
-
- }
-
- image: Phaser.Sprite;
- button: Phaser.UI.Button;
-
- function create() {
-
- // This is just an image that we'll toggle the display of when you click the button
- this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
- this.image.transform.origin.setTo(0.5, 0);
-
- // This button is created from a texture atlas.
- // Instead of frame IDs (like with a sprite sheet) we can tell it to use frame names instead.
- // In this case our atlast frame names were called 'over', 'out' and 'down', but they could be anything you want.
- // The function "clickedIt" will be called when the button is clicked or touched
- this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 'over', 'out', 'down');
-
- // Makes the button origin set to the middle
- this.button.transform.origin.setTo(0.5, 0.5);
-
- }
-
- function update() {
-
- // Rotate the button each frame, the button states will still work and respond.
- this.button.rotation += 1;
-
- }
-
- function clickedIt() {
-
- if (this.image.visible == true)
- {
- this.image.visible = false;
- }
- else
- {
- this.image.visible = true;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/camera fx/fade.ts b/wip/TS Tests/camera fx/fade.ts
deleted file mode 100644
index e69de29b..00000000
diff --git a/wip/TS Tests/camera fx/mirror.ts b/wip/TS Tests/camera fx/mirror.ts
deleted file mode 100644
index 7292168d..00000000
--- a/wip/TS Tests/camera fx/mirror.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
-
-
-
- }
-
- var mirror: Phaser.Plugins.CameraFX.Mirror;
-
- function create() {
-
- // Just set the world to be the size of the image we're loading in
- game.world.setSize(1216, 896);
-
- // What we need is a camera 800x400 pixels in size as the mirror effect will be 200px tall and sit below it.
- // So we resize our default camera to 400px
- game.camera.height = 400;
-
- // Add our effect to the camera
- mirror = game.camera.plugins.add(Phaser.Plugins.CameraFX.Mirror);
-
- // The first 2 parameters are the x and y coordinates of where to display the effect. They are in STAGE coordinates, not World.
- // The next is a Rectangle making up the region of the Camera that we'll create the effect from (in this case the whole camera).
- // Finally we set the fill color that is put over the top of the mirror effect.
- mirror.start(0, 400, new Phaser.Rectangle(0, 0, 800, 400), 'rgba(0, 0, 100, 0.7)');
-
- // Experiment with variations on these to see the different mirror effects that can be achieved.
- //mirror.flipX = true;
- //mirror.flipY = true;
-
- // The Mirror FX will literally mirror EVERYTHING that was rendered to the camera, in the case of this test it's
- // just a single image, but when used on a full game it can look really quite neat.
- game.add.sprite(0, 0, 'backdrop');
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/camera fx/scanlines.ts b/wip/TS Tests/camera fx/scanlines.ts
deleted file mode 100644
index 8dff7678..00000000
--- a/wip/TS Tests/camera fx/scanlines.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
-
-
-
- }
-
- var scanlines: Phaser.Plugins.CameraFX.Scanlines;
-
- function create() {
-
- game.world.setSize(1216, 896);
-
- // Add our effect to the camera
- scanlines = game.camera.plugins.add(Phaser.Plugins.CameraFX.Scanlines);
-
- // We'll have the scanlines spaced out every 2 pixels
- scanlines.spacing = 2;
-
- // This is the color the lines will be drawn in
- scanlines.color = 'rgba(0, 0, 0, 0.8)';
-
- game.add.sprite(0, 0, 'backdrop');
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/cameras/basic camera 1.ts b/wip/TS Tests/cameras/basic camera 1.ts
deleted file mode 100644
index f8eb42f8..00000000
--- a/wip/TS Tests/cameras/basic camera 1.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
- game.load.image('melon', 'assets/sprites/melon.png');
-
- }
-
- function create() {
-
- game.world.setSize(1920, 1200, true);
-
- game.add.sprite(0, 0, 'backdrop');
-
- for (var i = 0; i < 100; i++)
- {
- game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
- }
-
- //game.camera.texture.alpha = 0.5;
- //game.camera.width = 400;
- game.camera.texture.opaque = true;
- game.camera.texture.backgroundColor = 'rgb(200,0,0)';
- game.camera.transform.origin.setTo(0.5, 0.5);
- game.camera.setPosition(game.stage.centerX, game.stage.centerY);
- //game.camera.setPosition(0, 0);
- //console.log('cam', game.camera.width, game.camera.height);
-
- }
-
- function update() {
-
- game.camera.rotation--;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- //game.camera.x -= 4;
- game.camera.transform.scale.x -= 0.1;
- game.camera.transform.scale.y -= 0.1;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- //game.camera.x += 4;
- game.camera.transform.scale.x += 0.1;
- game.camera.transform.scale.y += 0.1;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/cameras/basic follow.ts b/wip/TS Tests/cameras/basic follow.ts
deleted file mode 100644
index 6567bee3..00000000
--- a/wip/TS Tests/cameras/basic follow.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- var ufo: Phaser.Sprite;
- var speed: number = 4;
-
- function preload() {
- game.world.setSize(1280, 600, true);
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
- game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
- game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
- game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
-
- game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
-
-
- }
- function create() {
- // background images
- game.add.sprite(0, 0, 'sky')
- .transform.scrollFactor.setTo(0, 0);
- game.add.sprite(0, 360, 'ground')
- .transform.scrollFactor.setTo(0.5, 0.5);
- game.add.sprite(0, 400, 'river')
- .transform.scrollFactor.setTo(1.3, 1.3);
- game.add.sprite(200, 120, 'cloud0')
- .transform.scrollFactor.setTo(0.3, 0.3);
- game.add.sprite(-60, 120, 'cloud1')
- .transform.scrollFactor.setTo(0.5, 0.3);
- game.add.sprite(900, 170, 'cloud2')
- .transform.scrollFactor.setTo(0.7, 0.3);
-
- // ufo spirte
- ufo = game.add.sprite(320, 240, 'ufo');
- ufo.animations.add('fly', null, 30, false);
- ufo.animations.play('fly');
- ufo.transform.origin.setTo(0.5, 0.5);
-
- // make camera follows ufo
- game.camera.follow(ufo);
- }
- function update() {
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
- ufo.x -= speed;
- ufo.rotation = -15;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
- ufo.x += speed;
- ufo.rotation = 15;
- }
- else {
- ufo.rotation = 0;
- }
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
- ufo.y -= speed;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
- ufo.y += speed;
- }
- }
-})();
diff --git a/wip/TS Tests/cameras/camera alpha.ts b/wip/TS Tests/cameras/camera alpha.ts
deleted file mode 100644
index 0051eb8b..00000000
--- a/wip/TS Tests/cameras/camera alpha.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
- game.load.image('car', 'assets/sprites/car90.png');
-
-
-
- }
-
- var car: Phaser.Sprite;
- var miniCam: Phaser.Camera;
-
- function create() {
-
- game.world.setSize(2240, 2240, true);
-
- game.add.sprite(0, 0, 'grid');
-
- car = game.add.sprite(400, 300, 'car');
-
- game.camera.follow(car, Phaser.Types.CAMERA_FOLLOW_TOPDOWN);
-
- miniCam = game.add.camera(0, 0, 300, 300);
- miniCam.follow(car, Phaser.Types.CAMERA_FOLLOW_TOPDOWN_TIGHT);
- miniCam.setBounds(0, 0, game.world.width, game.world.height);
- miniCam.texture.alpha = 0.7;
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- car.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- car.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- car.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- car.y += 4;
- }
-
- /*
- car.velocity.x = 0;
- car.velocity.y = 0;
- car.angularVelocity = 0;
- car.angularAcceleration = 0;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- car.angularVelocity = -200;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- car.angularVelocity = 200;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- var motion:Phaser.Point = game.motion.velocityFromAngle(car.angle, 300);
-
- car.velocity.copyFrom(motion);
- }
- */
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderSpriteInfo(car, 32, 32);
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 300);
-
- }
-
-})();
diff --git a/wip/TS Tests/cameras/camera fx 1.ts b/wip/TS Tests/cameras/camera fx 1.ts
deleted file mode 100644
index b228bf27..00000000
--- a/wip/TS Tests/cameras/camera fx 1.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var btn1: Phaser.UI.Button,
- btn2: Phaser.UI.Button,
- btn3: Phaser.UI.Button;
- var fx;
-
- function preload() {
- game.world.setSize(800, 600, true);
- game.load.image('blue', 'assets/tests/blue-circle.png');
- game.load.image('yellow', 'assets/tests/yellow-circle.png');
- game.load.image('magenta', 'assets/tests/magenta-circle.png');
-
-
- }
- function create() {
- btn1 = game.add.button(114, 34, 'blue', simpleFade, this);
- btn2 = game.add.button(426, 86, 'yellow', forceFade, this);
- btn3 = game.add.button(221, 318, 'magenta', fadeWithCallback, this);
-
- //fx = game.camera.fx.add(Phaser.FX.Camera.Fade);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Press to fade.', 114 + 90, 34 + 130);
- Phaser.DebugUtils.context.fillText('Force to fade every time you press it.', 426 + 20, 86 + 130);
- Phaser.DebugUtils.context.fillText('Popup a window when fade finished.', 221 + 30, 318 + 130);
- }
- function simpleFade() {
- // Simply fade to black in 0.5 seconds.
- fx.start(0x330033, 0.5);
- }
- function forceFade() {
- // Force restart fade effect each time you pressed the button.
- fx.start(0x003333, 0.5, null, true);
- }
- function fadeWithCallback() {
- // Popup a alert window when fade finished.
- fx.start(0x333300, 0.5, function() {
- alert('Fade finished!');
- });
- }
-})();
diff --git a/wip/TS Tests/cameras/camera fx 2.ts b/wip/TS Tests/cameras/camera fx 2.ts
deleted file mode 100644
index 197350e6..00000000
--- a/wip/TS Tests/cameras/camera fx 2.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var btn1: Phaser.UI.Button,
- btn2: Phaser.UI.Button,
- btn3: Phaser.UI.Button;
- var fx;
-
- function preload() {
- game.world.setSize(800, 600, true);
- game.load.image('blue', 'assets/tests/blue-circle.png');
- game.load.image('yellow', 'assets/tests/yellow-circle.png');
- game.load.image('magenta', 'assets/tests/magenta-circle.png');
-
-
- }
- function create() {
- btn1 = game.add.button(114, 34, 'blue', simpleFlash, this);
- btn2 = game.add.button(426, 86, 'yellow', forceFlash, this);
- btn3 = game.add.button(221, 318, 'magenta', flashWithCallback, this);
-
- // Usage of flash fx is the same as fade.
- //fx = game.camera.fx.add(Phaser.FX.Camera.Flash);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Press to flash.', 114 + 90, 34 + 130);
- Phaser.DebugUtils.context.fillText('Force to flash every time you press it.', 426 + 20, 86 + 130);
- Phaser.DebugUtils.context.fillText('Popup a window when flash finished.', 221 + 30, 318 + 130);
- }
- function simpleFlash() {
- // Simply flash to black in 0.5 seconds.
- fx.start(0x330033, 0.5);
- }
- function forceFlash() {
- // Force restart flash effect each time you pressed the button.
- fx.start(0x003333, 0.5, null, true);
- }
- function flashWithCallback() {
- // Popup a alert window when flash finished.
- fx.start(0x333300, 0.5, function() {
- alert('Flash finished!');
- });
- }
-})();
diff --git a/wip/TS Tests/cameras/camera fx 3.ts b/wip/TS Tests/cameras/camera fx 3.ts
deleted file mode 100644
index 0ab7a3b7..00000000
--- a/wip/TS Tests/cameras/camera fx 3.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var btn1: Phaser.UI.Button,
- btn2: Phaser.UI.Button,
- btn3: Phaser.UI.Button;
- var fx;
-
- function preload() {
- game.world.setSize(800, 600, true);
- game.load.image('blue', 'assets/tests/blue-circle.png');
- game.load.image('yellow', 'assets/tests/yellow-circle.png');
- game.load.image('magenta', 'assets/tests/magenta-circle.png');
-
-
- }
- function create() {
- btn1 = game.add.button(114, 34, 'blue', simpleShake, this);
- btn2 = game.add.button(426, 86, 'yellow', forceShake, this);
- btn3 = game.add.button(221, 318, 'magenta', shakeWithCallback, this);
-
- // Usage of shake fx is the same as fade and flash.
- //fx = game.camera.fx.add(Phaser.FX.Camera.Shake);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Press to shake.', 114 + 90, 34 + 130);
- Phaser.DebugUtils.context.fillText('Force to shake every time you press it.', 426 + 20, 86 + 130);
- Phaser.DebugUtils.context.fillText('Popup a window when shake finished.', 221 + 30, 318 + 130);
- }
- function simpleShake() {
- // Simply shake to black in 0.5 seconds.
- fx.start(0x330033, 0.5);
- }
- function forceShake() {
- // Force restart shake effect each time you pressed the button.
- fx.start(0x003333, 0.5, null, true);
- }
- function shakeWithCallback() {
- // Popup a alert window when shake finished.
- fx.start(0x333300, 0.5, function() {
- alert('Shake finished!');
- });
- }
-})();
diff --git a/wip/TS Tests/cameras/camera rotation.ts b/wip/TS Tests/cameras/camera rotation.ts
deleted file mode 100644
index b2c916c5..00000000
--- a/wip/TS Tests/cameras/camera rotation.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('melon', 'assets/sprites/melon.png');
-
-
-
- }
-
- var car: Phaser.Sprite;
- var miniCam: Phaser.Camera;
-
- function create() {
-
- game.world.setSize(3000, 3000, true);
- game.stage.backgroundColor = 'rgb(20,20,50)';
-
- for (var i = 0; i < 1000; i++)
- {
- game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
- }
-
- game.camera.transform.origin.setTo(0.5, 0.5);
- game.camera.texture.opaque = true;
- game.camera.texture.backgroundColor = 'rgb(0,0,0)';
- game.camera.setPosition(game.stage.centerX, game.stage.centerY);
- //game.camera.setPosition(200, 0);
- game.camera.setSize(320, 320);
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.rotation -= 2;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.rotation += 2;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/cameras/camera scale.ts b/wip/TS Tests/cameras/camera scale.ts
deleted file mode 100644
index 8254f2f0..00000000
--- a/wip/TS Tests/cameras/camera scale.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var zombieCamera: Phaser.Camera;
-
- var zombie: Phaser.Sprite;
- var walkSpeed: number = 2,
- direction: number = 1;
-
- function preload() {
- game.world.setSize(1280, 600, true);
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
-
- game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
-
-
- }
- function create() {
- // Add background images.
- game.add.sprite(0, 0, 'sky');
- game.add.sprite(0, 360, 'ground');
- game.add.sprite(0, 400, 'river');
-
- // Create zombie spirte
- zombie = game.add.sprite(480, 336, 'zombie');
- zombie.animations.add('walk', null, 30, true);
- zombie.animations.play('walk');
-
- // Create a small camera which looks at the zombie.
- // Use the same settings as the default camera.
- zombieCamera = game.add.camera(0, 0, 800, 600);
- // Use x and y properties to set the target area.
- zombieCamera.x = 420;
- zombieCamera.y = 240;
- // Resize the camera so that it will only look at 200x200 area.
- zombieCamera.setSize(200, 200);
- // Scale the camera to 2.0, now its target will be 100x100.
- zombieCamera.transform.scale.setTo(2.0, 2.0);
- // Use setPosition() method to set where the camera rendered
- // on the screen.
- zombieCamera.setPosition(0, 0);
- }
- function update() {
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
- zombieCamera.x -= 2;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
- zombieCamera.x += 2;
- }
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
- zombieCamera.y -= 2;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
- zombieCamera.y += 2;
- }
- // zombie wandering update
- zombie.x += walkSpeed * direction;
- if (zombie.x > 540 || zombie.x < 440) {
- // Change walk direction.
- direction *= -1;
- // Flip zombie's animation.
- zombie.texture.flippedX = !zombie.texture.flippedX;
- }
- }
- function render() {
-
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
- Phaser.DebugUtils.renderCameraInfo(zombieCamera, 32, 128);
- }
-})();
diff --git a/wip/TS Tests/cameras/camera texture.ts b/wip/TS Tests/cameras/camera texture.ts
deleted file mode 100644
index 2e092c9e..00000000
--- a/wip/TS Tests/cameras/camera texture.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
- game.world.setSize(800, 600, true);
- game.load.image('background', 'assets/misc/water_texture.jpg');
-
-
- }
- function create() {
- game.camera.texture.loadImage('background', false);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = 'rgb(255, 255, 255)';
- Phaser.DebugUtils.context.fillText('Draw background image using camera.texture property.',
- 196, 320);
- }
-})();
diff --git a/wip/TS Tests/cameras/follow styles.ts b/wip/TS Tests/cameras/follow styles.ts
deleted file mode 100644
index fda27733..00000000
--- a/wip/TS Tests/cameras/follow styles.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var ufo: Phaser.Sprite,
- speed: number = 4;
-
- var btn0: Phaser.UI.Button,
- btn1: Phaser.UI.Button,
- btn2: Phaser.UI.Button,
- btn3: Phaser.UI.Button;
- var style: string = 'default';
-
- function preload() {
- game.world.setSize(1280, 800, true);
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
- game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
- game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
- game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
-
- game.load.spritesheet('button', 'assets/buttons/follow-style-button.png', 224, 70);
-
- game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
-
-
- }
- function create() {
- // background images
- game.add.sprite(0, 0, 'sky')
- .transform.scrollFactor.setTo(0, 0);
- game.add.sprite(0, 360, 'ground')
- .transform.scrollFactor.setTo(0.5, 0.1);
- game.add.sprite(0, 400, 'river')
- .transform.scrollFactor.setTo(1.3, 0.16);
- game.add.sprite(200, 120, 'cloud0')
- .transform.scrollFactor.setTo(0.3, 0.1);
- game.add.sprite(-60, 120, 'cloud1')
- .transform.scrollFactor.setTo(0.5, 0.1);
- game.add.sprite(900, 170, 'cloud2')
- .transform.scrollFactor.setTo(0.7, 0.1);
- // ufo spirte
- ufo = game.add.sprite(360, 240, 'ufo');
- ufo.animations.add('fly', null, 30, false);
- ufo.animations.play('fly');
- ufo.transform.origin.setTo(0.5, 0.5);
-
- // make camera follows ufo
- game.camera.follow(ufo);
-
- // follow style switch buttons
- btn0 = game.add.button(16, 40, 'button', lockonFollow, 0, 0, 0);
- btn1 = game.add.button(16, 120, 'button', platformerFollow, 1, 1, 1);
- btn2 = game.add.button(16, 200, 'button', topdownFollow, 2, 2, 2);
- btn3 = game.add.button(16, 280, 'button', topdownTightFollow, 3, 3, 3);
- }
- function update() {
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
- ufo.x -= speed;
- ufo.rotation = -15;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
- ufo.x += speed;
- ufo.rotation = 15;
- }
- else {
- ufo.rotation = 0;
- }
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
- ufo.y -= speed;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
- ufo.y += speed;
- }
- }
- function render() {
- if (game.camera.deadzone) {
- Phaser.DebugUtils.renderRectangle(game.camera.deadzone, 'rgba(240, 112, 111, 0.4)');
- }
- // game.camera.renderDebugInfo(400, 16);
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Click buttons to switch between different styles.', 360, 32);
- Phaser.DebugUtils.context.fillText('Current style: ' + style, 360, 48);
- }
- function lockonFollow() {
- game.camera.follow(ufo, Phaser.Types.CAMERA_FOLLOW_LOCKON);
- style = 'STYLE_LOCKON';
- }
- function platformerFollow() {
- game.camera.follow(ufo, Phaser.Types.CAMERA_FOLLOW_PLATFORMER);
- style = 'STYLE_PLATFORMER';
- }
- function topdownFollow() {
- game.camera.follow(ufo, Phaser.Types.CAMERA_FOLLOW_TOPDOWN);
- style = 'STYLE_TOPDOWN';
- }
- function topdownTightFollow() {
- game.camera.follow(ufo, Phaser.Types.CAMERA_FOLLOW_TOPDOWN_TIGHT);
- style = 'STYLE_TOPDOWN_TIGHT';
- }
-})();
diff --git a/wip/TS Tests/cameras/hide from camera.ts b/wip/TS Tests/cameras/hide from camera.ts
deleted file mode 100644
index 6570e476..00000000
--- a/wip/TS Tests/cameras/hide from camera.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-///
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var radar: Phaser.Sprite;
- var ships: Phaser.Sprite[] = [];
-
- var enemyCamera: Phaser.Camera;
-
- function preload() {
-
- game.load.image('radar-surface', 'assets/tests/radar-surface.png');
- game.load.image('ship', 'assets/sprites/asteroids_ship_white.png');
- game.load.image('enemy-ship', 'assets/sprites/asteroids_ship.png');
-
-
- }
-
- function create() {
-
- // Add enemies and our ship the the world.
- for (var i = 0; i < 4; i++) {
- ships.push(game.add.sprite(100 + i * 10, 280 + i * 16, 'enemy-ship'));
- }
-
- var ourShip: Phaser.Sprite = game.add.sprite(160, 300, 'ship');
- ships.push(ourShip);
-
- // Radar sprite is a HUD.
- radar = game.add.sprite(0, 0, 'radar-surface');
-
- // Make the default camera rendered on the left half screen.
- game.camera.setSize(400, 600);
- game.camera.texture.backgroundColor = 'rgb(0,50,100)';
- game.camera.texture.opaque = true;
-
- // Add a new camera and render it on the right half screen.
- // The newly created is the enemies' camera, which cannot "see" our ship.
- enemyCamera = game.add.camera(400, 0, 400, 600);
- enemyCamera.texture.backgroundColor = 'rgb(100,0,50)';
- enemyCamera.texture.opaque = true;
-
- // Hide our ship on the enemies' camera.
- enemyCamera.hide(ourShip);
-
- }
-
- function update() {
-
- for (var i = 0; i < ships.length; i++) {
-
- ships[i].x += 4;
-
- if (ships[i].x > 400) {
- ships[i].x = 40;
- }
- }
-
- }
-
- function render() {
- Phaser.DebugUtils.renderText('Left is the player\'s camera and right is the enemies\' camera.', 32, 32);
- }
-
-})();
diff --git a/wip/TS Tests/cameras/multi camera.ts b/wip/TS Tests/cameras/multi camera.ts
deleted file mode 100644
index 93b38f52..00000000
--- a/wip/TS Tests/cameras/multi camera.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var zombieCamera: Phaser.Camera;
-
- var zombie: Phaser.Sprite;
- var walkSpeed: number = 2,
- direction: number = 1;
-
- function preload() {
- game.world.setSize(1280, 600, true);
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
-
- game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
-
-
- }
- function create() {
- // Add background images.
- game.add.sprite(0, 0, 'sky');
- game.add.sprite(0, 360, 'ground');
- game.add.sprite(0, 400, 'river');
-
- // Create zombie spirte
- zombie = game.add.sprite(480, 336, 'zombie');
- zombie.animations.add('walk', null, 30, true);
- zombie.animations.play('walk');
-
- // Create a small camera which looks at the zombie.
- // Use the same settings as the default camera.
- zombieCamera = game.add.camera(0, 0, 800, 600);
- // Use x and y properties to set the target area.
- zombieCamera.x = 420;
- zombieCamera.y = 240;
- // Resize the camera so that it will only look at 200x200 area.
- zombieCamera.setSize(200, 200);
- // Use setPosition() method to set where the camera rendered
- // on the screen.
- zombieCamera.setPosition(0, 0);
- }
- function update() {
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
- zombieCamera.x -= 2;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
- zombieCamera.x += 2;
- }
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
- zombieCamera.y -= 2;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
- zombieCamera.y += 2;
- }
- // zombie wandering update
- zombie.x += walkSpeed * direction;
- if (zombie.x > 540 || zombie.x < 440) {
- // Change walk direction.
- direction *= -1;
- // Flip zombie's animation.
- zombie.texture.flippedX = !zombie.texture.flippedX;
- }
- }
- function render() {
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
- Phaser.DebugUtils.renderCameraInfo(zombieCamera, 32, 128);
- }
-})();
diff --git a/wip/TS Tests/cameras/scrollfactor 1.ts b/wip/TS Tests/cameras/scrollfactor 1.ts
deleted file mode 100644
index 82217633..00000000
--- a/wip/TS Tests/cameras/scrollfactor 1.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.world.setSize(1920, 1200, true);
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
- game.load.image('ball', 'assets/sprites/shinyball.png');
-
-
-
- }
-
- function create() {
-
- game.add.sprite(0, 0, 'backdrop');
-
- for (var i = 0; i < 400; i++)
- {
- var tempBall:Phaser.Sprite = game.add.sprite(game.world.randomX * 2, game.world.randomY * 2, 'ball');
- tempBall.transform.scrollFactor.setTo(2, 2);
- }
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/cameras/scrollfactor 2.ts b/wip/TS Tests/cameras/scrollfactor 2.ts
deleted file mode 100644
index c97093b2..00000000
--- a/wip/TS Tests/cameras/scrollfactor 2.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.world.setSize(1600, 800, true);
-
- game.load.image('disk', 'assets/pics/devilstar_demo_download_disk.png');
-
-
-
- }
-
- function create() {
-
- for (var i = 0; i < 10; i++)
- {
- var temp:Phaser.Sprite = game.add.sprite(600 + (10 * i), 200 + (10 * i), 'disk');
- temp.transform.scrollFactor.setTo(i / 2, i / 2);
- }
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/cameras/scrollfactor compare.ts b/wip/TS Tests/cameras/scrollfactor compare.ts
deleted file mode 100644
index 7ceab175..00000000
--- a/wip/TS Tests/cameras/scrollfactor compare.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
- function preload() {
- game.world.setSize(1280, 600, true);
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
- game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
- game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
- game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
-
- }
- function create() {
- // background sky, which does not move at all
- game.add.sprite(0, 0, 'sky')
- .transform.scrollFactor.setTo(0, 0);
-
- // clouds with different scroll factor which moves slower than camera
- game.add.sprite(200, 120, 'cloud0')
- .transform.scrollFactor.setTo(0.3, 0.3);
- game.add.sprite(-60, 120, 'cloud1')
- .transform.scrollFactor.setTo(0.5, 0.3);
- game.add.sprite(900, 170, 'cloud2')
- .transform.scrollFactor.setTo(0.7, 0.3);
-
- // forground objects which moves equal or faster than camera
- game.add.sprite(0, 360, 'ground')
- .transform.scrollFactor.setTo(0.5, 0.5);
- game.add.sprite(0, 400, 'river')
- .transform.scrollFactor.setTo(1.3, 1.3);
- }
- function update() {
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
- game.camera.x -= 3;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
- game.camera.x += 3;
- }
- }
- function render() {
- // game.camera.renderDebugInfo(32, 32);
- }
-})();
diff --git a/wip/TS Tests/cameras/world sprite.ts b/wip/TS Tests/cameras/world sprite.ts
deleted file mode 100644
index ec79dc37..00000000
--- a/wip/TS Tests/cameras/world sprite.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.world.setSize(1920, 1200, true);
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
- game.load.image('ball', 'assets/sprites/mana_card.png');
-
-
-
- }
-
- var ball: Phaser.Sprite;
-
- function create() {
-
- game.add.sprite(0, 0, 'backdrop');
-
- ball = game.add.sprite(200, 200, 'ball');
-
- ball.body.velocity.x = 50;
- ball.transform.scale.setTo(2, 2);
-
- }
-
- function update() {
-
- /*
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- //ball.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- //ball.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- //ball.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- //ball.y += 4;
- }
- */
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- ball.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- ball.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- ball.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- ball.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
- Phaser.DebugUtils.renderSpriteInfo(ball, 32, 200);
-
- }
-
-})();
diff --git a/wip/TS Tests/display/render crisp.ts b/wip/TS Tests/display/render crisp.ts
deleted file mode 100644
index abbe1ee6..00000000
--- a/wip/TS Tests/display/render crisp.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('boss', 'assets/misc/boss1.png');
- game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
-
- }
-
- var boss: Phaser.Sprite;
- var button: Phaser.UI.Button;
-
- function create() {
-
- // For browsers that support it, this keeps our pixel art looking crisp
- Phaser.CanvasUtils.setSmoothingEnabled(game.stage.context, false);
-
- boss = game.add.sprite(game.stage.centerX, game.stage.centerY, 'boss');
- boss.origin.setTo(0.5, 0.5);
-
- // Zoom in each time we press it
- button = game.add.button(32, 32, 'button', clickedIt, this, 2, 1, 0);
-
- }
-
- function clickedIt() {
-
- boss.scale.x += 0.5;
- boss.scale.y += 0.5;
-
- }
-
-})();
diff --git a/wip/TS Tests/groups/add to group 1.ts b/wip/TS Tests/groups/add to group 1.ts
deleted file mode 100644
index 1b85986f..00000000
--- a/wip/TS Tests/groups/add to group 1.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var friendAndFoe: Phaser.Group,
- enemies: Phaser.Group;
-
- function preload() {
- game.load.image('ufo', 'assets/sprites/ufo.png');
- game.load.image('baddie', 'assets/sprites/space-baddie.png');
-
- }
- function create() {
- // Create some local groups for later use.
- friendAndFoe = game.add.group();
- enemies = game.add.group();
-
- // Use game.add (GameObjectFactory) to create sprites, those
- // newly created ones will be added to game.world.group
- // automatically. While you can still use new to allocate and
- // only add them to your own groups.
- var ufo: Phaser.Sprite = game.add.sprite(200, 240, 'ufo');
- friendAndFoe.add(ufo);
-
- // Create some enemies using new keyword.
- // (Don't forget to pass game as the first parameter.)
- var enemy;
- for (var i = 0; i < 16; i++) {
- enemy = new Phaser.Sprite(game,
- 360 + Math.random() * 200, 120 + Math.random() * 200,
- 'baddie');
- enemies.add(enemy);
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('ufo added to game.world.group and "friendAndFoe" group', 16, 24);
- Phaser.DebugUtils.context.fillText('others ONLY added to "enemies" group', 16, 40);
- }
-})();
diff --git a/wip/TS Tests/groups/add to group 2.ts b/wip/TS Tests/groups/add to group 2.ts
deleted file mode 100644
index d5e74de2..00000000
--- a/wip/TS Tests/groups/add to group 2.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
- function preload() {
- game.load.image('ufo', 'assets/sprites/ufo.png');
- game.load.image('baddie', 'assets/sprites/space-baddie.png');
-
- }
-
- var friendAndFoe: Phaser.Group,
- enemies: Phaser.Group;
-
- function create() {
- // Create some local groups for later use.
- friendAndFoe = game.add.group();
- enemies = game.add.group();
-
- // You can directly create sprite and add it to a group
- // using just one line. (One thing you should know is, the body type
- // of this sprite is set to BODY_DINAMIC by default, while it's
- // BODY_DISABLED by default using other creating methods.)
- friendAndFoe.addNewSprite(200, 240, 'ufo', null, Phaser.Types.BODY_DISABLED);
-
- // Create some enemies.
- for (var i = 0; i < 8; i++) {
- createBaddie();
- }
-
- // Tap to create new baddie sprites.
- game.input.onTap.add(createBaddie, this);
- }
- function createBaddie() {
- enemies.addNewSprite(360 + Math.random() * 200, 120 + Math.random() * 200,
- 'baddie', null,
- Phaser.Types.BODY_DISABLED);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Tap screen or click to create new baddies.', 16, 24);
- }
-})();
diff --git a/wip/TS Tests/groups/bring to top 1.ts b/wip/TS Tests/groups/bring to top 1.ts
deleted file mode 100644
index 28cb07a9..00000000
--- a/wip/TS Tests/groups/bring to top 1.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
- game.load.image('snot', 'assets/pics/nslide_snot.png');
- game.load.image('atari1', 'assets/sprites/atari130xe.png');
- game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
- game.load.image('coke', 'assets/sprites/cokecan.png');
- game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png');
-
-
- }
-
- var group1: Phaser.Group;
- var group2: Phaser.Group;
- var coke: Phaser.Sprite;
- var disk: Phaser.Sprite;
-
- function create() {
-
- // Create a background image
- game.add.sprite(0, 0, 'beast');
-
- // Create a Group that will sit above the background image
- group1 = game.add.group(11);
-
- // Create a Group that will sit above Group 1
- group2 = game.add.group(11);
-
- // Now let's create some random sprites and enable them all for drag and 'bring to top'
- for (var i = 0; i < 10; i++)
- {
- //var tempSprite: Phaser.Sprite = group1.addNewSprite(game.stage.randomX, game.stage.randomY, 'atari1');
- //var tempSprite: Phaser.Sprite = new Phaser.Sprite(game, game.stage.randomX, game.stage.randomY, 'atari1');
- var tempSprite: Phaser.Sprite = game.add.sprite(game.stage.randomX, game.stage.randomY, 'atari1');
-
- tempSprite.name = 'atari' + i;
- tempSprite.input.start(i, false, true);
- tempSprite.input.enableDrag(false, true);
-
- group1.add(tempSprite);
-
- // Sonics
-
- //var tempSprite: Phaser.Sprite = group2.addNewSprite(game.stage.randomX, game.stage.randomY, 'sonic');
- //var tempSprite: Phaser.Sprite = new Phaser.Sprite(game, game.stage.randomX, game.stage.randomY, 'sonic');
- var tempSprite: Phaser.Sprite = game.add.sprite(game.stage.randomX, game.stage.randomY, 'sonic');
-
- tempSprite.name = 'sonic' + i;
- tempSprite.input.start(10 + i, false, true);
- tempSprite.input.enableDrag(false, true);
-
- group2.add(tempSprite);
- }
-
- // Add 2 control sprites into each group - these cannot be dragged but should be bought to the top each time
- coke = group1.addNewSprite(100, 100, 'coke');
- disk = group2.addNewSprite(400, 300, 'disk');
-
- // Create a foreground image - everything should appear behind this, even when dragged
- var snot = game.add.sprite(game.stage.centerX, game.stage.height, 'snot');
- snot.origin.setTo(0.5, 1);
-
- // You can click and drag any sprite but Sonic sprites should always appear above the Atari sprites
- // and both types of sprite should only ever appear above the background and behind the
-
- }
-
- function update() {
-
- if (game.input.keyboard.justReleased(Phaser.Keyboard.ONE))
- {
- coke.bringToTop();
- }
-
- if (game.input.keyboard.justReleased(Phaser.Keyboard.TWO))
- {
- disk.bringToTop();
- }
-
- }
-
- function render() {
- Phaser.DebugUtils.renderInputInfo(32, 32);
- }
-
-})();
diff --git a/wip/TS Tests/groups/bring to top.ts b/wip/TS Tests/groups/bring to top.ts
deleted file mode 100644
index 658497c3..00000000
--- a/wip/TS Tests/groups/bring to top.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var container: Phaser.Group;
-
- function preload() {
- game.load.spritesheet('button', 'assets/buttons/number-buttons.png', 160, 160);
-
- }
- function create() {
- // Container for sorting the buttons, which we'll use to make buttons
- // to the top later.
- container = game.add.group();
-
- // Add buttons to container.
- container.add(game.add.button(200, 100, 'button', bringMeToTop, this, 0, 0, 0));
- container.add(game.add.button(300, 100, 'button', bringMeToTop, this, 1, 1, 1));
- container.add(game.add.button(100, 200, 'button', bringMeToTop, this, 2, 2, 2));
- container.add(game.add.button(400, 200, 'button', bringMeToTop, this, 3, 3, 3));
- container.add(game.add.button(300, 300, 'button', bringMeToTop, this, 4, 4, 4));
- container.add(game.add.button(200, 300, 'button', bringMeToTop, this, 5, 5, 5));
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Tap or click buttons to bring it to the top.', 32, 32);
- }
- function bringMeToTop(btn) {
- container.bringToTop(btn);
- }
-})();
diff --git a/wip/TS Tests/groups/call all.ts b/wip/TS Tests/groups/call all.ts
deleted file mode 100644
index 530b4eeb..00000000
--- a/wip/TS Tests/groups/call all.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
- game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
-
- }
- function create() {
- // Add some items.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- item = game.add.sprite(290, 98 * (i + 1), 'item', i);
- // Enable input.
- item.input.start(0, false, true);
- item.events.onInputUp.add(kill);
- // An item besides the left one.
- item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
- item.input.start(0, false, true);
- item.events.onInputUp.add(kill);
- }
- // Add a button to revive all the items.
- game.add.button(270, 400, 'reviveBtn', reviveAll, this, 0, 0, 0);
- }
- function kill(item) {
- item.kill();
- }
- function reviveAll() {
- game.world.group.callAll('revive');
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Tap or click an item to kill it, and press the revive button to revive them all.', 160, 500);
- }
-})();
diff --git a/wip/TS Tests/groups/create group 1.ts b/wip/TS Tests/groups/create group 1.ts
deleted file mode 100644
index 7e2e71bc..00000000
--- a/wip/TS Tests/groups/create group 1.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
-
-
- }
-
- var firstGroup: Phaser.Group;
-
- function create() {
-
- // Here we'll create a new Group
- firstGroup = game.add.group();
-
- // And add some sprites to it
- for (var i = 0; i < 10; i++)
- {
- // Create a new sprite at a random screen location
- var newSprite: Phaser.Sprite = new Phaser.Sprite(game, game.stage.randomX, game.stage.randomY, 'sonic');
-
- // This set-ups a listener for the event, view your console.log output to see the result
- newSprite.events.onAddedToGroup.add(logGroupAdd);
-
- // Add the sprite to the Group
- firstGroup.add(newSprite);
- }
-
- }
-
- function logGroupAdd(sprite: Phaser.Sprite, group: Phaser.Group, zIndex: number) {
-
- console.log('Sprite added to Group', group.ID, 'at z-index:', zIndex);
-
- }
-
-})();
diff --git a/wip/TS Tests/groups/direct render.ts b/wip/TS Tests/groups/direct render.ts
deleted file mode 100644
index 10d03b95..00000000
--- a/wip/TS Tests/groups/direct render.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- // Left and right group.
- var left:: Phaser.Group, right: Phaser.Group;
- // The first selected item.
- var selected: Phaser.Sprite = null;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
-
- }
- function create() {
- left = game.add.group();
- right = new Phaser.Group(game);
- // Add some items to left side, and set a onDragStop listener
- // to limit its location when dropped.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Directly create sprites from the left group.
- item = left.addNewSprite(250, 98 * (i + 1), 'item', i, Phaser.Types.BODY_DISABLED);
- // Add another to the right group.
- item = right.addNewSprite(348, 98 * (i + 1), 'item', i + 3, Phaser.Types.BODY_DISABLED);
- }
-
- exCamera = game.add.camera(0, 0, 800, 600);
- exCamera.setPosition(120, 0);
- }
- function render() {
- right.directRender(exCamera);
-
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Left Group', 300, 80);
- Phaser.DebugUtils.context.fillText('Right Group', 400, 80);
- Phaser.DebugUtils.context.fillText('Left group is normally rendered, while the right one is ONLY rendered directly to another camera.', 120, 480);
- }
-})();
diff --git a/wip/TS Tests/groups/display order.ts b/wip/TS Tests/groups/display order.ts
deleted file mode 100644
index 3795e3e9..00000000
--- a/wip/TS Tests/groups/display order.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('atari1', 'assets/sprites/atari130xe.png');
- game.load.image('atari2', 'assets/sprites/atari800xl.png');
- game.load.image('card', 'assets/sprites/mana_card.png');
-
-
-
- }
-
- var items: Phaser.Group;
- var card: Phaser.Sprite;
-
- function create() {
-
- items = game.add.group();
-
- // Items are rendered in the depth order in which they are added to the Group
-
- items.addNewSprite(64, 100, 'atari1');
- card = items.addNewSprite(240, 80, 'card');
- items.addNewSprite(280, 100, 'atari2');
-
- game.input.onTap.addOnce(removeCard, this);
-
- }
-
- function removeCard() {
-
- // Now let's kill the card sprite
- card.kill();
-
- game.input.onTap.addOnce(replaceCard, this);
-
- }
-
- function replaceCard() {
-
- // And bring it back to life again - I assume it will render in the same place as before?
- var bob = items.getFirstDead();
-
- bob.revive();
-
- }
-
-})();
diff --git a/wip/TS Tests/groups/for each.ts b/wip/TS Tests/groups/for each.ts
deleted file mode 100644
index f41e5aaa..00000000
--- a/wip/TS Tests/groups/for each.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var baseAlphaIncSpeed: Number = 0.006;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
-
- }
- function create() {
- // Add some items.
- for (var i = 0; i < 3; i++) {
- game.add.sprite(290, 98 * (i + 1), 'item', i)
- .alphaIncSpeed = baseAlphaIncSpeed * (i + 1);
- game.add.sprite(388, 98 * (i + 1), 'item', i + 3)
- .alphaIncSpeed = baseAlphaIncSpeed * (i + 4);
- }
- }
- function update() {
- // Animating alpha property of each item using forEach() method.
- game.world.group.forEach(function(item) {
- // Update alpha first.
- item.alpha -= item.alphaIncSpeed;
- // Check for switch between increasing and descreasing.
- if (item.alpha < 0.001 || item.alpha > 0.999) {
- item.alphaIncSpeed *= -1;
- }
- });
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Alpha of items is always changing.', 280, 480);
- }
-})();
diff --git a/wip/TS Tests/groups/get first 1.ts b/wip/TS Tests/groups/get first 1.ts
deleted file mode 100644
index 5ef8194e..00000000
--- a/wip/TS Tests/groups/get first 1.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var timer: Number,
- cycle: Number;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
- game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
-
- }
- function create() {
- // Add some items.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- item = game.add.sprite(290, 98 * (i + 1), 'item', i);
- // An item besides the left one.
- item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
- }
-
- // Set a timer so we can perform an action after a delay.
- timer = 0;
- cycle = 1000;
- }
- function update() {
- // Update timer.
- timer += game.time.delta;
- if (timer > cycle) {
- timer -= cycle;
- // Get the first alive item and kill it.
- var item = game.world.group.getFirstAlive();
- if (item) {
- item.kill();
- }
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('One item will be killed each second.', 280, 420);
- // Get living and dead number of a group.
- Phaser.DebugUtils.context.fillText('Living: ' + game.world.group.countLiving() + ', Dead: ' + game.world.group.countDead(), 330, 440);
- }
-})();
diff --git a/wip/TS Tests/groups/get first 2.ts b/wip/TS Tests/groups/get first 2.ts
deleted file mode 100644
index dc61445a..00000000
--- a/wip/TS Tests/groups/get first 2.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var timer: Number,
- cycle: Number;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
- game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
-
- }
- function create() {
- // Add some items.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- item = game.add.sprite(290, 98 * (i + 1), 'item', i);
- // An item besides the left one.
- item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
- }
-
- // Set a timer so we can perform an action after a delay.
- timer = 0;
- cycle = 1000;
- }
- function update() {
- // Update timer.
- timer += game.time.delta;
- if (timer > cycle) {
- timer -= cycle;
- // Get an alive item from the group randomly, so it may not
- // be the first to be killed.
- // Also you can specific a range, only items between that range
- // will be found and return.
- // Set a range of (0, 5), so the first item will not be kill at all.
- var item: Phaser.Sprite = game.world.group.getRandom(1, 5);
- if (item) {
- item.kill();
- }
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('One item will be killed each second.', 280, 420);
- Phaser.DebugUtils.context.fillText('Yet the first one will NEVER be killed since we use a range from 1 to 5 for selection.', 140, 432);
- // Get living and dead number of a group.
- Phaser.DebugUtils.context.fillText('Living: ' + game.world.group.countLiving() + ', Dead: ' + game.world.group.countDead(), 330, 460);
- }
-})();
diff --git a/wip/TS Tests/groups/get first 3.ts b/wip/TS Tests/groups/get first 3.ts
deleted file mode 100644
index cfc69653..00000000
--- a/wip/TS Tests/groups/get first 3.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var killTimer: Number,
- reviveTimer: Number,
- cycle: Number;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
- game.load.image('reviveBtn', 'assets/buttons/revive-button.png');
-
- }
- function create() {
- // Add some items.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- item = game.add.sprite(290, 98 * (i + 1), 'item', i);
- // An item besides the left one.
- item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
- }
-
- // Set a timer so we can perform an action after a delay.
- killTimer = 0;
- // Another timer for reviving.
- reviveTimer = 0;
- cycle = 1000;
- }
- function update() {
- // Update timers.
- killTimer += game.time.delta;
- reviveTimer += game.time.delta;
-
- // Kill first alive item every "cycle" duration.
- if (killTimer > cycle) {
- killTimer -= cycle;
- // Get an alive item from the group and kill it.
- var item: Phaser.Sprite = game.world.group.getFirstAlive();
- if (item) {
- item.kill();
- }
- }
- // Revive first dead item every 1.5 "cycle" duration.
- if (reviveTimer > cycle * 1.5) {
- reviveTimer -= cycle * 1.5;
- // Get a dead item from the group and revive it.
- var item: Phaser.Sprite = game.world.group.getFirstDead();
- if (item) {
- item.revive();
- }
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('One item will be killed each second and revived later.', 240, 420);
- // Get living and dead number of a group.
- Phaser.DebugUtils.context.fillText('Living: ' + game.world.group.countLiving() + ', Dead: ' + game.world.group.countDead(), 330, 440);
- }
-})();
diff --git a/wip/TS Tests/groups/group as layer.ts b/wip/TS Tests/groups/group as layer.ts
deleted file mode 100644
index 1c221822..00000000
--- a/wip/TS Tests/groups/group as layer.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
- function preload() {
- game.world.setSize(1280, 800, true);
-
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
- game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
- game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
- game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
-
- game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
-
-
- }
- function create() {
- // Create the sky layer, behind everything and donot move.
- var skyLayer: Phaser.Group = game.add.group();
- skyLayer.z = 0;
- // Create the cloud layer, only beyond the sky.
- var cloudLayer: Phaser.Group = game.add.group();
- cloudLayer.z = 1;
- // Create the ground, behind the river and beyond clouds.
- var groundLayer: Phaser.Group = game.add.group();
- groundLayer.z = 2;
- // Create the sprite layer. This should behind the river,
- // and beyond the ground, cloud and sky layer.
- var spriteLayer: Phaser.Group = game.add.group();
- spriteLayer.z = 3;
- // Create the river layer, beyond everything.
- var riverLayer: Phaser.Group = game.add.group();
- riverLayer.z = 4;
-
- // Add sky background to skyLayer.
- var sky: Phaser.Sprite = new Phaser.Sprite(game, 0, 0, 'sky');
- sky.transform.scrollFactor.setTo(0, 0);
- skyLayer.add(sky);
- // Add clouds to cloudLayer.
- var cloud0: Phaser.Sprite = new Phaser.Sprite(game, 200, 120, 'cloud0');
- cloud0.transform.scrollFactor.setTo(0.3, 0.1);
- var cloud1: Phaser.Sprite = new Phaser.Sprite(game, -60, 120, 'cloud1');
- cloud1.transform.scrollFactor.setTo(0.5, 0.1);
- var cloud2: Phaser.Sprite = new Phaser.Sprite(game, 900, 170, 'cloud2');
- cloud2.transform.scrollFactor.setTo(0.7, 0.1);
- cloudLayer.add(cloud0);
- cloudLayer.add(cloud1);
- cloudLayer.add(cloud2);
- // Add ground sprite to groundLayer.
- var ground: Phaser.Sprite = new Phaser.Sprite(game, 0, 360, 'ground');
- ground.transform.scrollFactor.setTo(0.5, 0.1);
- groundLayer.add(ground);
- // Add river to riverLayer.
- var river: Phaser.Sprite = new Phaser.Sprite(game, 0, 400, 'river');
- river.transform.scrollFactor.setTo(1.3, 0.16);
- riverLayer.add(river);
-
- // Add animating sprites to spriteLayer.
- var ufo: Phaser.Sprite = new Phaser.Sprite(game, 360, 240, 'ufo');
- ufo.animations.add('fly', null, 0, false);
- ufo.animations.play('fly');
- ufo.transform.origin.setTo(0.5, 0.5);
- spriteLayer.add(ufo);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('sky layer: z = 0', 16, 20);
- Phaser.DebugUtils.context.fillText('cloud layer: z = 1', 16, 36);
- Phaser.DebugUtils.context.fillText('ground layer: z = 2', 16, 52);
- Phaser.DebugUtils.context.fillText('sprite layer: z = 3', 16, 68);
- Phaser.DebugUtils.context.fillText('river layer: z = 4', 16, 84);
- }
-})();
diff --git a/wip/TS Tests/groups/group transform 1.ts b/wip/TS Tests/groups/group transform 1.ts
deleted file mode 100644
index 0166e70c..00000000
--- a/wip/TS Tests/groups/group transform 1.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var robot: Phaser.Group;
- var eye: Phaser.Sprite,
- body: Phaser.Sprite,
- leftArm: Phaser.Sprite,
- rightArm: Phaser.Sprite,
- leftLeg: Phaser.Sprite,
- rightLeg: Phaser.Sprite;
-
- function preload() {
- game.load.image('eye', 'assets/sprites/robot/eye.png');
- game.load.image('body', 'assets/sprites/robot/body.png');
- game.load.image('arm-l', 'assets/sprites/robot/arm-l.png');
- game.load.image('arm-r', 'assets/sprites/robot/arm-r.png');
- game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
- game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
-
- }
- function create() {
- // Add some items.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- item = game.add.sprite(290, 98 * (i + 1), 'item', i);
- // An item besides the left one.
- item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
- }
- // Use groups of sprites to create a big robot.
- // Robot itself, you can subclass group class in a real game.
- robot = game.add.group();
- // Robot components.
- leftArm = robot.addNewSprite(90, 175, 'arm-l', 0, Phaser.Types.BODY_DISABLED);
- rightArm = robot.addNewSprite(549, 175, 'arm-r', 0, Phaser.Types.BODY_DISABLED);
- leftLeg = robot.addNewSprite(270, 325, 'leg-l', 0, Phaser.Types.BODY_DISABLED);
- rightLeg = robot.addNewSprite(410, 325, 'leg-r', 0, Phaser.Types.BODY_DISABLED);
- body = robot.addNewSprite(219, 32, 'body', 0, Phaser.Types.BODY_DISABLED);
- eye = robot.addNewSprite(335, 173,'eye', 0, Phaser.Types.BODY_DISABLED);
-
- leftArm.input.start(0, false, true);
- leftArm.input.enableDrag();
- rightArm.input.start(0, false, true);
- rightArm.input.enableDrag();
- leftLeg.input.start(0, false, true);
- leftLeg.input.enableDrag();
- rightLeg.input.start(0, false, true);
- rightLeg.input.enableDrag();
- body.input.start(0, false, true);
- body.input.enableDrag();
- eye.input.start(0, false, true);
- eye.input.enableDrag();
- }
- function update() {
- }
- function render() {
- Phaser.DebugUtils.renderSpriteInfo(leftArm, 32, 32);
- Phaser.DebugUtils.renderSpriteInfo(rightArm, 32, 152);
- Phaser.DebugUtils.renderSpriteInfo(leftLeg, 32, 272);
- Phaser.DebugUtils.renderSpriteInfo(rightLeg, 32, 392);
- Phaser.DebugUtils.renderSpriteInfo(rightLeg, 450, 32);
- Phaser.DebugUtils.renderSpriteInfo(rightLeg, 450, 152);
-
- Phaser.DebugUtils.context.fillStyle = 'rgb(0, 160, 213)';
- Phaser.DebugUtils.context.fillText('The robot is a group and every component is a sprite.', 240, 580);
- // Phaser.DebugUtils.context.fillText('Drag each part to re-position them.', 288, 592);
- Phaser.DebugUtils.context.fillText('Drag each part to re-position them. ', 288, 592);
- }
-})();
diff --git a/wip/TS Tests/groups/group transform 2.ts b/wip/TS Tests/groups/group transform 2.ts
deleted file mode 100644
index e37ab4f3..00000000
--- a/wip/TS Tests/groups/group transform 2.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var robot: Phaser.Group;
- var eye: Phaser.Sprite,
- body: Phaser.Sprite,
- leftArm: Phaser.Sprite,
- rightArm: Phaser.Sprite,
- leftLeg: Phaser.Sprite,
- rightLeg: Phaser.Sprite;
-
- function preload() {
- game.load.image('eye', 'assets/sprites/robot/eye.png');
- game.load.image('body', 'assets/sprites/robot/body.png');
- game.load.image('arm-l', 'assets/sprites/robot/arm-l.png');
- game.load.image('arm-r', 'assets/sprites/robot/arm-r.png');
- game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
- game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
-
-
- }
- function create() {
- // Add some items.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- item = game.add.sprite(290, 98 * (i + 1), 'item', i);
- // An item besides the left one.
- item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
- }
- // Use groups of sprites to create a big robot.
- // Robot itself, you can subclass group class in a real game.
- robot = game.add.group();
- // Robot components.
- leftArm = robot.addNewSprite(90, 175, 'arm-l', 0, Phaser.Types.BODY_DISABLED);
- rightArm = robot.addNewSprite(549, 175, 'arm-r', 0, Phaser.Types.BODY_DISABLED);
- leftLeg = robot.addNewSprite(270, 325, 'leg-l', 0, Phaser.Types.BODY_DISABLED);
- rightLeg = robot.addNewSprite(410, 325, 'leg-r', 0, Phaser.Types.BODY_DISABLED);
- body = robot.addNewSprite(219, 32, 'body', 0, Phaser.Types.BODY_DISABLED);
- eye = robot.addNewSprite(335, 173,'eye', 0, Phaser.Types.BODY_DISABLED);
- }
- function update() {
- // Change parent's rotation to change all the childs.
- // robot.transform.rotation += 2;
- game.world.group.transform.rotation += 2;
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = 'rgb(0, 160, 213)';
- Phaser.DebugUtils.context.fillText('The robot is a group and every component is a sprite.', 240, 580);
- }
-})();
diff --git a/wip/TS Tests/groups/group transform 3.ts b/wip/TS Tests/groups/group transform 3.ts
deleted file mode 100644
index d1a04298..00000000
--- a/wip/TS Tests/groups/group transform 3.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var robot: Phaser.Group;
- var eye: Phaser.Sprite,
- body: Phaser.Sprite,
- leftArm: Phaser.Sprite,
- rightArm: Phaser.Sprite,
- leftLeg: Phaser.Sprite,
- rightLeg: Phaser.Sprite;
-
- function preload() {
- game.load.image('eye', 'assets/sprites/robot/eye.png');
- game.load.image('body', 'assets/sprites/robot/body.png');
- game.load.image('arm-l', 'assets/sprites/robot/arm-l.png');
- game.load.image('arm-r', 'assets/sprites/robot/arm-r.png');
- game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
- game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
-
-
- }
- function create() {
- // Add some items.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- item = game.add.sprite(290, 98 * (i + 1), 'item', i);
- // An item besides the left one.
- item = game.add.sprite(388, 98 * (i + 1), 'item', i + 3);
- }
- // Use groups of sprites to create a big robot.
- // Robot itself, you can subclass group class in a real game.
- robot = game.add.group();
- // Robot components.
- leftArm = robot.addNewSprite(90, 175, 'arm-l', 0, Phaser.Types.BODY_DISABLED);
- rightArm = robot.addNewSprite(549, 175, 'arm-r', 0, Phaser.Types.BODY_DISABLED);
- leftLeg = robot.addNewSprite(270, 325, 'leg-l', 0, Phaser.Types.BODY_DISABLED);
- rightLeg = robot.addNewSprite(410, 325, 'leg-r', 0, Phaser.Types.BODY_DISABLED);
- body = robot.addNewSprite(219, 32, 'body', 0, Phaser.Types.BODY_DISABLED);
- eye = robot.addNewSprite(335, 173,'eye', 0, Phaser.Types.BODY_DISABLED);
-
- // Tween the robot's size, so all the components also scaled.
- // game.add.tween(robot.transform.scale)
- game.add.tween(game.world.group.transform.scale)
- .to({x: 1.2, y: 1.2}, 1000, Phaser.Easing.Back.InOut, true, 0, false)
- .yoyo(true);
- }
- function update() {
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = 'rgb(0, 160, 213)';
- Phaser.DebugUtils.context.fillText('The robot is a group and every component is a sprite.', 240, 580);
- }
-})();
diff --git a/wip/TS Tests/groups/recycle 1.ts b/wip/TS Tests/groups/recycle 1.ts
deleted file mode 100644
index a75a2280..00000000
--- a/wip/TS Tests/groups/recycle 1.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var friendAndFoe: Phaser.Group,
- enemies: Phaser.Group;
-
- function preload() {
- game.load.image('ufo', 'assets/sprites/ufo.png');
- game.load.image('baddie', 'assets/sprites/space-baddie.png');
- game.load.spritesheet('button', 'assets/buttons/baddie-buttons.png', 224, 70);
-
- }
- function create() {
- // Create some local groups for later use.
- friendAndFoe = game.add.group();
- enemies = game.add.group();
-
- // Create a ufo.
- friendAndFoe.addNewSprite(200, 240, 'ufo', null, Phaser.Types.BODY_DISABLED);
-
- // Create some enemies.
- for (var i = 0; i < 8; i++) {
- createBaddie();
- }
-
- // Create buttons to create and kill baddies.
- game.add.button(16, 50, 'button', createBaddie, 0, 0, 0);
- game.add.button(16, 130, 'button', killBaddie, 1, 1, 1);
- }
- function killBaddie() {
- var baddie: Phaser.Sprite = enemies.getFirstAlive();
- if (baddie) baddie.kill();
- }
- function createBaddie() {
- // Group's recycle() method will always return a valid object unless
- // you did not pass an objectClass parameter.
- // It will create new object instance of the given class if no "dead"
- // object can be found inside the group.
- var enemy: Phaser.Sprite = enemies.recycle(Phaser.Sprite);
- enemy.texture.loadImage('baddie', false);
- enemy.texture.opaque = false;
- enemy.x = 360 + Math.random() * 200;
- enemy.y = 120 + Math.random() * 200;
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Add new baddies using recyle() instead of allocating new object every time.', 16, 24);
- }
-})();
diff --git a/wip/TS Tests/groups/recycle 2.ts b/wip/TS Tests/groups/recycle 2.ts
deleted file mode 100644
index 1dd33315..00000000
--- a/wip/TS Tests/groups/recycle 2.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var friendAndFoe: Phaser.Group,
- enemies: Phaser.Group;
-
- function preload() {
- game.load.image('ufo', 'assets/sprites/ufo.png');
- game.load.image('baddie', 'assets/sprites/space-baddie.png');
- game.load.spritesheet('button', 'assets/buttons/baddie-buttons.png', 224, 70);
-
- }
- function create() {
- // Create some local groups for later use.
- friendAndFoe = game.add.group();
- enemies = game.add.group();
-
- // Create a ufo.
- friendAndFoe.addNewSprite(200, 240, 'ufo', null, Phaser.Types.BODY_DISABLED);
-
- // Create some enemies.
- for (var i = 0; i < 8; i++) {
- // Since the getFirstAvailable() which we'll use for recycling
- // cannot allocate new objects, create them manually here.
- enemies.addNewSprite(360 + Math.random() * 200, 120 + Math.random() * 200,
- 'baddie', null, Phaser.Types.BODY_DISABLED);
- }
-
- // Create buttons to create and kill baddies.
- game.add.button(16, 50, 'button', createBaddie, 0, 0, 0);
- game.add.button(16, 130, 'button', killBaddie, 1, 1, 1);
- }
- function killBaddie() {
- var baddie: Phaser.Sprite = enemies.getFirstAlive();
- if (baddie) baddie.kill();
- }
- function createBaddie() {
- // Recycle using getFirstAvailable() as an alternative to recycle().
- // Notice that this method will not create new objects if there's no one
- // available, and it won't change size of this group.
- var enemy: Phaser.Sprite = enemies.getFirstAvailable();
- if (enemy) {
- enemy.revive();
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Recycle baddies from a group using getFirstAvailable() instead of recycle().', 16, 24);
- Phaser.DebugUtils.context.fillText('Notice that you cannot add more than 8 baddies since we only create 8 instance.', 16, 36);
- Phaser.DebugUtils.context.fillText('Living baddies: ' + enemies.countLiving(), 340, 420);
- }
-})();
diff --git a/wip/TS Tests/groups/remove.ts b/wip/TS Tests/groups/remove.ts
deleted file mode 100644
index 24cddc55..00000000
--- a/wip/TS Tests/groups/remove.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- // Group contains items.
- var items: Phaser.Group;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
- game.load.image('rect', 'assets/tests/200x100corners.png');
- game.load.image('rect2', 'assets/tests/200x100corners2.png');
-
- }
- function create() {
- // Create item container group.
- items = game.add.group();
-
- // Add some items and add them to the container group,
- // then you can drag and drop them to remove.
- var item: Phaser.Sprite;
- for (var i = 0; i < 6; i++) {
- // Directly create sprites from the group.
- item = items.addNewSprite(90, 90 * i, 'item', i, Phaser.Types.BODY_DISABLED);
- // Enable input detection, then it's possible be dragged.
- item.input.start(0, false, true);
- // Make this item draggable.
- item.input.enableDrag();
- // Then we make it snap to 90x90 grids.
- item.input.enableSnap(90, 90, false, true);
- // Add a handler to remove it using different options when dropped.
- item.events.onDragStop.add(dropHandler);
- }
-
- // Create 2 rectangles, drop it at these rectangle to
- // remove it from origin group normally or
- // cut it from the group's array entirely.
- var rect: Phaser.Sprite = game.add.sprite(400, 0, 'rect');
- rect.transform.scale.setTo(2.0, 3.0);
- var rect2: Phaser.Sprite = game.add.sprite(400, 300, 'rect2');
- rect2.transform.scale.setTo(2.0, 3.0);
- }
- function update() {
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Size of group: ' + items.length, 100, 560);
- Phaser.DebugUtils.context.fillText('Drop here to cut items from groups entirely.', 450, 24);
- Phaser.DebugUtils.context.fillText('Drop here to remove it normally.', 450, 324);
- }
- function dropHandler(item, pointer) {
- if (item.x < 90) {
- item.x = 90;
- }
- else if (item.x > 400) { // So it is dropped in one rectangle.
- if (item.y < 300) {
- // Remove it from group normally, so the group's size does not change.
- items.remove(item, true);
- }
- else {
- // Remove it from group and cut from it, so the group's size decreases.
- items.remove(item);
- }
- }
- }
-})();
diff --git a/wip/TS Tests/groups/replace.ts b/wip/TS Tests/groups/replace.ts
deleted file mode 100644
index 6e9f9eb9..00000000
--- a/wip/TS Tests/groups/replace.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- // Left and right group.
- var left: Phaser.Group, right: Phaser.Group;
- // The first selected item.
- var selected: Phaser.Sprite = null;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
-
- }
- function create() {
- left = game.add.group();
- right = game.add.group();
- // Add some items to left side, and set a onDragStop listener
- // to limit its location when dropped.
- var item: Phaser.Sprite;
- for (var i = 0; i < 3; i++) {
- // Directly create sprites from the left group.
- item = left.addNewSprite(290, 98 * (i + 1), 'item', i, Phaser.Types.BODY_DISABLED);
- // Enable input.
- item.input.start(0, false, true);
- item.events.onInputUp.add(select);
- // Add another to the right group.
- item = right.addNewSprite(388, 98 * (i + 1), 'item', i + 3, Phaser.Types.BODY_DISABLED);
- // Enable input.
- item.input.start(0, false, true);
- item.events.onInputUp.add(select);
- }
- }
- function select(item, pointer) {
- // If there's no one selected, mark it as selected.
- if (!selected) {
- selected = item;
- selected.alpha = 0.5;
- }
- else {
- // Items from different group selected, replace with each other;
- // Something like a swap action, maybe better done with
- // group.swap() method.
- if (selected.group !== item.group) {
- // Move the later selected to the first selected item's position.
- item.x = selected.x;
- item.y = selected.y;
- // Replace first selected with the second one.
- selected.group.replace(selected, item);
- }
- else {
- selected.alpha = 1;
- }
-
- // After checking, now clear the helper var.
- selected = null;
- }
- }
- function update() {
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Left Group', 300, 80);
- Phaser.DebugUtils.context.fillText('Right Group', 400, 80);
- Phaser.DebugUtils.context.fillText('Click an item and one from another group to replace it.', 240, 480);
- }
-})();
diff --git a/wip/TS Tests/groups/set all.ts b/wip/TS Tests/groups/set all.ts
deleted file mode 100644
index ffa20eb7..00000000
--- a/wip/TS Tests/groups/set all.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var baseIncSpeed: Number = 0.006;
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
-
- }
- function create() {
- // Add some items.
- for (var i = 0; i < 3; i++) {
- // Give the items a different alpha increase speed.
- game.add.sprite(290, 98 * (i + 1), 'item', i)
- .alphaIncSpeed = baseIncSpeed * (i + 1);
- game.add.sprite(388, 98 * (i + 1), 'item', i + 3)
- .alphaIncSpeed = baseIncSpeed * (i + 4);
- }
-
- game.input.onTap.add(resetAlpha);
- }
- function resetAlpha() {
- // Set "alpha" value of all the childs.
- game.world.group.setAll('alpha', Math.random());
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Tap or click to set random alpha of all the items.', 240, 480);
- }
-})();
diff --git a/wip/TS Tests/groups/sort 1.ts b/wip/TS Tests/groups/sort 1.ts
deleted file mode 100644
index e521c8cc..00000000
--- a/wip/TS Tests/groups/sort 1.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var xTop: Phaser.Group,
- yTop: Phaser.Group,
- zTop: Phaser.Group;
-
- function preload() {
- game.load.image('cell', 'assets/sprites/diamond.png');
-
- }
- function create() {
- // Create 3 groups which will have different sort "index".
- xTop = game.add.group();
- yTop = game.add.group();
- zTop = game.add.group();
-
- var i: Number;
- for (i = 0; i < 64; i++) {
- xTop.addNewSprite(160 + 48 * Math.cos(i * Math.PI / 8), 540 - i * 8,
- 'cell', 0,
- Phaser.Types.BODY_DISABLED);
- }
- for (i = 0; i < 64; i++) {
- yTop.addNewSprite(340 + 48 * Math.cos(i * Math.PI / 8), 540 - i * 8,
- 'cell', 0,
- Phaser.Types.BODY_DISABLED);
- }
- for (i = 0; i < 64; i++) {
- zTop.addNewSprite(520 + 48 * Math.cos(i * Math.PI / 8), 540 - i * 8,
- 'cell', 0,
- Phaser.Types.BODY_DISABLED);
- }
- }
- function update() {
- // Sort 3 groups using different methods, all of them are
- // ascending by default.
- xTop.sort('x');
- yTop.sort('y');
- zTop.sort('z');
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Left group sorted by x.', 16, 18);
- Phaser.DebugUtils.context.fillText('Middle group sorted by y.', 16, 36);
- Phaser.DebugUtils.context.fillText('Right group sorted by z.', 16, 54);
- }
-})();
diff --git a/wip/TS Tests/groups/sort 2.ts b/wip/TS Tests/groups/sort 2.ts
deleted file mode 100644
index 51c8a5b1..00000000
--- a/wip/TS Tests/groups/sort 2.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- // Wabbits inside this group is sorted by its "dead" property.
- // Dead wabbits behinds the others.
- var wabbits: Phaser.Group;
-
- function preload() {
- game.load.image('wabbit', 'assets/sprites/wabbit.png');
-
- }
- function create() {
- // Create container group.
- wabbits = game.add.group();
-
- // Create wabbit and add to the container.
- var wabbe: Phaser.Sprite;
- for (var i = 0; i < 64; i++) {
- wabbe = wabbits.addNewSprite(Math.random() * 480 + 64, Math.random() * 480 + 32,
- 'wabbit', 0,
- Phaser.Types.BODY_DISABLED);
- wabbe.transform.scale.setTo(2, 2);
- wabbe.transform.origin.setTo(0.5, 0.5);
-
- // Give wabbie a flag of living or not.
- wabbe.dead = false;
-
- wabbe.input.start(0, false, true);
- wabbe.events.onInputUp.add(killMe, this);
- }
- }
- function update() {
- // sort wabbies by "exists", so killed ones will
- wabbits.sort('dead', Phaser.Group.DESCENDING);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Tap or click wabbits to kill them.', 32, 32);
- }
- function killMe(wabbe) {
- // Disable input.
- wabbe.input.stop();
-
- // Do not call the kill method, set its "dead" property instead.
- wabbe.dead = true;
-
- // Kill effects.
- game.add.tween(wabbe)
- .to({x: wabbe.x - 48}, 2000, Phaser.Easing.Linear.None, true, 0, false);
- game.add.tween(wabbe)
- .to({y: 640}, 2000 - wabbe.y, Phaser.Easing.Back.In, true, 0, false);
- game.add.tween(wabbe)
- .to({rotation: 240}, 1000, Phaser.Easing.Back.In, true, 0, false);
- game.add.tween(wabbe.transform.scale)
- .to({x: 2, y: 2}, 1000, Phaser.Easing.Bounce.In, true, 0, false);
- }
-})();
diff --git a/wip/TS Tests/groups/sub groups.ts b/wip/TS Tests/groups/sub groups.ts
deleted file mode 100644
index 96bbee13..00000000
--- a/wip/TS Tests/groups/sub groups.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- // Groups for storing friends and enemies, may use for collision later.
- var friendAndFoe: Phaser.Group,
- enemies: Phaser.Group;
-
- // Groups for teaming up stuff.
- var normalBaddies: Phaser.Group,
- purpleBaddies: Phaser.Group;
-
- function preload() {
- game.load.image('ufo', 'assets/sprites/ufo.png');
- game.load.image('baddie', 'assets/sprites/space-baddie.png');
- game.load.image('purple-baddie', 'assets/sprites/space-baddie-purple.png');
-
- }
- function create() {
- // Create some local groups for later use.
- friendAndFoe = game.add.group();
- enemies = game.add.group();
- normalBaddies = game.add.group();
- purpleBaddies = game.add.group();
-
- // Add both teams to enemies group.
- enemies.add(normalBaddies);
- enemies.add(purpleBaddies);
-
- // Create a ufo as a friend sprite.
- friendAndFoe.addNewSprite(200, 240, 'ufo', null, Phaser.Types.BODY_DISABLED);
-
- // Create some enemies.
- for (var i = 0; i < 16; i++) {
- createBaddie();
- }
-
- // Tap to create new baddie sprites.
- game.input.onTap.add(createBaddie, this);
- }
- function createBaddie() {
- var baddie: Phaser.Sprite;
- if (Math.random() > 0.5) {
- baddie = purpleBaddies.addNewSprite(360 + Math.random() * 200, 120 + Math.random() * 200,
- 'purple-baddie', null, Phaser.Types.BODY_DISABLED);
- }
- else {
- baddie = normalBaddies.addNewSprite(360 + Math.random() * 200, 120 + Math.random() * 200,
- 'baddie', null, Phaser.Types.BODY_DISABLED);
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Tap screen or click to create new baddies.', 16, 24);
- Phaser.DebugUtils.context.fillText('enemies: ' + enemies.length + ' (actually ' + enemies.length + ' groups)', 16, 48);
- Phaser.DebugUtils.context.fillText('normal baddies: ' + normalBaddies.length, 16, 60);
- Phaser.DebugUtils.context.fillText('purple baddies: ' + purpleBaddies.length, 16, 72);
- Phaser.DebugUtils.context.fillText('friends: ' + friendAndFoe.length, 16, 96);
- }
-})();
diff --git a/wip/TS Tests/groups/swap children.ts b/wip/TS Tests/groups/swap children.ts
deleted file mode 100644
index 51f12245..00000000
--- a/wip/TS Tests/groups/swap children.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('atari1', 'assets/sprites/atari130xe.png');
- game.load.image('atari2', 'assets/sprites/atari800xl.png');
-
-
-
- }
-
- var atari1: Phaser.Sprite;
- var atari2: Phaser.Sprite;
-
- function create() {
-
- // Items are rendered in the depth order in which they are added to the Group
-
- atari1 = game.add.sprite(100, 100, 'atari1');
- atari2 = game.add.sprite(250, 90, 'atari2');
-
- game.input.onTap.add(swapSprites, this);
-
- }
-
- function swapSprites() {
-
- // The 2 Sprites are in the global world Group, but this will work for any Group:
- game.world.group.swap(atari1, atari2);
-
- }
-
-
-})();
diff --git a/wip/TS Tests/input/bring to top.ts b/wip/TS Tests/input/bring to top.ts
deleted file mode 100644
index 9b05718c..00000000
--- a/wip/TS Tests/input/bring to top.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- game.load.image('atari1', 'assets/sprites/atari130xe.png');
- game.load.image('atari2', 'assets/sprites/atari800xl.png');
- game.load.image('atari4', 'assets/sprites/atari800.png');
- game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
- game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
- game.load.image('firstaid', 'assets/sprites/firstaid.png');
- game.load.image('diamond', 'assets/sprites/diamond.png');
- game.load.image('mushroom', 'assets/sprites/mushroom2.png');
-
-
- }
-
- function create() {
-
- // This returns an array of all the image keys in the cache
- var images = game.cache.getImageKeys()
-
- // Now let's create some random sprites and enable them all for drag and 'bring to top'
- for (var i = 0; i < 20; i++)
- {
- var tempSprite: Phaser.Sprite = game.add.sprite(game.stage.randomX, game.stage.randomY, game.rnd.pick(images));
- tempSprite.input.start(i, false, true);
- tempSprite.input.enableDrag(false, true);
- }
-
- }
-
- function render() {
- Phaser.DebugUtils.renderInputInfo(32, 32);
- }
-
-})();
diff --git a/wip/TS Tests/input/drag sprite 1.ts b/wip/TS Tests/input/drag sprite 1.ts
deleted file mode 100644
index daebf83d..00000000
--- a/wip/TS Tests/input/drag sprite 1.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sprite', 'assets/sprites/atari130xe.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
-
- function create() {
-
- sprite = game.add.sprite(200, 200, 'sprite');
-
- // Enable Input detection. Sprites have this disabled by default,
- // so you have to start it if you want to interact with them.
- sprite.input.start(0, false, true);
-
- // This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
- // or if it will snap to the center (true)
- sprite.input.enableDrag(true);
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
- Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/drag sprite 2.ts b/wip/TS Tests/input/drag sprite 2.ts
deleted file mode 100644
index fc5fcf2f..00000000
--- a/wip/TS Tests/input/drag sprite 2.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sprite', 'assets/sprites/atari800.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
-
- function create() {
-
- sprite = game.add.sprite(200, 200, 'sprite');
-
- sprite.input.start(0, false, true);
-
- sprite.input.enableDrag(true);
-
- // The drag offset allows us to position the sprite relative to the pointer (+ lock) position
- // In this case it will be positioned -100px above the pointer
- sprite.input.dragOffset.y = -100;
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
- Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/drag sprite 3.ts b/wip/TS Tests/input/drag sprite 3.ts
deleted file mode 100644
index afd6f6e8..00000000
--- a/wip/TS Tests/input/drag sprite 3.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sprite', 'assets/sprites/atari800.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
-
- function create() {
-
- sprite = game.add.sprite(500, 300, 'sprite');
-
- sprite.input.start(0, false, true);
-
- // This will ensure the sprite is dragged from its center
- sprite.input.enableDrag(true);
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderSpriteCorners(sprite);
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
-
- Phaser.DebugUtils.renderSpriteInfo(sprite, 32, 200);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/drop limitation.ts b/wip/TS Tests/input/drop limitation.ts
deleted file mode 100644
index 608000da..00000000
--- a/wip/TS Tests/input/drop limitation.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
- game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);
-
- }
- function create() {
- // Add some items to left side, and set a onDragStop listener
- // to limit its location when dropped.
- var item: Phaser.Sprite;
- for (var i = 0; i < 6; i++) {
- // Directly create sprites from the left group.
- item = game.add.sprite(90, 90 * i, 'item', i);
- // Enable input detection, then it's possible be dragged.
- item.input.start(0, false, true);
- // Make this item draggable.
- item.input.enableDrag();
- // Then we make it snap to left and right side,
- // also make it only snaps when released.
- item.input.enableSnap(90, 90, false, true);
- // Limit drop location to only the 2 columns.
- item.events.onDragStop.add(fixLocation);
- }
- }
- function update() {
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Group Left.', 100, 560);
- Phaser.DebugUtils.context.fillText('Group Right.', 280, 560);
- }
- function fixLocation(item) {
- // Move the items when it is already dropped.
- if (item.x < 90) {
- item.x = 90;
- }
- else if (item.x > 180 && item.x < 270) {
- item.x = 180;
- }
- else if (item.x > 360) {
- item.x = 270;
- }
- }
-})();
diff --git a/wip/TS Tests/input/game scale 1.ts b/wip/TS Tests/input/game scale 1.ts
deleted file mode 100644
index 57ecc714..00000000
--- a/wip/TS Tests/input/game scale 1.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-///
-
-(function () {
-
- // Here we create a tiny game (320x240 in size)
- var game = new Phaser.Game(this, 'game', 320, 240, preload, create, update, render);
-
- function preload() {
-
- // This sets a limit on the up-scale
- game.stage.scale.maxWidth = 800;
- game.stage.scale.maxHeight = 600;
-
- // Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
- game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
-
- game.load.image('melon', 'assets/sprites/melon.png');
-
-
-
- }
-
- function create() {
-
- game.world.setSize(2000, 2000);
-
- for (var i = 0; i < 1000; i++)
- {
- game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
- }
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(16, 16);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/keyboard 1.ts b/wip/TS Tests/input/keyboard 1.ts
deleted file mode 100644
index 00b83df8..00000000
--- a/wip/TS Tests/input/keyboard 1.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- var ufo: Phaser.Sprite,
- leftBtn: Phaser.Sprite,
- rightBtn: Phaser.Sprite;
- var speed: Number = 4;
-
- function preload() {
- game.world.setSize(1280, 600, true);
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
- game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
- game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
- game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
-
- game.load.spritesheet('button', 'assets/buttons/arrow-button.png', 112, 95);
-
- game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
-
-
- }
- function create() {
- // background images
- game.add.sprite(0, 0, 'sky')
- .transform.scrollFactor.setTo(0, 0);
- game.add.sprite(0, 360, 'ground')
- .transform.scrollFactor.setTo(0.5, 0.5);
- game.add.sprite(0, 400, 'river')
- .transform.scrollFactor.setTo(1.3, 1.3);
- game.add.sprite(200, 120, 'cloud0')
- .transform.scrollFactor.setTo(0.3, 0.3);
- game.add.sprite(-60, 120, 'cloud1')
- .transform.scrollFactor.setTo(0.5, 0.3);
- game.add.sprite(900, 170, 'cloud2')
- .transform.scrollFactor.setTo(0.7, 0.3);
-
- // Create a ufo spirte as player.
- ufo = game.add.sprite(320, 240, 'ufo');
- ufo.animations.add('fly', null, 30, false);
- ufo.animations.play('fly');
- ufo.transform.origin.setTo(0.5, 0.5);
-
- // Make the default camera follow the ufo.
- game.camera.follow(ufo);
-
- // Add 2 sprite to display hold direction.
- leftBtn = game.add.sprite(160 - 112, 200, 'button', 0);
- leftBtn.transform.scrollFactor.setTo(0, 0);
- leftBtn.alpha = 0;
- rightBtn = game.add.sprite(640 - 112, 200, 'button', 1);
- rightBtn.alpha = 0;
- rightBtn.transform.scrollFactor.setTo(0, 0);
- }
- function update() {
- // Check key states every frame.
- // Move ONLY one of the left and right key is hold.
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT) &&
- !game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
- ufo.x -= speed;
- ufo.rotation = -15;
- leftBtn.alpha = 0.6;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) &&
- !game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
- ufo.x += speed;
- ufo.rotation = 15;
- rightBtn.alpha = 0.6;
- }
- else {
- ufo.rotation = 0;
- leftBtn.alpha = rightBtn.alpha = 0;
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Hold left/right to move the ufo.');
- }
-})();
diff --git a/wip/TS Tests/input/keyboard 2.ts b/wip/TS Tests/input/keyboard 2.ts
deleted file mode 100644
index 9c713b47..00000000
--- a/wip/TS Tests/input/keyboard 2.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- var ufo: Phaser.Sprite,
- leftBtn: Phaser.Sprite,
- rightBtn: Phaser.Sprite,
- spaceBtn: Phaser.Sprite;
-
- var speed: Number = 4;
-
- function preload() {
- game.world.setSize(1280, 600, true);
- game.load.image('ground', 'assets/tests/ground-2x.png');
- game.load.image('river', 'assets/tests/river-2x.png');
- game.load.image('sky', 'assets/tests/sky-2x.png');
- game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
- game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
- game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
-
- game.load.spritesheet('button', 'assets/buttons/arrow-button.png', 112, 95);
- game.load.image('spacebar', 'assets/buttons/spacebar.png');
-
- game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
-
-
- }
- function create() {
- // background images
- game.add.sprite(0, 0, 'sky')
- .transform.scrollFactor.setTo(0, 0);
- game.add.sprite(0, 360, 'ground')
- .transform.scrollFactor.setTo(0.5, 0.5);
- game.add.sprite(0, 400, 'river')
- .transform.scrollFactor.setTo(1.3, 1.3);
- game.add.sprite(200, 120, 'cloud0')
- .transform.scrollFactor.setTo(0.3, 0.3);
- game.add.sprite(-60, 120, 'cloud1')
- .transform.scrollFactor.setTo(0.5, 0.3);
- game.add.sprite(900, 170, 'cloud2')
- .transform.scrollFactor.setTo(0.7, 0.3);
-
- // Create a ufo spirte as player.
- ufo = game.add.sprite(320, 240, 'ufo');
- ufo.animations.add('fly', null, 30, false);
- ufo.animations.play('fly');
- ufo.transform.origin.setTo(0.5, 0.5);
-
- // Make the default camera follow the ufo.
- game.camera.follow(ufo);
-
- // Add 2 sprite to display hold direction.
- leftBtn = game.add.sprite(160 - 112 / 2, 200, 'button', 0);
- leftBtn.transform.scrollFactor.setTo(0, 0);
- leftBtn.alpha = 0;
- rightBtn = game.add.sprite(640 - 112 / 2, 200, 'button', 1);
- rightBtn.alpha = 0;
- rightBtn.transform.scrollFactor.setTo(0, 0);
- // Add a sprite to display spacebar press.
- spaceBtn = game.add.sprite(400 - 112, 100, 'spacebar');
- spaceBtn.transform.scrollFactor.setTo(0, 0);
- spaceBtn.alpha = 0;
-
- // Prevent directions and space key events bubbling up to browser,
- // since these keys will make web page scroll which is not
- // expected.
- game.input.keyboard.addKeyCapture([
- Phaser.Keyboard.LEFT,
- Phaser.Keyboard.RIGHT,
- Phaser.Keyboard.UP,
- Phaser.Keyboard.DOWN,
- Phaser.Keyboard.SPACEBAR
- ]);
- }
- function update() {
- // Check key states every frame.
- // Move ONLY one of the left and right key is hold.
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT) &&
- !game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
- ufo.x -= speed;
- ufo.rotation = -15;
- leftBtn.alpha = 0.6;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) &&
- !game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
- ufo.x += speed;
- ufo.rotation = 15;
- rightBtn.alpha = 0.6;
- }
- else {
- ufo.rotation = 0;
- leftBtn.alpha = rightBtn.alpha = 0;
- }
-
- // 50 is a good choice if you are running 60FPS.
- if (game.input.keyboard.justPressed(Phaser.Keyboard.SPACEBAR, 50)) {
- console.log('space bar pressed');
- spaceBtn.alpha = 1;
- }
- if (spaceBtn.alpha > 0) {
- spaceBtn.alpha -= 0.03;
- }
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Hold left/right to move the ufo.', 16, 32);
- Phaser.DebugUtils.context.fillText('Direction and Space key events are stopped by Phaser now, which will no longer be sent to the browser.', 16, 48);
- Phaser.DebugUtils.context.fillText('Now you can press UP/DOWN or SPACE to see what happened.', 16, 64);
- }
-})();
diff --git a/wip/TS Tests/input/motion lock 2.ts b/wip/TS Tests/input/motion lock 2.ts
deleted file mode 100644
index 900d8782..00000000
--- a/wip/TS Tests/input/motion lock 2.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sprite', 'assets/sprites/darkwing_crazy.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(85,85,85)';
-
- sprite = game.add.sprite(200, 200, 'sprite');
-
- // Enable Input detection. Sprites have this disabled by default,
- // so you have to start it if you want to interact with them.
- sprite.input.start(0, false, true);
-
- // This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
- // or if it will snap to the center (true)
- sprite.input.enableDrag();
-
- // This will lock the sprite so it can only be dragged vertically, not horizontally
- sprite.input.allowHorizontalDrag = false;
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
- Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/motion lock.ts b/wip/TS Tests/input/motion lock.ts
deleted file mode 100644
index e9b4625f..00000000
--- a/wip/TS Tests/input/motion lock.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sprite', 'assets/sprites/parsec.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(85,85,85)';
-
- sprite = game.add.sprite(200, 400, 'sprite');
-
- // Enable Input detection. Sprites have this disabled by default,
- // so you have to start it if you want to interact with them.
- sprite.input.start(0, false, true);
-
- // This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
- // or if it will snap to the center (true)
- sprite.input.enableDrag();
-
- // This will lock the sprite so it can only be dragged horizontally, not vertically
- sprite.input.allowVerticalDrag = false;
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
- Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/multitouch.ts b/wip/TS Tests/input/multitouch.ts
deleted file mode 100644
index 1f236a33..00000000
--- a/wip/TS Tests/input/multitouch.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, null, null, null, render);
-
- function render() {
-
- Phaser.DebugUtils.renderPointer(game.input.pointer1);
- Phaser.DebugUtils.renderPointer(game.input.pointer2);
- Phaser.DebugUtils.renderPointer(game.input.pointer3);
- Phaser.DebugUtils.renderPointer(game.input.pointer4);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/over sprite 1.ts b/wip/TS Tests/input/over sprite 1.ts
deleted file mode 100644
index 63bdbcdf..00000000
--- a/wip/TS Tests/input/over sprite 1.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sprite', 'assets/sprites/atari130xe.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
-
- function create() {
-
- sprite = game.add.sprite(200, 200, 'sprite');
-
- // Enable Input detection
- sprite.input.start(0, false, true);
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
- Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/over sprite 2.ts b/wip/TS Tests/input/over sprite 2.ts
deleted file mode 100644
index 2fa65a03..00000000
--- a/wip/TS Tests/input/over sprite 2.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('sprite', 'assets/sprites/shinyball.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
-
- function create() {
-
- // Create a load of sprites
- for (var i = 0; i < 26; i++)
- {
- var tempSprite: Phaser.Sprite = game.add.sprite(i * 32, 100, 'sprite');
- tempSprite.input.start(0, false, true);
- tempSprite.events.onInputOver.add(dropSprite, this);
- }
-
- }
-
- function dropSprite(sprite: Phaser.Sprite) {
-
- sprite.body.velocity.y = 300;
- sprite.input.enabled = false;
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/point in rotated sprite.ts b/wip/TS Tests/input/point in rotated sprite.ts
deleted file mode 100644
index 7a28d25d..00000000
--- a/wip/TS Tests/input/point in rotated sprite.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('sprite', 'assets/sprites/atari130xe.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
- var rotate: bool = false;
-
- function create() {
-
- sprite = game.add.sprite(200, 200, 'sprite');
-
- game.input.onTap.add(rotateIt, this);
-
- }
-
- function rotateIt() {
- if (rotate == false) { rotate = true; } else { rotate = false; }
- }
-
- var inPoint: bool = false;
-
- function update() {
-
- if (rotate)
- {
- sprite.rotation++;
- }
-
- inPoint = Phaser.SpriteUtils.overlapsXY(sprite, game.input.x, game.input.y);
-
- }
-
- function render() {
-
- game.stage.context.save();
- game.stage.context.fillStyle = 'rgb(255,0,255)';
-
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
-
- game.stage.context.fillText('in: ' + inPoint, 300, 32);
-
- game.stage.context.restore();
-
- }
-
-})();
diff --git a/wip/TS Tests/input/rotated sprites.ts b/wip/TS Tests/input/rotated sprites.ts
deleted file mode 100644
index 04faec21..00000000
--- a/wip/TS Tests/input/rotated sprites.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('atari1', 'assets/sprites/atari130xe.png');
- game.load.image('atari2', 'assets/sprites/atari800xl.png');
- game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
-
-
- }
-
- var atari1: Phaser.Sprite;
- var atari2: Phaser.Sprite;
- var sonic: Phaser.Sprite;
-
- function create() {
-
- atari1 = game.add.sprite(200, 200, 'atari1');
- atari2 = game.add.sprite(500, 400, 'atari2');
- sonic = game.add.sprite(400, 500, 'sonic');
-
- atari1.origin.setTo(0.5, 0.5);
- atari1.rotation = 35;
-
- atari2.origin.setTo(1, 1);
- atari2.rotation = 80;
-
- sonic.rotation = 140;
-
- atari1.input.start(0, false, true);
- atari2.input.start(1, false, true);
- sonic.input.start(2, false, true);
-
- atari1.input.enableDrag();
- atari2.input.enableDrag();
- sonic.input.enableDrag();
-
- }
-
- function render() {
- Phaser.DebugUtils.renderInputInfo(32, 32);
- }
-
-})();
diff --git a/wip/TS Tests/input/snap 1.ts b/wip/TS Tests/input/snap 1.ts
deleted file mode 100644
index 3f6481aa..00000000
--- a/wip/TS Tests/input/snap 1.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
- game.load.image('atari1', 'assets/sprites/atari130xe.png');
- game.load.image('atari2', 'assets/sprites/atari800xl.png');
-
-
- }
-
- var atari1: Phaser.Sprite;
- var atari2: Phaser.Sprite;
- var sonic: Phaser.Sprite;
-
- function create() {
-
- game.add.sprite(0, 0, 'grid');
-
- atari1 = game.add.sprite(128, 128, 'atari1');
- atari2 = game.add.sprite(256, 256, 'atari2');
-
- // Input Enable the sprites
- atari1.input.start(0, false, true);
- atari2.input.start(1, false, true);
-
- // Allow dragging
- atari1.input.enableDrag();
- atari2.input.enableDrag();
-
- // Enable snapping. For the atari1 sprite it will snap as its dragged around and on release.
- // The snap is set to every 32x32 pixels.
- atari1.input.enableSnap(32, 32, true, true);
-
- // For the atari2 sprite it will snap only when released, not on drag.
- atari2.input.enableSnap(32, 32, false, true);
-
- }
-
- function render() {
- Phaser.DebugUtils.renderInputInfo(32, 32);
- }
-
-})();
diff --git a/wip/TS Tests/input/touch priority.ts b/wip/TS Tests/input/touch priority.ts
deleted file mode 100644
index beff791c..00000000
--- a/wip/TS Tests/input/touch priority.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('atari1', 'assets/sprites/atari130xe.png');
- game.load.image('atari2', 'assets/sprites/atari800xl.png');
- game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
-
-
- }
-
- var atari1: Phaser.Sprite;
- var atari2: Phaser.Sprite;
- var sonic: Phaser.Sprite;
-
- function create() {
-
- atari1 = game.add.sprite(100, 100, 'atari1');
- atari2 = game.add.sprite(300, 200, 'atari2');
- sonic = game.add.sprite(400, 300, 'sonic');
-
- atari1.input.start(0, false, true);
- atari2.input.start(1, false, true);
- sonic.input.start(2, false, true);
-
- atari1.input.enableDrag();
- atari2.input.enableDrag();
- sonic.input.enableDrag();
-
- }
-
- function render() {
- Phaser.DebugUtils.renderInputInfo(32, 32);
- }
-
-})();
diff --git a/wip/TS Tests/input/world coordinates.ts b/wip/TS Tests/input/world coordinates.ts
deleted file mode 100644
index 760d1a2c..00000000
--- a/wip/TS Tests/input/world coordinates.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.world.setSize(1920, 1200, true);
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
-
-
-
- }
-
- var test: Phaser.Sprite;
-
- function create() {
-
- game.add.sprite(0, 0, 'backdrop');
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderInputInfo(32, 32);
- Phaser.DebugUtils.renderPointer(game.input.activePointer);
-
- }
-
-})();
diff --git a/wip/TS Tests/input/world drag.ts b/wip/TS Tests/input/world drag.ts
deleted file mode 100644
index 86f1daf8..00000000
--- a/wip/TS Tests/input/world drag.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.world.setSize(1920, 1200, true);
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
- game.load.image('diamond', 'assets/sprites/diamond.png');
-
-
-
- }
-
- var test: Phaser.Sprite;
-
- function create() {
-
- game.add.sprite(0, 0, 'backdrop');
-
- for (var i = 0; i < 50; i++)
- {
- var sprite: Phaser.Sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'diamond');
- sprite.input.start(i, false, true);
-
- if (i < 25)
- {
- sprite.input.enableDrag(false);
- }
- else
- {
- sprite.input.enableDrag(true);
- sprite.alpha = 0.5;
- }
-
- }
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- function render() {
-
- Phaser.DebugUtils.renderCameraInfo(game.camera, 16, 32);
- Phaser.DebugUtils.renderInputInfo(16, 200);
-
- }
-
-})();
diff --git a/wip/TS Tests/misc/boot screen.ts b/wip/TS Tests/misc/boot screen.ts
deleted file mode 100644
index 29b0043d..00000000
--- a/wip/TS Tests/misc/boot screen.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-///
-
-(function () {
-
- // If you don't give any parameters to Phaser beyond the defaults you'll see the standard Phaser boot screen appear.
- var game = new Phaser.Game(this, 'game');
-
-})();
diff --git a/wip/TS Tests/misc/color utils 1.ts b/wip/TS Tests/misc/color utils 1.ts
deleted file mode 100644
index 6bd7972b..00000000
--- a/wip/TS Tests/misc/color utils 1.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var colorWheel: Phaser.Sprite,
- selected: Phaser.Sprite,
- color: String = '#CCA22B';
- var offset = {
- x: 300 - 578 / 2,
- y: 300 - 550 / 2
- };
- var rect: Phaser.Rectangle,
- rectSize: Number = 24;
-
- function preload() {
- game.load.image('color-wheel', 'assets/pics/color-wheel.png');
-
- }
- function create() {
- // Create color wheel texture.
- colorWheel = game.add.dynamicTexture(578, 550);
- colorWheel.pasteImage('color-wheel');
-
- // Create a rectangle shows the color you just selected.
- rect = new Phaser.Rectangle(0, 0, rectSize, rectSize);
- selected = game.add.sprite(600, 430);
- selected.width = rectSize;
- selected.height = rectSize;
- selected.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- selected.texture.dynamicTexture.fillRect(rect, color);
-
- // Get the color under the position you tapped or clicked.
- var pos = {};
- game.input.onTap.add(function(pointer) {
- pos.x = pointer.position.x - offset.x;
- pos.y = pointer.position.y - offset.y;
- color = Phaser.ColorUtils.RGBtoWebstring(colorWheel.getPixel32(pos.x, pos.y));
-
- // Set the rectangle's color to new selected one.
- selected.texture.dynamicTexture.fillRect(rect, color);
- });
-
- // Set the background color to white.
- game.stage.backgroundColor = '#fff';
-}
- function render() {
- colorWheel.render(offset.x, offset.y);
-
- Phaser.DebugUtils.context.fillStyle = '#000';
- Phaser.DebugUtils.context.fillText('Tap or click the color wheel to select a color.', 480, 52);
- Phaser.DebugUtils.context.fillText(color, 646, 452);
- }
-})();
diff --git a/wip/TS Tests/misc/color utils 2.ts b/wip/TS Tests/misc/color utils 2.ts
deleted file mode 100644
index a0d5e40a..00000000
--- a/wip/TS Tests/misc/color utils 2.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var colorWheel: Phaser.Sprite,
- selected: Phaser.Sprite,
- color: Number = 0xAACCA22B,
- colorStr: String = '#CCA22B';
- var offset = {
- x: 300 - 578 / 2,
- y: 300 - 550 / 2
- };
- var rect: Phaser.Rectangle,
- rectSize = 24;
-
- function preload() {
- game.load.image('color-wheel', 'assets/pics/color-wheel.png');
-
- }
- function create() {
- // Create color wheel texture.
- colorWheel = game.add.dynamicTexture(578, 550);
- colorWheel.pasteImage('color-wheel');
-
- // Create a rectangle shows the color you just selected.
- rect = new Phaser.Rectangle(0, 0, rectSize, rectSize);
- selected = game.add.sprite(600, 430);
- selected.width = rectSize;
- selected.height = rectSize;
- selected.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- selected.texture.dynamicTexture.fillRect(rect, colorStr);
-
- // Get the color under the position you tapped or clicked.
- var pos = {};
- game.input.onTap.add(function(pointer) {
- pos.x = pointer.position.x - offset.x;
- pos.y = pointer.position.y - offset.y;
- color = colorWheel.getPixel32(pos.x, pos.y);
- colorStr = Phaser.ColorUtils.RGBtoWebstring(color);
-
- // Set the rectangle's color to new selected one.
- selected.texture.dynamicTexture.fillRect(rect, colorStr);
- });
-
- // Set the background color to white.
- game.stage.backgroundColor = '#fff';
-}
- function render() {
- colorWheel.render(offset.x, offset.y);
-
- Phaser.DebugUtils.context.fillStyle = '#000';
- Phaser.DebugUtils.context.fillText('Tap or click the color wheel to select a color.', 480, 52);
-
- // Display more color formated infos here. You can also get a
- // string contains everything using getColorInfo();
- Phaser.DebugUtils.context.fillText('Web String: ' + colorStr, 600, 492);
- Phaser.DebugUtils.context.fillText('Hex String: ' + Phaser.ColorUtils.RGBtoHexstring(color), 600, 508);
- var hsv = Phaser.ColorUtils.RGBtoHSV(color);
- Phaser.DebugUtils.context.fillText('HSV: (' + hsv.hue.toFixed() + ', ' + hsv.saturation.toFixed(2) + ', ' + hsv.value.toFixed(2) + ')', 600, 524);
- }
-})();
diff --git a/wip/TS Tests/misc/color utils 3.ts b/wip/TS Tests/misc/color utils 3.ts
deleted file mode 100644
index 08336bc2..00000000
--- a/wip/TS Tests/misc/color utils 3.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- var colorWheel: Phaser.Sprite,
- selected: Phaser.Sprite,
- compHarmony: Phaser.Sprite,
- analoHarmony: Phaser.Sprite, analoHarmony1: Phaser.Sprite,
- splitHarmony: Phaser.Sprite, splitHarmony1: Phaser.Sprite,
- triaHarmony: Phaser.Sprite, triaHarmony1: Phaser.Sprite,
-
- color: Number = 0xAACCA22B, colorStr: String = '#CCA22B',
- compHColor: Number,
- analoColor: Number, splitColor: Number, triaColor: Number,
- analoColor1: Number, splitColor1: Number, triaColor1: Number;
-
- var offset = {
- x: 300 - 578 / 2,
- y: 300 - 550 / 2
- };
- var rect: Phaser.Rectangle,
- rectSize: Number = 24;
-
- function preload() {
- game.load.image('color-wheel', 'assets/pics/color-wheel.png');
-
- }
- function create() {
- // Create color wheel texture.
- colorWheel = game.add.dynamicTexture(578, 550);
- colorWheel.pasteImage('color-wheel');
-
- // Create a rectangle shows the color you just selected.
- rect = new Phaser.Rectangle(0, 0, rectSize, rectSize);
- selected = game.add.sprite(700, 290);
- selected.width = rectSize;
- selected.height = rectSize;
- selected.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- selected.texture.dynamicTexture.fillRect(rect, colorStr);
-
- // Create rectangles to show the harmony colors to the selected one.
- compHColor = Phaser.ColorUtils.getComplementHarmony(color),
- analoColor = Phaser.ColorUtils.getAnalogousHarmony(color),
- splitColor = Phaser.ColorUtils.getSplitComplementHarmony(color),
- triaColor = Phaser.ColorUtils.getTriadicHarmony(color);
-
- // Complement
- compHarmony = game.add.sprite(700, 390);
- compHarmony.width = rectSize;
- compHarmony.height = rectSize;
- compHarmony.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- compHarmony.texture.dynamicTexture.fillRect(rect, Phaser.ColorUtils.RGBtoWebstring(compHColor));
-
- // Analogous
- analoHarmony = game.add.sprite(700, 434);
- analoHarmony.width = rectSize;
- analoHarmony.height = rectSize;
- analoHarmony.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- analoHarmony.texture.dynamicTexture.fillRect(rect, Phaser.ColorUtils.RGBtoWebstring(analoColor.color2));
-
- analoHarmony1 = game.add.sprite(744, 434);
- analoHarmony1.width = rectSize;
- analoHarmony1.height = rectSize;
- analoHarmony1.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- analoHarmony1.texture.dynamicTexture.fillRect(rect, Phaser.ColorUtils.RGBtoWebstring(analoColor.color3));
-
- // Split Complement
- splitHarmony = game.add.sprite(700, 478);
- splitHarmony.width = rectSize;
- splitHarmony.height = rectSize;
- splitHarmony.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- splitHarmony.texture.dynamicTexture.fillRect(rect, Phaser.ColorUtils.RGBtoWebstring(splitColor.color2));
-
- splitHarmony1 = game.add.sprite(744, 478);
- splitHarmony1.width = rectSize;
- splitHarmony1.height = rectSize;
- splitHarmony1.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- splitHarmony1.texture.dynamicTexture.fillRect(rect, Phaser.ColorUtils.RGBtoWebstring(splitColor.color3));
-
- // Triadic
- triaHarmony = game.add.sprite(700, 522);
- triaHarmony.width = rectSize;
- triaHarmony.height = rectSize;
- triaHarmony.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- triaHarmony.texture.dynamicTexture.fillRect(rect, Phaser.ColorUtils.RGBtoWebstring(triaColor.color2));
-
- triaHarmony1 = game.add.sprite(744, 522);
- triaHarmony1.width = rectSize;
- triaHarmony1.height = rectSize;
- triaHarmony1.texture.loadDynamicTexture(game.add.dynamicTexture(rectSize, rectSize));
- triaHarmony1.texture.dynamicTexture.fillRect(rect, Phaser.ColorUtils.RGBtoWebstring(triaColor.color3));
-
- // Get the color under the position you tapped or clicked.
- var pos = {};
- game.input.onTap.add(function(pointer) {
- pos.x = pointer.position.x - offset.x;
- pos.y = pointer.position.y - offset.y;
-
- // Update colors.
- color = colorWheel.getPixel32(pos.x, pos.y);
- compHColor = Phaser.ColorUtils.getComplementHarmony(color),
- analoColor = Phaser.ColorUtils.getAnalogousHarmony(color).color2,
- analoColor1 = Phaser.ColorUtils.getAnalogousHarmony(color).color3,
- splitColor = Phaser.ColorUtils.getSplitComplementHarmony(color).color2,
- splitColor1 = Phaser.ColorUtils.getSplitComplementHarmony(color).color3,
- triaColor = Phaser.ColorUtils.getTriadicHarmony(color).color2;
- triaColor1 = Phaser.ColorUtils.getTriadicHarmony(color).color3;
-
- // Calc color strings.
- colorStr = Phaser.ColorUtils.RGBtoWebstring(color);
- var compStr: String = Phaser.ColorUtils.RGBtoWebstring(compHColor),
- analStr: String = Phaser.ColorUtils.RGBtoWebstring(analoColor),
- analStr1: String = Phaser.ColorUtils.RGBtoWebstring(analoColor1),
- spliStr: String = Phaser.ColorUtils.RGBtoWebstring(splitColor),
- spliStr1: String = Phaser.ColorUtils.RGBtoWebstring(splitColor1),
- triaStr: String = Phaser.ColorUtils.RGBtoWebstring(triaColor),
- triaStr1: String = Phaser.ColorUtils.RGBtoWebstring(triaColor1);
-
- // Update color of the rectangles.
- selected.texture.dynamicTexture.fillRect(rect, colorStr);
- compHarmony.texture.dynamicTexture.fillRect(rect, compStr);
- analoHarmony.texture.dynamicTexture.fillRect(rect, analStr);
- analoHarmony1.texture.dynamicTexture.fillRect(rect, analStr1);
- splitHarmony.texture.dynamicTexture.fillRect(rect, spliStr);
- splitHarmony1.texture.dynamicTexture.fillRect(rect, spliStr1);
- triaHarmony.texture.dynamicTexture.fillRect(rect, triaStr);
- triaHarmony1.texture.dynamicTexture.fillRect(rect, triaStr1);
- });
-
- // Set the background color to white.
- game.stage.backgroundColor = '#fff';
- }
- function render() {
- colorWheel.render(offset.x, offset.y);
-
- Phaser.DebugUtils.context.fillStyle = '#000';
- Phaser.DebugUtils.context.fillText('Tap or click the color wheel to select a color.', 480, 52);
- Phaser.DebugUtils.context.fillText('All the harmony colors are calculated on the fly.', 480, 590);
-
- // Display more color formated infos here. You can also get a
- // string contains everything using getColorInfo();
- Phaser.DebugUtils.context.fillText('Selected Color: ', 600, 312);
- Phaser.DebugUtils.context.fillText('Web String: ' + colorStr, 640, 342);
- Phaser.DebugUtils.context.fillText('Hex String: ' + Phaser.ColorUtils.RGBtoHexstring(color), 640, 358);
- var hsv = Phaser.ColorUtils.RGBtoHSV(color);
- Phaser.DebugUtils.context.fillText('HSV: (' + hsv.hue.toFixed() + ', ' + hsv.saturation.toFixed(2) + ', ' + hsv.value.toFixed(2) + ')', 640, 374);
-
- // Harmony color types info.
- Phaser.DebugUtils.context.fillText('Complement Harmony Color: ', 540, 412);
- Phaser.DebugUtils.context.fillText(' Analogous Harmony Color: ', 540, 456);
- Phaser.DebugUtils.context.fillText('Split Complement Harmony Color: ', 502, 500);
- Phaser.DebugUtils.context.fillText(' Triadic Harmony Color: ', 540, 544);
- }
-})();
diff --git a/wip/TS Tests/misc/dynamic texture 1.ts b/wip/TS Tests/misc/dynamic texture 1.ts
deleted file mode 100644
index d2e5e65c..00000000
--- a/wip/TS Tests/misc/dynamic texture 1.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-///
-
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, null, create, null, render);
-
- // Pattern texture for tiling render to the stage later.
- var pattern: Phaser.DynamicTexture;
-
- function create() {
- // Create a simple pattern texture.
- pattern = game.add.dynamicTexture(96, 96);
- pattern.fillRect(new Phaser.Rectangle(0, 0, 48, 48), '#5b35c0');
- pattern.fillRect(new Phaser.Rectangle(48, 48, 48, 48), '#5b35c0');
- pattern.fillRect(new Phaser.Rectangle(48, 0, 48, 48), '#43baf3');
- pattern.fillRect(new Phaser.Rectangle(0, 48, 48, 48), '#43baf3');
- }
- function render() {
- // Directly render the texture to the stage.
- // In screen coordinates.
- pattern.render(400 - 48, 300 - 48);
-
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('There\'s no sprites here, only a DynamicTexture created on the fly.', 210, 450);
- }
-})();
diff --git a/wip/TS Tests/misc/dynamic texture 2.ts b/wip/TS Tests/misc/dynamic texture 2.ts
deleted file mode 100644
index 79e78f9e..00000000
--- a/wip/TS Tests/misc/dynamic texture 2.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, null, create, null, render);
-
- // Pattern texture for tiling render to the stage later.
- var pattern: Phaser.DynamicTexture;
-
- function create() {
- // Create a simple pattern texture.
- pattern = game.add.dynamicTexture(96, 96);
- pattern.fillRect(new Phaser.Rectangle(0, 0, 48, 48), '#5b35c0');
- pattern.fillRect(new Phaser.Rectangle(48, 48, 48, 48), '#5b35c0');
- pattern.fillRect(new Phaser.Rectangle(48, 0, 48, 48), '#43baf3');
- pattern.fillRect(new Phaser.Rectangle(0, 48, 48, 48), '#43baf3');
-
- // Create a sprite and load to our newly created DynamicTexture.
- // Notice that loadDynamicTexture() will destroy sprite's AnimationManager,
- // so all the animations already added will no longer exist.
- var sprite: Phaser.Sprite = game.add.sprite(game.stage.centerX - 48, game.stage.centerY - 48);
- sprite.texture.loadDynamicTexture(pattern);
-
- console.log('Size of the sprite is now: (' + sprite.width + ', ' + sprite.height + ').');
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('This is a sprite whose appearance defined by a DynamicTexture created on the fly.', 160, 450);
- }
-})();
diff --git a/wip/TS Tests/misc/dynamic texture 3.ts b/wip/TS Tests/misc/dynamic texture 3.ts
deleted file mode 100644
index cb75104c..00000000
--- a/wip/TS Tests/misc/dynamic texture 3.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
-
- // Pattern texture for tiling render to the stage later.
- var pattern: Phaser.DynamicTexture;
-
- function preload() {
- game.load.spritesheet('cat', 'assets/sprites/baddie_cat_1.png', 16, 16);
-
- }
- function create() {
- // Create a simple pattern first.
- pattern = game.add.dynamicTexture(64, 16);
- for (var i = 0; i < 4; i++) {
- pattern.fillRect(new Phaser.Rectangle(i * 16, 0, 8, 8), '#5b35c0');
- pattern.fillRect(new Phaser.Rectangle((i + 1) * 16 - 8, 8, 8, 8), '#5b35c0');
- pattern.fillRect(new Phaser.Rectangle((i + 1) * 16 - 8, 0, 8, 8), '#43baf3');
- pattern.fillRect(new Phaser.Rectangle(i * 16, 8, 8, 8), '#43baf3');
- }
-
- // Paste cat image to the texture, so the cat is on top of our pattern.
- pattern.pasteImage('cat');
-
- // Create a sprite with our result texture.
- var sprite: Phaser.Sprite = game.add.sprite(game.stage.centerX - 32, game.stage.centerY - 8);
- sprite.texture.loadDynamicTexture(pattern);
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Paste exist spritesheet to a DynamicTexture created on the fly.', 220, 450);
- }
-})();
diff --git a/wip/TS Tests/misc/point1.ts b/wip/TS Tests/misc/point1.ts
deleted file mode 100644
index a4b05730..00000000
--- a/wip/TS Tests/misc/point1.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('box2', 'assets/tests/320x200.png');
- game.load.image('box1', 'assets/sprites/oz_pov_melting_disk.png');
- game.load.image('box', 'assets/sprites/bunny.png');
-
-
- }
-
- var sprite: Phaser.Sprite;
- var rotate: bool = false;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,0)';
-
- sprite = game.add.sprite(game.stage.centerX, game.stage.centerY, 'box');
-
- //sprite.transform.scale.setTo(0.5, 0.5);
- sprite.transform.origin.setTo(1, 1);
- //sprite.transform.origin.setTo(0.5, 0.5);
-
- game.input.onTap.add(rotateIt, this);
-
- //game.add.tween(sprite.transform.scale).to({ x: 0.5, y: 0.5 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
-
- }
-
- function rotateIt() {
- if (rotate == false) { rotate = true; } else { rotate = false; }
- }
-
- function update() {
-
- if (rotate)
- {
- sprite.rotation++;
- }
-
- }
-
- function render() {
-
- game.stage.context.save();
- game.stage.context.fillStyle = 'rgb(255,0,255)';
-
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
-
- game.stage.context.fillRect(sprite.transform.center.x, sprite.transform.center.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.upperLeft.x, sprite.transform.upperLeft.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.upperRight.x, sprite.transform.upperRight.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.bottomRight.x, sprite.transform.bottomRight.y, 2, 2);
-
- game.stage.context.strokeStyle = 'rgb(255,255,0)';
- game.stage.context.strokeRect(sprite.cameraView.x, sprite.cameraView.y, sprite.cameraView.width, sprite.cameraView.height);
-
- game.stage.context.restore();
-
- }
-
-})();
diff --git a/wip/TS Tests/misc/point2.ts b/wip/TS Tests/misc/point2.ts
deleted file mode 100644
index 8f0d99e3..00000000
--- a/wip/TS Tests/misc/point2.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
-
-
- }
-
- var sprite: Phaser.Sprite;
- var rotate: bool = false;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,0)';
-
- sprite = game.add.sprite(game.stage.centerX, game.stage.centerY, 'mummy');
-
- sprite.animations.add('walk');
- sprite.animations.play('walk', 20, true);
-
- sprite.transform.scale.setTo(4, 4);
-
- game.input.onTap.add(rotateIt, this);
-
- }
-
- function rotateIt() {
- if (rotate == false) { rotate = true; } else { rotate = false; }
- }
-
- function update() {
-
- if (rotate)
- {
- sprite.rotation++;
- }
-
- }
-
- function render() {
-
- game.stage.context.save();
- game.stage.context.fillStyle = 'rgb(255,0,255)';
-
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
-
- game.stage.context.fillRect(sprite.transform.center.x, sprite.transform.center.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.upperLeft.x, sprite.transform.upperLeft.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.upperRight.x, sprite.transform.upperRight.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.bottomRight.x, sprite.transform.bottomRight.y, 2, 2);
-
- game.stage.context.strokeStyle = 'rgb(255,255,0)';
- game.stage.context.strokeRect(sprite.cameraView.x, sprite.cameraView.y, sprite.cameraView.width, sprite.cameraView.height);
-
- game.stage.context.restore();
-
- }
-
-})();
diff --git a/wip/TS Tests/misc/point3.ts b/wip/TS Tests/misc/point3.ts
deleted file mode 100644
index 8554d50e..00000000
--- a/wip/TS Tests/misc/point3.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
-
-
- }
-
- var sprite: Phaser.Sprite;
- var rotate: bool = false;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,0)';
-
- sprite = game.add.sprite(game.stage.centerX, game.stage.centerY, 'bot');
-
- sprite.animations.add('run', null, 10, true);
-
- sprite.animations.play('run');
-
- //sprite.transform.scale.setTo(4, 4);
-
- game.input.onTap.add(rotateIt, this);
-
- }
-
- function rotateIt() {
- if (rotate == false) { rotate = true; } else { rotate = false; }
- }
-
- function update() {
-
- if (rotate)
- {
- sprite.rotation++;
- }
-
- }
-
- function render() {
-
- game.stage.context.save();
- game.stage.context.fillStyle = 'rgb(255,0,255)';
-
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
- game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
-
- game.stage.context.fillRect(sprite.transform.center.x, sprite.transform.center.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.upperLeft.x, sprite.transform.upperLeft.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.upperRight.x, sprite.transform.upperRight.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y, 2, 2);
- game.stage.context.fillRect(sprite.transform.bottomRight.x, sprite.transform.bottomRight.y, 2, 2);
-
- game.stage.context.strokeStyle = 'rgb(255,255,0)';
- game.stage.context.strokeRect(sprite.cameraView.x, sprite.cameraView.y, sprite.cameraView.width, sprite.cameraView.height);
-
- game.stage.context.restore();
-
- }
-
- var botData = '{"frames": [{"filename": "running bot.swf/0000","frame": { "x": 34, "y": 128, "w": 56, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0001","frame": { "x": 54, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0002","frame": { "x": 54, "y": 58, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0003","frame": { "x": 0, "y": 192, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0004","frame": { "x": 0, "y": 64, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0005","frame": { "x": 196, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0006","frame": { "x": 0, "y": 0, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0007","frame": { "x": 140, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0008","frame": { "x": 34, "y": 188, "w": 50, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0009","frame": { "x": 0, "y": 128, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0010","frame": { "x": 84, "y": 188, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }}]}';
-
-})();
diff --git a/wip/TS Tests/misc/rectangle utils 1.ts b/wip/TS Tests/misc/rectangle utils 1.ts
deleted file mode 100644
index 9c63681f..00000000
--- a/wip/TS Tests/misc/rectangle utils 1.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
-
- var rects: Phaser.Rectangle[] = [],
- rect: Phaser.Rectangle,
- lastCreated: Phaser.Rectangle;
-
- function create() {
- // Create a rect first.
- spawnRect(64, 32, 64, 64);
-
- // Add a rectangle on each touch or click.
- game.input.onTap.add(function() {
- spawnRect(lastCreated.x + 12, lastCreated.y + 12, 64, 64);
- });
- }
- function update() {
- // body...
- }
- function render() {
- var context: CanvasRenderingContext2D = Phaser.DebugUtils.context;
-
- // Render rectangles.
- context.strokeStyle = '#fff';
- // context.fillStyle = '#fff';
- context.lineWidth = 2;
- for (var i = 0, len = rects.length; i < len; i++) {
- rect = rects[i];
- context.strokeRect(rect.x, rect.y, rect.width, rect.height);
- }
-
- // Render info.
- context.fillStyle = '#fff';
- context.lineWidth = 0;
- context.fillText('Tap or click to clone a new rectangle.', 480, 128);
- }
- function spawnRect(x, y, w, h) {
- // If a rect already created, clone it to create a new one instead
- // of allocating.
- if (lastCreated) {
- rect = Phaser.RectangleUtils.clone(lastCreated);
- // Offset the newly created rectangle.
- rect.x += 24;
- rect.y += 24;
- // Now the last created is this one.
- lastCreated = rect;
- }
- else {
- lastCreated = new Phaser.Rectangle(x, y, w, h);
- }
- rects.push(lastCreated);
- }
-})();
diff --git a/wip/TS Tests/misc/rectangle utils 2.ts b/wip/TS Tests/misc/rectangle utils 2.ts
deleted file mode 100644
index f96d063a..00000000
--- a/wip/TS Tests/misc/rectangle utils 2.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
-
- var rect: Phaser.Rectangle,
- renderList: Phaser.Rectangle[] = [];
-
- var leftHandler: Phaser.Rectangle,
- rightHandler: Phaser.Rectangle,
- topHandler: Phaser.Rectangle,
- bottomHandler: Phaser.Rectangle;
-
- var onDragLeft: bool = false,
- onDragRight: bool = false,
- onDragTop: bool = false,
- onDragBottom: bool = false;
-
- var lastPos = {x: 0, y: 0};
-
- function create() {
- // Rectangle to be dragged and scaled.
- rect = new Phaser.Rectangle(game.stage.centerX - 160, game.stage.centerY - 120,
- 320, 240);
- // Handler rectangles for dragging scaling.
- leftHandler = new Phaser.Rectangle(game.stage.centerX - 160 - 4, game.stage.centerY - 4,
- 8, 8);
- rightHandler = new Phaser.Rectangle(game.stage.centerX + 160 - 4, game.stage.centerY - 4,
- 8, 8);
- topHandler = new Phaser.Rectangle(game.stage.centerX - 4, game.stage.centerY - 120 - 4,
- 8, 8);
- bottomHandler = new Phaser.Rectangle(game.stage.centerX - 4, game.stage.centerY + 120 - 4,
- 8, 8);
- // Add all the rectangles to the render list.
- renderList.push(rect,
- leftHandler, rightHandler, topHandler, bottomHandler);
-
- // Touch or press mouse button on any handler to start inflating rectangle.
- game.input.onDown.add(function(pointer) {
- if (Phaser.RectangleUtils.contains(leftHandler, pointer.position.x, pointer.position.y)) {
- onDragLeft = true;
- lastPos.x = pointer.position.x;
- lastPos.y = pointer.position.y;
- }
- else if (Phaser.RectangleUtils.contains(rightHandler, pointer.position.x, pointer.position.y)) {
- onDragRight = true;
- lastPos.x = pointer.position.x;
- lastPos.y = pointer.position.y;
- }
- else if (Phaser.RectangleUtils.contains(topHandler, pointer.position.x, pointer.position.y)) {
- onDragTop = true;
- lastPos.x = pointer.position.x;
- lastPos.y = pointer.position.y;
- }
- else if (Phaser.RectangleUtils.contains(bottomHandler, pointer.position.x, pointer.position.y)) {
- onDragBottom = true;
- lastPos.x = pointer.position.x;
- lastPos.y = pointer.position.y;
- }
- });
- // Stop dragging handlers when up.
- game.input.onUp.add(function() {
- onDragLeft = onDragRight = onDragTop = onDragBottom = false;
- });
- }
- function update() {
- var offset = {x: 0, y: 0};
- // Calc offset from last frame (previous update).
- if (onDragLeft) {
- offset.x = -game.input.x + lastPos.x;
- }
- else if (onDragRight) {
- offset.x = game.input.x - lastPos.x;
- }
- else if (onDragTop) {
- offset.y = -game.input.y + lastPos.y;
- }
- else if (onDragBottom) {
- offset.y = game.input.y - lastPos.y;
- }
- // Update last position.
- lastPos.x = game.input.x;
- lastPos.y = game.input.y;
-
- // Change rect's size and also the 4 handlers' position.
- Phaser.RectangleUtils.inflate(rect, offset.x, offset.y);
- leftHandler.x = rect.x - leftHandler.width / 2;
- rightHandler.x = rect.x + rect.width - rightHandler.width / 2;
- topHandler.y = rect.y - topHandler.height / 2;
- bottomHandler.y = rect.y + rect.height - bottomHandler.height / 2;
- }
- function render() {
- var context: CanvasRenderingContext2D = Phaser.DebugUtils.context;
-
- // Render rectangles.
- context.strokeStyle = '#fff';
- context.fillStyle = '#000';
- context.lineWidth = 4;
- for (var i = 0, len = renderList.length; i < len; i++) {
- context.strokeRect(renderList[i].x, renderList[i].y, renderList[i].width, renderList[i].height);
- context.fillRect(renderList[i].x, renderList[i].y, renderList[i].width, renderList[i].height);
- }
-
- // Render info.
- context.fillStyle = '#fff';
- context.lineWidth = 0;
-
- // Draw offset from origin point when drawing.
- var origin: Phaser.Vec2 = game.input.activePointer.positionDown,
- currPos: Phaser.Vec2 = game.input.activePointer.position;
- if (onDragLeft) {
- context.fillText('dx: ' + (currPos.x - origin.x), leftHandler.x + 16, leftHandler.y - 20);
- context.fillText('dy: 0', leftHandler.x + 16, leftHandler.y - 8);
- }
- else if (onDragRight) {
- context.fillText('dx: ' + (currPos.x - origin.x), rightHandler.x + 16, rightHandler.y - 20);
- context.fillText('dx: 0', rightHandler.x + 16, rightHandler.y - 8);
- }
- else if (onDragTop) {
- context.fillText('dy: 0', topHandler.x + 16, topHandler.y - 20);
- context.fillText('dy: ' + (currPos.y - origin.y), topHandler.x + 16, topHandler.y - 8);
- }
- else if (onDragBottom) {
- context.fillText('dy: 0', bottomHandler.x + 16, bottomHandler.y - 20);
- context.fillText('dy: ' + (currPos.y - origin.y), bottomHandler.x + 16, bottomHandler.y - 8);
- }
-
- context.fillText('Drag handlers to scale the rectangle!', 280, 96);
- context.fillText('Notice that the scaling does not move the rectangle\'s center!', 220, 508);
- context.fillText('You can also get same effect by using "Sprite" and its origin property.', 196, 520);
- }
-})();
diff --git a/wip/TS Tests/mobile/fullscreen.html b/wip/TS Tests/mobile/fullscreen.html
deleted file mode 100644
index 0c669898..00000000
--- a/wip/TS Tests/mobile/fullscreen.html
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
- Phaser Mobile Fullscreen Test
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wip/TS Tests/mobile/sprite test 1.js b/wip/TS Tests/mobile/sprite test 1.js
deleted file mode 100644
index 7686e492..00000000
--- a/wip/TS Tests/mobile/sprite test 1.js
+++ /dev/null
@@ -1,59 +0,0 @@
-///
-(function () {
- var game = new Phaser.Game(this, 'game', 320, 400, preload, create);
-
- var emitter;
-
- function preload() {
- game.load.image('backdrop1', 'assets/pics/atari_fujilogo.png');
- game.load.image('backdrop2', 'assets/pics/acryl_bladerunner.png');
- game.load.image('jet', 'assets/sprites/carrot.png');
-
- // This can help a lot on crappy old Android phones :)
- //game.framerate = 30;
- game.stage.backgroundColor = 'rgb(0,0,0)';
-
- //game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
- game.stage.scaleMode = Phaser.StageScaleMode.EXACT_FIT;
- //game.stage.scaleMode = Phaser.StageScaleMode.NO_SCALE;
- }
-
- var pic1;
- var pic2;
-
- function create() {
- console.log('created now');
-
- game.stage.enableOrientationCheck(false, true, 'backdrop2');
-
- pic1 = game.add.sprite(0, 0, 'backdrop1');
- pic2 = game.add.sprite(0, 0, 'backdrop2');
-
- // Creates a basic emitter, bursting out 50 default sprites (i.e. 16x16 white boxes)
- emitter = game.add.emitter(game.stage.centerX, game.stage.centerY);
- emitter.makeParticles('jet', 50, false, 0);
- emitter.setRotation(0, 0);
- emitter.start(false, 10, 0.1);
-
- game.stage.scale.enterLandscape.add(goneLandscape, this);
- game.stage.scale.enterPortrait.add(gonePortrait, this);
-
- game.onRenderCallback = render;
- }
-
- function goneLandscape() {
- pic1.visible = true;
- pic2.visible = false;
- }
-
- function gonePortrait() {
- pic1.visible = false;
- pic2.visible = true;
- }
-
- function render() {
- game.stage.context.fillStyle = 'rgb(255,0,0)';
- game.stage.context.font = '20px Arial';
- //game.stage.context.fillText("ttc: " + game._raf.timeToCall.toString(), 0, 64);
- }
-})();
diff --git a/wip/TS Tests/mobile/sprite test 1.ts b/wip/TS Tests/mobile/sprite test 1.ts
deleted file mode 100644
index 1c22905d..00000000
--- a/wip/TS Tests/mobile/sprite test 1.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 320, 400, preload, create);
-
- var emitter: Phaser.ArcadeEmitter;
-
- function preload() {
-
- game.load.image('backdrop1', 'assets/pics/atari_fujilogo.png');
- game.load.image('backdrop2', 'assets/pics/acryl_bladerunner.png');
- game.load.image('jet', 'assets/sprites/carrot.png');
-
-
-
- // This can help a lot on crappy old Android phones :)
- //game.framerate = 30;
-
- game.stage.backgroundColor = 'rgb(0,0,0)';
- //game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
- game.stage.scaleMode = Phaser.StageScaleMode.EXACT_FIT;
- //game.stage.scaleMode = Phaser.StageScaleMode.NO_SCALE;
-
- }
-
- var pic1;
- var pic2;
-
- function create() {
-
- console.log('created now');
-
- game.stage.enableOrientationCheck(false, true, 'backdrop2');
-
- pic1 = game.add.sprite(0, 0, 'backdrop1');
- pic2 = game.add.sprite(0, 0, 'backdrop2');
-
- // Creates a basic emitter, bursting out 50 default sprites (i.e. 16x16 white boxes)
- emitter = game.add.emitter(game.stage.centerX, game.stage.centerY);
- emitter.makeParticles('jet', 50, false, 0);
- emitter.setRotation(0, 0);
- emitter.start(false, 10, 0.1);
-
- game.stage.scale.enterLandscape.add(goneLandscape, this);
- game.stage.scale.enterPortrait.add(gonePortrait, this);
-
- game.onRenderCallback = render;
-
- }
-
- function goneLandscape() {
-
- pic1.visible = true;
- pic2.visible = false;
-
- }
-
- function gonePortrait() {
-
- pic1.visible = false;
- pic2.visible = true;
-
- }
-
- function render() {
-
- game.stage.context.fillStyle = 'rgb(255,0,0)';
- game.stage.context.font = '20px Arial';
- //game.stage.context.fillText("ttc: " + game._raf.timeToCall.toString(), 0, 64);
-
- }
-
-})();
diff --git a/wip/TS Tests/mobile/test1.html b/wip/TS Tests/mobile/test1.html
deleted file mode 100644
index 7491bbf3..00000000
--- a/wip/TS Tests/mobile/test1.html
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
- Phaser Mobile Fullscreen Test
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wip/TS Tests/particles/graphic emitter.ts b/wip/TS Tests/particles/graphic emitter.ts
deleted file mode 100644
index 2472ca64..00000000
--- a/wip/TS Tests/particles/graphic emitter.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- var emitter: Phaser.ArcadeEmitter;
-
- function preload() {
-
- game.load.image('jet', 'assets/sprites/jets.png');
-
-
-
- }
-
- function create() {
-
- emitter = game.add.emitter(game.stage.centerX, game.stage.centerY);
- emitter.makeParticles('jet', 100, false, 0);
- emitter.start(false, 20, 0.1);
-
- }
-
-})();
diff --git a/wip/TS Tests/particles/mousetrail.ts b/wip/TS Tests/particles/mousetrail.ts
deleted file mode 100644
index 17da8c99..00000000
--- a/wip/TS Tests/particles/mousetrail.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- var emitter: Phaser.ArcadeEmitter;
-
- function preload() {
-
- game.load.image('jet', 'assets/sprites/particle1.png');
- game.load.image('starfield', 'assets/misc/starfield.jpg');
-
-
- }
-
- var scroller: Phaser.ScrollZone;
- var emitter: Phaser.ArcadeEmitter;
-
- function create() {
-
- scroller = game.add.scrollZone('starfield', 0, 0, 1024, 1024);
- scroller.setSpeed(0, -1);
-
- emitter = game.add.emitter(game.stage.centerX, game.stage.centerY);
- emitter.makeParticles('jet', 200);
-
- emitter.texture.globalCompositeOperation = 'lighter';
-
- emitter.gravity = 300;
- emitter.setXSpeed(-50, 50);
- emitter.setYSpeed(-50, -100);
- emitter.setRotation(0, 0);
- emitter.start(false, 50, 0.02);
-
- }
-
- function update() {
-
- emitter.x = game.input.x;
- emitter.y = game.input.y;
- //emitter.em
-
- }
-
-})();
diff --git a/wip/TS Tests/particles/multiple streams.ts b/wip/TS Tests/particles/multiple streams.ts
deleted file mode 100644
index 01ff39ff..00000000
--- a/wip/TS Tests/particles/multiple streams.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- var emitter1: Phaser.ArcadeEmitter;
- var emitter2: Phaser.ArcadeEmitter;
- var emitter3: Phaser.ArcadeEmitter;
- var emitter4: Phaser.ArcadeEmitter;
- var emitter5: Phaser.ArcadeEmitter;
- var emitter6: Phaser.ArcadeEmitter;
-
- function preload() {
-
- game.load.image('ball1', 'assets/sprites/aqua_ball.png');
- game.load.image('ball2', 'assets/sprites/yellow_ball.png');
- game.load.image('ball3', 'assets/sprites/red_ball.png');
- game.load.image('ball4', 'assets/sprites/purple_ball.png');
- game.load.image('ball5', 'assets/sprites/blue_ball.png');
- game.load.image('ball6', 'assets/sprites/green_ball.png');
-
-
-
- }
-
- function makeEmitter(emitter, x, y, graphic) {
-
- emitter = game.add.emitter(x, y);
- emitter.gravity = 100;
- emitter.bounce = 0.5;
-
- if (x == 0)
- {
- emitter.setXSpeed(200, 250);
- }
- else
- {
- emitter.setXSpeed(-200, -250);
- }
-
- emitter.setYSpeed(-50, -10);
- emitter.makeParticles(graphic, 250, false, 0);
-
- return emitter;
-
- }
-
- function create() {
-
- emitter1 = makeEmitter(emitter1, 0, 50, 'ball1');
- emitter2 = makeEmitter(emitter2, 0, 250, 'ball2');
- emitter3 = makeEmitter(emitter3, 0, 450, 'ball3');
- emitter4 = makeEmitter(emitter4, game.stage.width, 50, 'ball4');
- emitter5 = makeEmitter(emitter5, game.stage.width, 250, 'ball5');
- emitter6 = makeEmitter(emitter6, game.stage.width, 450, 'ball6');
-
- emitter1.start(false, 50, 0.05);
- emitter2.start(false, 50, 0.05);
- emitter3.start(false, 50, 0.05);
- emitter4.start(false, 50, 0.05);
- emitter5.start(false, 50, 0.05);
- emitter6.start(false, 50, 0.05);
-
- }
-
- function update() {
-
- //game.collide(leftEmitter, rightEmitter);
-
- }
-
-})();
diff --git a/wip/TS Tests/particles/sprite emitter.ts b/wip/TS Tests/particles/sprite emitter.ts
deleted file mode 100644
index 89719dfb..00000000
--- a/wip/TS Tests/particles/sprite emitter.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-///
-///
-///
-
-// Actually we could achieve the same result as this by using a sprite sheet and basic Particle
-// but it still shows you how to use it properly from TypeScript, so it was worth making
-class customParticle extends Phaser.ArcadeParticle {
-
- constructor(game:Phaser.Game) {
-
- super(game);
-
- var s = ['carrot', 'melon', 'eggplant', 'mushroom', 'pineapple'];
-
- this.texture.loadImage(game.math.getRandom(s));
- }
-
-}
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- var emitter: Phaser.ArcadeEmitter;
-
- function preload() {
-
- game.load.image('carrot', 'assets/sprites/carrot.png');
- game.load.image('melon', 'assets/sprites/melon.png');
- game.load.image('eggplant', 'assets/sprites/eggplant.png');
- game.load.image('mushroom', 'assets/sprites/mushroom.png');
- game.load.image('pineapple', 'assets/sprites/pineapple.png');
-
-
-
- }
-
- function create() {
-
- emitter = game.add.emitter(game.stage.centerX, 50);
- emitter.gravity = 100;
-
- // Here we tell the emitter to use our customParticle class
- // The customParticle needs to extend Particle and must take game:Game as the first constructor parameter, otherwise it's free as a bird
- emitter.particleClass = customParticle;
-
- emitter.makeParticles(null, 500, false, 0);
- emitter.start(false, 10, 0.05);
-
- }
-
-})();
diff --git a/wip/TS Tests/particles/when particles collide.ts b/wip/TS Tests/particles/when particles collide.ts
deleted file mode 100644
index ec41e9d1..00000000
--- a/wip/TS Tests/particles/when particles collide.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- var leftEmitter: Phaser.ArcadeEmitter;
- var rightEmitter: Phaser.ArcadeEmitter;
-
- function preload() {
-
- game.load.image('ball1', 'assets/sprites/aqua_ball.png');
- game.load.image('ball2', 'assets/sprites/yellow_ball.png');
-
-
-
- }
-
- function create() {
-
- leftEmitter = game.add.emitter(0, game.stage.centerY - 200);
- leftEmitter.gravity = 100;
- leftEmitter.bounce = 0.5;
- leftEmitter.setXSpeed(100, 200);
- leftEmitter.setYSpeed(-50, 50);
- leftEmitter.makeParticles('ball1', 250, false, 1);
-
- rightEmitter = game.add.emitter(game.stage.width + 20, game.stage.centerY - 200);
- rightEmitter.gravity = 100;
- rightEmitter.bounce = 0.5;
- rightEmitter.setXSpeed(-100, -200);
- rightEmitter.setYSpeed(-50, 50);
- rightEmitter.makeParticles('ball2', 250, false, 1);
-
- leftEmitter.start(false, 50, 0.05);
- rightEmitter.start(false, 50, 0.05);
-
- }
-
- function update() {
-
- //game.collide(leftEmitter, rightEmitter);
-
- }
-
-})();
diff --git a/wip/TS Tests/physics/circle 1.ts b/wip/TS Tests/physics/circle 1.ts
deleted file mode 100644
index 90447164..00000000
--- a/wip/TS Tests/physics/circle 1.ts
+++ /dev/null
@@ -1,222 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('ball', 'assets/sprites/shinyball.png');
- game.load.image('carrot', 'assets/sprites/carrot.png');
-
- }
-
- var cells;
- var b: Phaser.Physics.AABB;
- var c: Phaser.Physics.Circle;
- var t: Phaser.Physics.TileMapCell;
- var ball: Phaser.Sprite;
- var carrot: Phaser.Sprite;
-
- function create() {
-
- //this.ball = game.add.sprite(0, 0, 'ball');
-
- carrot = game.add.sprite(300, 50, 'carrot');
-
- // N+ motion version
- carrot.body.aabb.drag.setTo(1, 1);
- carrot.body.aabb.bounce.setTo(0.3, 0.3);
- carrot.body.aabb.gravity.setTo(0, 0.3);
-
-
-
-
- //carrot.body.aabb.bounce.setTo(0.5, 0.5);
- //carrot.body.aabb.drag.x = 50;
- //carrot.body.aabb.drag.y = 50;
- //carrot.body.aabb.velocity.y = 250;
-
- //this.b = game.add.aabb(game.stage.randomX, 200, 22, 21);
- //this.c = game.add.circle(200, 200, 16);
-
- // pos is center, not upper-left
- this.cells = [];
-
- var tid;
-
- for (var i = 0; i < 10; i++)
- {
- if (i % 2 == 0)
- {
- tid = Phaser.Physics.TileMapCell.TID_CONCAVEpn;
- //tid = Phaser.Physics.TileMapCell.TID_45DEGpn;
- }
- else
- {
- //tid = Phaser.Physics.TileMapCell.TID_CONCAVEnn;
- tid = Phaser.Physics.TileMapCell.TID_45DEGnn;
- }
-
- //tid = Phaser.Physics.TileMapCell.TID_FULL;
-
- this.cells.push(game.add.cell(100 + (i * 100), 400, 50, 50, tid));
- }
-
- }
-
- function update() {
-
- /*
- carrot.body.aabb.acceleration.x = 0;
- carrot.body.aabb.acceleration.y = 0;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- carrot.body.aabb.acceleration.x = -200;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- carrot.body.aabb.acceleration.x = 200;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- carrot.body.aabb.acceleration.y = -200;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- carrot.body.aabb.acceleration.y = 200;
- }
-
- carrot.body.aabb.FFupdate();
-
- */
-
- // This works but it's a static motion (no easing / acceleration)
- //carrot.body.aabb.velocity.x = 0;
- //carrot.body.aabb.velocity.y = 0;
-
- /*
- var s = 200;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- carrot.body.aabb.velocity.x = -s;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- carrot.body.aabb.velocity.x = s;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- carrot.body.aabb.velocity.y = -s;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- carrot.body.aabb.velocity.y = s;
- }
-
- carrot.body.aabb.FFupdate();
-
- */
-
- /*
-
- // N+ motion - This works but no acceleration and the gravity values are insanely sensitive
-
- carrot.body.aabb._vx = 0;
- carrot.body.aabb._vy = 0;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- carrot.body.aabb._vx = -0.2;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- carrot.body.aabb._vx = 0.2;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- carrot.body.aabb._vy = -(0.2 + carrot.body.aabb.gravity.y);
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- carrot.body.aabb._vy = 0.2;
- }
-
- carrot.body.aabb.update();
-
- */
-
- // N+ with Flixel Compute
- carrot.body.aabb.velocity.x = 0;
- carrot.body.aabb.velocity.y = 0;
-
- var s = 50;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- carrot.body.aabb.velocity.x = -s;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- carrot.body.aabb.velocity.x = s;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- carrot.body.aabb.velocity.y = -s;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- carrot.body.aabb.velocity.y = s;
- }
-
- carrot.body.aabb.update();
-
-
-
- carrot.body.aabb.collideAABBVsWorldBounds();
-
- for (var i = 0; i < this.cells.length; i++)
- {
- //this.c.collideCircleVsTile(this.cells[i]);
- //this.b.collideAABBVsTile(this.cells[i]);
- carrot.body.aabb.collideAABBVsTile(this.cells[i]);
- }
-
- //this.c.collideCircleVsWorldBounds();
- //this.b.collideAABBVsWorldBounds();
- //carrot.body.aabb.collideAABBVsWorldBounds();
-
- //this.ball.transform.centerOn(this.c.pos.x, this.c.pos.y);
- //this.carrot.transform.centerOn(this.b.pos.x, this.b.pos.y);
-
- }
-
- function render() {
-
- //this.c.render(game.stage.context);
- //this.b.render(game.stage.context);
- carrot.body.aabb.render(game.stage.context);
-
- for (var i = 0; i < this.cells.length; i++)
- {
- this.cells[i].render(game.stage.context);
- }
-
- Phaser.DebugUtils.renderText('dx: ' + carrot.body.aabb._deltaX, 32, 32);
- Phaser.DebugUtils.renderText('dy: ' + carrot.body.aabb._deltaY, 32, 64);
- Phaser.DebugUtils.renderText('vx: ' + carrot.body.aabb.velocity.x, 432, 32);
- Phaser.DebugUtils.renderText('vy: ' + carrot.body.aabb.velocity.y, 432, 64);
- Phaser.DebugUtils.renderText('delta: ' + game.time.delta, 32, 90);
- Phaser.DebugUtils.renderText('phye: ' + game.time.physicsElapsed, 32, 110);
- Phaser.DebugUtils.renderText('vxd: ' + carrot.body.aabb._vx, 32, 130);
- Phaser.DebugUtils.renderText('vyd: ' + carrot.body.aabb._vy, 32, 150);
-
- }
-
-})();
diff --git a/wip/TS Tests/physics/sprite bounds.ts b/wip/TS Tests/physics/sprite bounds.ts
deleted file mode 100644
index f28ecb1f..00000000
--- a/wip/TS Tests/physics/sprite bounds.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
- game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
- }
-
- var fuji: Phaser.Sprite;
- var tween: Phaser.Tween;
- var b: Phaser.Rectangle;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,100)';
-
- fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
- fuji.origin.setTo(0, 0.5);
- fuji.rotation = 34;
-
- b = new Phaser.Rectangle(fuji.transform.center.x, fuji.transform.center.y, fuji.width, fuji.height);
-
- //game.add.tween(fuji).to({ rotation: 360 }, 20000, Phaser.Easing.Linear.None, true, 0, true);
-
- }
-
- function update() {
-
- if (game.input.activePointer.justPressed())
- {
- //fuji.transform.centerOn(game.input.x, game.input.y);
- fuji.x = game.input.x;
- fuji.y = game.input.y;
- }
-
- b.x = fuji.transform.center.x - fuji.transform.halfWidth;
- b.y = fuji.transform.center.y - fuji.transform.halfHeight;
-
- }
-
- function render() {
-
- //Phaser.DebugUtils.renderSpriteWorldViewBounds(fuji);
- //Phaser.DebugUtils.renderSpriteBounds(fuji);
- Phaser.DebugUtils.renderSpriteCorners(fuji);
- //Phaser.DebugUtils.renderSpriteWorldView(fuji, 32, 32);
- Phaser.DebugUtils.renderRectangle(b, 'rgba(237,20,91,0.3)');
-
- }
-
-})();
diff --git a/wip/TS Tests/scrollzones/ballscroller.ts b/wip/TS Tests/scrollzones/ballscroller.ts
deleted file mode 100644
index f6df3cec..00000000
--- a/wip/TS Tests/scrollzones/ballscroller.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('balls', 'assets/sprites/balls.png');
-
-
-
- }
-
- var scroller: Phaser.ScrollZone;
-
- function create() {
-
- // The source image (balls.png) is only 102x17 in size, but we want it to create a scroll the size of the whole game window.
- // We can take advantage of the way a ScrollZone can create a seamless pattern for us automatically.
- // If you create a ScrollRegion larger than the source texture, it'll create a DynamicTexture and perform a pattern fill on it and use that
- // for rendering.
-
- // We've rounded the height up to 612 because in order to have a seamless pattern it needs to be a multiple of 17 (the height of the source image)
- scroller = game.add.scrollZone('balls', 0, 0, 800, 612);
-
- // Some sin/cos data for the movement
- game.math.sinCosGenerator(256, 4, 4, 2);
-
- }
-
- function update() {
-
- // Cycle through the wave data and apply it to the scroll speed (causes the circular wave motion)
- scroller.currentRegion.scrollSpeed.x = game.math.shiftSinTable();
- scroller.currentRegion.scrollSpeed.y = game.math.shiftCosTable();
-
- }
-
-})();
diff --git a/wip/TS Tests/scrollzones/blasteroids.ts b/wip/TS Tests/scrollzones/blasteroids.ts
deleted file mode 100644
index 0da877f1..00000000
--- a/wip/TS Tests/scrollzones/blasteroids.ts
+++ /dev/null
@@ -1,156 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- game.load.image('nashwan', 'assets/sprites/xenon2_ship.png');
- game.load.image('starfield', 'assets/misc/starfield.jpg');
- game.load.image('jet', 'assets/sprites/particle1.png');
- game.load.image('bullet', 'assets/misc/bullet1.png');
-
- }
-
- var scroller: Phaser.ScrollZone;
- var emitter: Phaser.ArcadeEmitter;
- var ship: Phaser.Sprite;
- var bullets: Phaser.Group;
-
- var speed: number = 0;
- var fireRate: number = 0;
- var shipMotion: Phaser.Point;
-
- function create() {
-
- scroller = game.add.scrollZone('starfield', 0, 0, 1024, 1024);
-
- emitter = game.add.emitter(game.stage.centerX + 16, game.stage.centerY + 12);
- emitter.makeParticles('jet', 250, false, 0);
- emitter.setRotation(0, 0);
-
- // Looks like a smoke trail!
- //emitter.globalCompositeOperation = 'xor';
-
- // Looks way cool :)
- emitter.texture.globalCompositeOperation = 'lighter';
-
- bullets = game.add.group(50);
-
- // Create our bullet pool
- for (var i = 0; i < 50; i++)
- {
- var tempBullet = new Phaser.Sprite(game, game.stage.centerX, game.stage.centerY, 'bullet');
- tempBullet.exists = false;
- tempBullet.transform.rotationOffset = 90;
- //tempBullet.setBounds(-100, -100, 900, 700);
- //tempBullet.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
- bullets.add(tempBullet);
- }
-
- ship = game.add.sprite(game.stage.centerX, game.stage.centerY, 'nashwan', Phaser.Types.BODY_DYNAMIC);
- ship.transform.origin.setTo(0.5, 0.5);
-
- // We do this because the ship was drawn facing up, but 0 degrees is pointing to the right
- ship.transform.rotationOffset = 90;
-
- game.input.onDown.add(test, this);
-
- }
-
- function test(event) {
-
- game.stage.scale.startFullScreen();
-
- }
-
- function update() {
-
- ship.body.angularVelocity = 0;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- ship.body.angularVelocity = -200;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- ship.body.angularVelocity = 200;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- speed += 0.1;
-
- if (speed > 10)
- {
- speed = 10;
- }
- }
- else
- {
- speed -= 0.1;
-
- if (speed < 0) {
- speed = 0;
- }
- }
-
- //shipMotion = game.motion.velocityFromAngle(ship.rotation, speed);
-
- scroller.setSpeed(shipMotion.x, shipMotion.y);
-
- // emit particles
- if (speed > 2)
- {
- // We use the opposite of the motion because the jets emit out the back of the ship
- // The 20 and 30 values just keep them nice and fast
- emitter.setXSpeed(-(shipMotion.x * 20), -(shipMotion.x * 30));
- emitter.setYSpeed(-(shipMotion.y * 20), -(shipMotion.y * 30));
- emitter.emitParticle();
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
- {
- fire();
- }
-
- }
-
- function render() {
-
- //ship.body.renderDebugInfo(32, 32);
-
- }
-
- function recycleBullet(bullet:Phaser.Sprite) {
-
- if (bullet.exists && bullet.x < -40 || bullet.x > 840 || bullet.y < -40 || bullet.y > 640)
- {
- bullet.exists = false;
- }
-
- }
-
- function fire() {
-
- if (game.time.now > fireRate)
- {
- var b:Phaser.Sprite = bullets.getFirstAvailable();
-
- b.x = ship.x;
- b.y = ship.y - 26;
-
- //var bulletMotion = game.motion.velocityFromAngle(ship.rotation, 400);
- var bulletMotion = {x:0,y:0};
-
- b.revive();
- b.rotation = ship.rotation;
- b.body.velocity.setTo(bulletMotion.x, bulletMotion.y);
-
- fireRate = game.time.now + 100;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/scrollzones/parallax.ts b/wip/TS Tests/scrollzones/parallax.ts
deleted file mode 100644
index 0d9d5806..00000000
--- a/wip/TS Tests/scrollzones/parallax.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('starray', 'assets/pics/auto_scroll_landscape.png');
-
-
-
- }
-
- function create() {
-
- var zone: Phaser.ScrollZone = game.add.scrollZone('starray');
-
- // Hide the default region (the full image)
- zone.currentRegion.visible = false;
-
- var y:number = 0;
- var speed:number = 16;
-
- // The image consists of 10px high scrolling layers, this creates them quickly (top = fastest, getting slower as we move down)
- for (var z:number = 0; z < 32; z++)
- {
- zone.addRegion(0, y, 640, 10, speed);
-
- if (z <= 15)
- {
- speed -= 1;
- }
- else
- {
- speed += 1;
- }
-
- if (z == 15)
- {
- y = 240;
- speed += 1;
- }
- else
- {
- y += 10;
- }
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/scrollzones/region demo.ts b/wip/TS Tests/scrollzones/region demo.ts
deleted file mode 100644
index d32b9922..00000000
--- a/wip/TS Tests/scrollzones/region demo.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('angelDawn', 'assets/pics/game14_angel_dawn.png');
-
-
-
- }
-
- var scroller: Phaser.ScrollZone;
-
- function create() {
-
- // This creates our ScrollZone centered in the middle of the stage.
- scroller = game.add.scrollZone('angelDawn', game.stage.centerX - 320, 100);
-
- // By default we won't scroll the full image, but we will create 3 ScrollRegions within it:
-
- // This creates a ScrollRegion which can be thought of as a rectangle within the ScrollZone that can be scrolled
- // independantly - this one scrolls the image of the spacemans head
- scroller.addRegion(32, 32, 352, 240, 0, 2);
-
- // The head in the top right
- scroller.addRegion(480, 30, 96, 96, 4, 0);
-
- // The small piece of text
- scroller.addRegion(466, 160, 122, 14, 0, -0.5);
-
- }
-
-})();
diff --git a/wip/TS Tests/scrollzones/scroll window.ts b/wip/TS Tests/scrollzones/scroll window.ts
deleted file mode 100644
index eb57e7b4..00000000
--- a/wip/TS Tests/scrollzones/scroll window.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('dragonsun', 'assets/pics/cougar_dragonsun.png');
- game.load.image('overlay', 'assets/pics/scrollframe.png');
-
-
-
- }
-
- var scroller: Phaser.ScrollZone;
-
- function create() {
-
- // This creates our ScrollZone. It is positioned at x32 y32 (world coodinates)
- // and is a size of 352x240 (which matches the window in our overlay image)
- scroller = game.add.scrollZone('dragonsun', 32, 32, 352, 240);
-
- scroller.setSpeed(2, 2);
-
- game.add.sprite(0, 0, 'overlay');
-
- }
-
-})();
diff --git a/wip/TS Tests/scrollzones/simple scrollzone.ts b/wip/TS Tests/scrollzones/simple scrollzone.ts
deleted file mode 100644
index 1573ecad..00000000
--- a/wip/TS Tests/scrollzones/simple scrollzone.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('crystal', 'assets/pics/jim_sachs_time_crystal.png');
-
-
- }
-
- function create() {
-
- // This creates our ScrollZone. It is positioned at x0 y0 (world coodinates) by default and uses
- // the 'crystal' image from the cache.
-
- // The default is for the scroll zone to create 1 new scrolling region the size of the whole image you gave it.
- // For this example we'll keep that, but look at the other tests to see reasons why you may not want to.
-
- game.add.scrollZone('crystal').setSpeed(4, 2);
-
- }
-
-})();
diff --git a/wip/TS Tests/scrollzones/skewed scroller.ts b/wip/TS Tests/scrollzones/skewed scroller.ts
deleted file mode 100644
index ede7f1de..00000000
--- a/wip/TS Tests/scrollzones/skewed scroller.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-///
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- game.load.image('balls', 'assets/sprites/balls.png');
-
-
- }
-
- var leftFace: Phaser.ScrollZone;
- var rightFace: Phaser.ScrollZone;
- var topFace: Phaser.ScrollZone;
-
- function create() {
-
- topFace = game.add.scrollZone('balls', 200, 0, 204, 204).setSpeed(0, 2.2);
- topFace.transform.skew.setTo(0, Math.tan(game.math.radiansToDegrees(-30)));
- topFace.transform.scale.setTo(1, 1.3);
-
- leftFace = game.add.scrollZone('balls', 110, 264, 204, 204).setSpeed(0, 2.1);
- leftFace.transform.skew.setTo(0, Math.tan(game.math.radiansToDegrees(30)));
-
- rightFace = game.add.scrollZone('balls', 200, 466, 204, 204).setSpeed(0, 2);
- rightFace.transform.skew.setTo(0, Math.tan(game.math.radiansToDegrees(-30)));
- rightFace.transform.scale.setTo(1, 0.8);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/alpha.ts b/wip/TS Tests/sprites/alpha.ts
deleted file mode 100644
index 76db8806..00000000
--- a/wip/TS Tests/sprites/alpha.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('bunny', 'assets/sprites/bunny.png');
-
-
- }
-
- function create() {
-
- // Here we'll assign the new sprite to the local bunny variable
- var bunny = game.add.sprite(0, 0, 'bunny');
-
- // And this sets the alpha of the sprite to 0.5, which is 50% opaque
- bunny.alpha = 0.5;
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/animate by framename.ts b/wip/TS Tests/sprites/animate by framename.ts
deleted file mode 100644
index ce738ced..00000000
--- a/wip/TS Tests/sprites/animate by framename.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
-
-
-
- }
-
- var bot: Phaser.Sprite;
-
- function create() {
-
- bot = game.add.sprite(game.stage.width, 300, 'bot');
-
- // If you are using a Texture Atlas and want to specify the frames of an animation by their name rather than frame index
- // then you can use this format:
- bot.animations.add('run', ['run00', 'run01', 'run02', 'run03', 'run04', 'run05', 'run06', 'run07', 'run08', 'run09', 'run10'], 10, true, false);
-
- bot.animations.play('run');
-
- //bot.velocity.x = -100;
-
- }
-
- function update() {
-
- bot.x -= 1;
-
- if (bot.x < -bot.width)
- {
- bot.x = game.stage.width;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/animation 1.ts b/wip/TS Tests/sprites/animation 1.ts
deleted file mode 100644
index 0550f861..00000000
--- a/wip/TS Tests/sprites/animation 1.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
-
- // The sprite sheet is a standard frame-by-frame sheet, and each frame is 37 x 45 pixels in size.
- // The final parameter (18) is the number of frames there are. You can omit this if your frames fill the entire sheet.
- game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
-
-
- }
-
- var mummy: Phaser.Sprite;
-
- function create() {
-
- mummy = game.add.sprite(game.stage.centerX, game.stage.centerY, 'mummy');
-
- // Here we add new animation called 'walk'.
- // As it's the only animation in our sprite sheet we don't need to define the frames being used.
- mummy.animations.add('walk');
-
- // This plays the animation at 20 frames per second on a loop (the 3rd parameter)
- // Try changing the 20 value to something low to slow the speed down, or higher to make it play faster.
- mummy.animations.play('walk', 20, true);
-
- // This just scales the sprite up so you can see the animation better
- mummy.transform.scale.setTo(4, 4);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/animation 2.ts b/wip/TS Tests/sprites/animation 2.ts
deleted file mode 100644
index a0ee3b1a..00000000
--- a/wip/TS Tests/sprites/animation 2.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.spritesheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
-
-
- }
-
- var monster: Phaser.Sprite;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(50,10,10)';
-
- // Notice the use of 'stage.centerX' - this places the sprite in the middle of the stage without needing to do any extra math
- monster = game.add.sprite(game.stage.centerX, game.stage.centerY, 'monster');
-
- // For this animation we pass 'null' for the frames, because we're going to use them all
- // And we set the frame rate (30) and loop status (true) when we add the animation
- // If the frame rate and looping is never going to change then it's easier to do it here
- monster.animations.add('walk', null, 30, true);
-
- // Then you can just call 'play' on its own with no other values to start things going
- monster.animations.play('walk');
-
- monster.transform.scale.setTo(2, 2);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/create sprite 1.ts b/wip/TS Tests/sprites/create sprite 1.ts
deleted file mode 100644
index bc9a2fbd..00000000
--- a/wip/TS Tests/sprites/create sprite 1.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('bunny', 'assets/sprites/bunny.png');
-
-
- }
-
- function create() {
-
- // This will create a Sprite positioned at the top-left of the game (0,0)
- // Try changing the 0, 0 values
- game.add.sprite(0, 0, 'bunny');
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/origin 5.ts b/wip/TS Tests/sprites/origin 5.ts
deleted file mode 100644
index 0c9784f0..00000000
--- a/wip/TS Tests/sprites/origin 5.ts
+++ /dev/null
@@ -1,291 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png');
- game.load.image('fuji', 'assets/tests/200x100corners.png');
- game.load.image('fuji2', 'assets/tests/200x100corners2.png');
- game.load.image('fuji3', 'assets/tests/320x200.png');
- game.load.image('fuji4', 'assets/tests/320x200g.png');
-
-
- }
-
- var fuji: Phaser.Sprite;
- var fuji2: Phaser.Sprite;
- var fuji3: Phaser.Sprite;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,0)';
- //game.world.setSize(2000, 1200, true);
-
- // The sprite is 320 x 200 pixels in size positioned in the middle of the stage
-
- //fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji4');
- fuji2 = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji3');
- //fuji2 = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji2');
- //fuji3 = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji2');
-
- //fuji.visible = false;
- //fuji2.visible = false;
-
- //fuji.texture.alpha = 0.6;
- //fuji2.texture.alpha = 0.6;
-
- //fuji = game.add.sprite(0, 0, 'fuji');
- //fuji2 = game.add.sprite(0, 0, 'fuji');
-
- //fuji.transform.scale.setTo(1.5, 1.5);
- //fuji.transform.scale.setTo(1.5, 1.5);
- //fuji.transform.skew.setTo(0.1, 0.1);
- //fuji.texture.alpha = 0.5;
-
- //fuji.texture.flippedX = true;
- //fuji.texture.flippedY = true;
-
- //fuji.transform.scale.setTo(2, 2);
- //fuji.transform.scale.setTo(2, 2);
-
- // This sets the origin to the center
- //fuji.transform.origin.setTo(0.5, 0.5);
-
- //fuji.transform.origin.setTo(0, 0);
- fuji2.transform.origin.setTo(1, 1);
-
- //fuji3.transform.origin.setTo(1, 1);
-
- game.input.onTap.add(rotateIt, this);
-
- //game.stage.clear = false;
-
- }
-
- function rotateIt() {
- //fuji.rotation += 10;
- fuji2.rotation += 10;
- //fuji3.rotation += 20;
- }
-
- function update() {
-
- //fuji.rotation++;
- //fuji2.rotation++;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
- var points: Phaser.Point[];
- var points2: Phaser.Point[];
-
- function render() {
-
- // This = the center point
- //var cx = fuji2.x + (fuji2.width / 2) * cos - (fuji2.height / 2) * sin;
- //var cy = fuji2.y + (fuji2.height / 2) * cos + (fuji2.width / 2) * sin;
-
- // This gives me the top-left of an origin 1,1
- //var cx = fuji2.x + (-fuji2.width / fuji2.transform.origin.x) * cos - (-fuji2.height / fuji2.transform.origin.y) * sin;
- //var cy = fuji2.y + (-fuji2.height / fuji2.transform.origin.y) * cos + (-fuji2.width / fuji2.transform.origin.x) * sin;
-
- // This gives me the center point of an origin 1,1
- //var cx = fuji2.x + (-(fuji2.width * fuji2.transform.origin.x) / 2) * cos - (-(fuji2.height * fuji2.transform.origin.y) / 2) * sin;
- //var cy = fuji2.y + (-(fuji2.height * fuji2.transform.origin.y) / 2) * cos + (-(fuji2.width * fuji2.transform.origin.x) / 2) * sin;
-
- //var dx = 0.5 * fuji2.transform.origin.x;
- //var dy = 0.5 * fuji2.transform.origin.y;
-
- //dx = 1;
- //dy = 1;
-
- //console.log(fuji2.width * 0);
-
- //var cx = fuji2.x + (-(fuji2.width * fuji2.transform.origin.x) / dx) * cos - (-(fuji2.height * fuji2.transform.origin.y) / dy) * sin;
- //var cy = fuji2.y + (-(fuji2.height * fuji2.transform.origin.y) / dy) * cos + (-(fuji2.width * fuji2.transform.origin.x) / dx) * sin;
-
- // This gives me the center point of an origin 0,0
- //var cx = fuji2.x + ((fuji2.width * fuji2.transform.origin.x) / 2) * cos - ((fuji2.height * fuji2.transform.origin.y) / 2) * sin;
- //var cy = fuji2.y + ((fuji2.height * fuji2.transform.origin.y) / 2) * cos + ((fuji2.width * fuji2.transform.origin.x) / 2) * sin;
-
- // center points
- //game.stage.context.fillStyle = 'rgb(255,255,0)';
- //game.stage.context.fillRect(fuji.x, fuji.y, 4, 4);
- //game.stage.context.fillRect(fuji2.x, fuji2.y, 4, 4);
- //game.stage.context.fillRect(cx, cy, 4, 4);
-
-
- var sin = Math.sin((fuji2.transform.rotation + fuji2.transform.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
- var cos = Math.cos((fuji2.transform.rotation + fuji2.transform.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
-
- var originX: number = fuji2.transform.origin.x * fuji2.width;
- var originY: number = fuji2.transform.origin.y * fuji2.height;
- var centerX: number = 0.5 * fuji2.width;
- var centerY: number = 0.5 * fuji2.height;
- var distanceX: number = originX - centerX;
- var distanceY: number = originY - centerY;
- var distance: number = Math.sqrt(((originX - centerX) * (originX - centerX)) + ((originY - centerY) * (originY - centerY)));
-
- var px = fuji2.x + distance * Math.cos(fuji2.transform.rotation + 45 * Math.PI / 180);
- var py = fuji2.y + distance * Math.sin(fuji2.transform.rotation + 45 * Math.PI / 180);
-
- game.stage.context.save();
- game.stage.context.fillStyle = 'rgb(255,255,0)';
- game.stage.context.fillText('rect width: ' + originX + ' height: ' + originY, 32, 32);
- game.stage.context.fillText('center x: ' + centerX + ' centerY: ' + centerY, 32, 52);
- game.stage.context.fillText('angle: ' + fuji2.rotation , 32, 72);
- game.stage.context.fillText('point of rotation x: ' + fuji2.transform.origin.x + ' y: ' + fuji2.transform.origin.y, 32, 92);
- game.stage.context.fillText('x: ' + fuji2.x + ' y: ' + fuji2.y, fuji2.x + 4, fuji2.y);
- game.stage.context.restore();
-
- game.stage.context.save();
- game.stage.context.fillStyle = 'rgba(255,255,255,0.1)';
- game.stage.context.arc(fuji2.x, fuji2.y, distance, 0, Math.PI * 2);
- game.stage.context.fill();
- game.stage.context.restore();
-
- //points = Phaser.SpriteUtils.getCornersAsPoints(fuji);
-
- //game.stage.context.fillStyle = 'rgb(255,255,255)';
- //game.stage.context.fillRect(points[0].x, points[0].y, 2, 2);
- //game.stage.context.fillRect(points[1].x, points[1].y, 2, 2);
- //game.stage.context.fillRect(points[2].x, points[2].y, 2, 2);
- //game.stage.context.fillRect(points[3].x, points[3].y, 2, 2);
-
-
- //points2 = Phaser.SpriteUtils.getCornersAsPoints2(fuji2);
-
- //game.stage.context.fillStyle = 'rgb(255,0,0)';
- //game.stage.context.fillRect(points2[0].x, points2[0].y, 2, 2);
- //game.stage.context.fillRect(points2[1].x, points2[1].y, 2, 2);
- //game.stage.context.fillRect(points2[2].x, points2[2].y, 2, 2);
- //game.stage.context.fillRect(points2[3].x, points2[3].y, 2, 2);
-
-
- /*
- //game.stage.context.fillStyle = 'rgb(255,255,255)';
- //game.stage.context.fillRect(fuji.x, fuji.y, 2, 2);
-
- //var sin = Math.sin(game.math.degreesToRadians(fuji.rotation));
- //var cos = Math.cos(game.math.degreesToRadians(fuji.rotation));
-
- //var fx = fuji.x + (fuji.width * fuji.transform.origin.x);
- //var fy = fuji.y + (fuji.height * fuji.transform.origin.y);
-
- // center x/y
- //var cx = fuji.width * 0.5;
- //var cy = fuji.height * 0.5;
-
- //var ax = fuji.width * fuji.transform.origin.x;
- //var ay = fuji.height * fuji.transform.origin.y;
-
- //var dx = cx - ax;
- //var dy = cy - ay;
-
- //var fx = fuji.x - dx;
- //var fy = fuji.y - dy;
-
- /*
- var ox = fuji.x + (fuji.width * fuji.transform.origin.x);
- var oy = fuji.y + (fuji.height * fuji.transform.origin.y);
- var cx = fuji.x + (fuji.width * 0.5);
- var cy = fuji.y + (fuji.height * 0.5);
-
- var dx = ox - cx;
- var dy = oy - cy;
-
- game.stage.context.fillText('dx: ' + dx + ' dy: ' + dy, 300, 100);
-
- var fx = fuji.x + dx;
- var fy = fuji.y + dy;
-
- //game.stage.context.fillStyle = 'rgb(255,0,255)';
- //game.stage.context.fillRect(cx, cy, 20, 20);
-
- //UL = x + ( Width / 2 ) * cos A - ( Height / 2 ) * sin A
- //ul.x = fuji.x + (fuji.width / 2) * cos - (fuji.height / 2) * sin;
- ul.x = fx + (fuji.width / 2) * cos - (fuji.height / 2) * sin;
-
- //UL = y + ( Height / 2 ) * cos A + ( Width / 2 ) * sin A
- //ul.y = fuji.y + (fuji.height / 2) * cos + (fuji.width / 2) * sin;
- ul.y = fy + (fuji.height / 2) * cos + (fuji.width / 2) * sin;
-
- //UR = x - ( Width / 2 ) * cos A - ( Height / 2 ) * sin A
- //ur.x = fuji.x - (fuji.width / 2) * cos - (fuji.height / 2) * sin;
- ur.x = fx - (fuji.width / 2) * cos - (fuji.height / 2) * sin;
-
- //UR = y + ( Height / 2 ) * cos A - ( Width / 2 ) * sin A
- //ur.y = fuji.y + (fuji.height / 2) * cos - (fuji.width / 2) * sin;
- ur.y = fy + (fuji.height / 2) * cos - (fuji.width / 2) * sin;
-
- //BL = x + ( Width / 2 ) * cos A + ( Height / 2 ) * sin A
- //bl.x = fuji.x + (fuji.width / 2) * cos + (fuji.height / 2) * sin;
- bl.x = fx + (fuji.width / 2) * cos + (fuji.height / 2) * sin;
-
- //BL = y - ( Height / 2 ) * cos A + ( Width / 2 ) * sin A
- //bl.y = fuji.y - (fuji.height / 2) * cos + (fuji.width / 2) * sin;
- bl.y = fy - (fuji.height / 2) * cos + (fuji.width / 2) * sin;
-
- //BR = x - ( Width / 2 ) * cos A + ( Height / 2 ) * sin A
- //br.x = fuji.x - (fuji.width / 2) * cos + (fuji.height / 2) * sin;
- br.x = fx - (fuji.width / 2) * cos + (fuji.height / 2) * sin;
-
- //BR = y - ( Height / 2 ) * cos A - ( Width / 2 ) * sin A
- //br.y = fuji.y - (fuji.height / 2) * cos - (fuji.width / 2) * sin;
- br.y = fy - (fuji.height / 2) * cos - (fuji.width / 2) * sin;
-
- game.stage.context.fillStyle = 'rgb(255,255,0)';
- game.stage.context.fillRect(ul.x, ul.y, 2, 2);
- game.stage.context.fillRect(ur.x, ur.y, 2, 2);
- game.stage.context.fillRect(bl.x, bl.y, 2, 2);
- game.stage.context.fillRect(br.x, br.y, 2, 2);
-
-
-
- //game.stage.context.fillRect(fuji.x - fuji.width / 2, fuji.y - fuji.width / 2, 2, 2);
-
- //game.stage.context.fillStyle = 'rgb(255,255,0)';
- //game.stage.context.fillRect(fuji2.x, fuji2.y, 2, 2);
-
- //game.stage.context.fillStyle = 'rgb(255,255,0)';
- //game.stage.context.fillRect(fuji.cameraView.x + fuji.cameraView.halfWidth, fuji.cameraView.y + fuji.cameraView.halfHeight, 2, 2);
-
- //game.stage.context.strokeStyle = 'rgb(255,255,0)';
- //game.stage.context.strokeRect(fuji.cameraView.x, fuji.cameraView.y, fuji.cameraView.width, fuji.cameraView.height);
-
- //game.stage.context.strokeStyle = 'rgb(0,255,0)';
- //game.stage.context.strokeRect(fuji.x, fuji.y, wn, hn);
-
- //game.camera.renderDebugInfo(32, 32);
-
- //Phaser.DebugUtils.renderSpriteInfo(fuji, 32, 32);
- */
-
- //game.stage.context.strokeStyle = 'rgb(255,255,0)';
- //game.stage.context.strokeRect(fuji.cameraView.x, fuji.cameraView.y, fuji.cameraView.width, fuji.cameraView.height);
-
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/out of screen.ts b/wip/TS Tests/sprites/out of screen.ts
deleted file mode 100644
index 3e9a052b..00000000
--- a/wip/TS Tests/sprites/out of screen.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- function preload() {
- game.load.spritesheet('rect', 'assets/buttons/number-buttons-90x90.png', 90, 90);
-
- }
- function create() {
- var rect: Phaser.Sprite,
- factor: Number;
- for (var i = 0; i < 16; i++) {
- rect = game.add.sprite(10 + Math.random() * 700, 10 + Math.random() * 300, 'rect', Math.round(Math.random() * 5));
- factor = 0.2 + Math.random() * 2;
- rect.transform.scale.setTo(factor, factor);
- factor = 2 + Math.random() * 6;
- rect.speed = factor;
- }
- console.log(game.world.group.length);
- }
- function update() {
- game.world.group.forEach(function(rect) {
- // Apply speed to each rect.
- rect.y += rect.speed;
- // Move the rect back to screen if it's not.
- if (!Phaser.SpriteUtils.onScreen(rect)) {
- rect.y = 0;
- }
- });
- }
-})();
diff --git a/wip/TS Tests/sprites/rotate around.ts b/wip/TS Tests/sprites/rotate around.ts
deleted file mode 100644
index db47fdad..00000000
--- a/wip/TS Tests/sprites/rotate around.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-(function() {
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
-
- var rotationSrv: Phaser.Point,
- angle: Number = 0;
-
- function preload() {
- game.load.spritesheet('x', 'assets/sprites/x.png', 220, 160);
-
- }
- function create() {
- // Create 6 sprites rotating around the center at the beginning.
- for (var i = 0; i < 3; i++) {
- game.add.sprite(210 - ((i % 2) ? 140 : 0), 120 * (i + 1), 'x', i);
- game.add.sprite(370 + ((i % 2) ? 140 : 0), 120 * (i + 1), 'x', i + 3);
- }
-
- // Set a default rotation server pointer.
- rotationSrv = new Phaser.Point(game.stage.centerX, game.stage.centerY);
-
- // Rotate all the sprites around the touch point.
- game.input.onTap.add(function(pointer) {
- rotationSrv.x = pointer.position.x;
- rotationSrv.y = pointer.position.y;
- });
- }
- function update() {
- angle += 0.1;
-
- game.world.group.forEach(function(obj) {
- var resPointer = new Phaser.Point(obj.x, obj.y);
- Phaser.PointUtils.rotateAroundPoint(resPointer, rotationSrv, angle);
- obj.x = resPointer.x;
- obj.y = resPointer.y;
- });
- }
- function render() {
- Phaser.DebugUtils.context.fillStyle = '#fff';
- Phaser.DebugUtils.context.fillText('Tap or click to set new rotation point.', 280, 100);
- }
-})();
diff --git a/wip/TS Tests/sprites/scale sprite 1.ts b/wip/TS Tests/sprites/scale sprite 1.ts
deleted file mode 100644
index 9dfd18cf..00000000
--- a/wip/TS Tests/sprites/scale sprite 1.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('bunny', 'assets/sprites/bunny.png');
-
-
- }
-
- var smallBunny: Phaser.Sprite;
-
- function create() {
-
- // Here we'll assign the new sprite to the local smallBunny variable
- smallBunny = game.add.sprite(0, 0, 'bunny');
-
- // And now let's scale the sprite by half
-
- // You can do either:
- //smallBunny.scale.x = 0.5;
- //smallBunny.scale.y = 0.5;
-
- // Or you can set them both at the same time using setTo:
- smallBunny.scale.setTo(0.5, 0.5);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/scale sprite 2.ts b/wip/TS Tests/sprites/scale sprite 2.ts
deleted file mode 100644
index baa69df9..00000000
--- a/wip/TS Tests/sprites/scale sprite 2.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('bunny', 'assets/sprites/bunny.png');
-
-
- }
-
- var bigBunny: Phaser.Sprite;
-
- function create() {
-
- // Here we'll assign the new sprite to the local bigBunny variable
- bigBunny = game.add.sprite(0, 0, 'bunny');
-
- // And now let's scale the sprite by two
-
- // You can do either:
- // smallBunny.transform.scale.x = 2;
- // smallBunny.transform.scale.y = 2;
-
- // Or you can set them both at the same time using setTo:
- bigBunny.transform.scale.setTo(2, 2);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/scale sprite 3.ts b/wip/TS Tests/sprites/scale sprite 3.ts
deleted file mode 100644
index 82cb3a5a..00000000
--- a/wip/TS Tests/sprites/scale sprite 3.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('bunny', 'assets/sprites/bunny.png');
-
-
- }
-
- var bunny: Phaser.Sprite;
-
- function create() {
-
- // Here we'll assign the new sprite to the local bunny variable
- bunny = game.add.sprite(0, 0, 'bunny');
-
- // You don't have to use the same values when scaling a sprite,
- // here we'll create a short and wide bunny
-
- bunny.transform.scale.setTo(3, 0.7);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/scale sprite 4.ts b/wip/TS Tests/sprites/scale sprite 4.ts
deleted file mode 100644
index 1b86f846..00000000
--- a/wip/TS Tests/sprites/scale sprite 4.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('bunny', 'assets/sprites/bunny.png');
-
-
- }
-
- var bunny: Phaser.Sprite;
- var tweenUp: Phaser.Tween;
- var tweenDown: Phaser.Tween;
-
- function create() {
-
- // Here we'll assign the new sprite to the local bunny variable
- bunny = game.add.sprite(0, 0, 'bunny');
-
- bunny.transform.scale.setTo(0.5, 0.5);
-
- // This time let's scale the sprite by a looped tween
- game.add.tween(bunny.transform.scale).to({ x: 1.5, y: 1.5 }, 2000, Phaser.Easing.Elastic.Out, true, 0, true, true);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/scale sprite 5.ts b/wip/TS Tests/sprites/scale sprite 5.ts
deleted file mode 100644
index d8cfc22c..00000000
--- a/wip/TS Tests/sprites/scale sprite 5.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
-
-
- }
-
- var fuji: Phaser.Sprite;
- var tween: Phaser.Tween;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,100)';
-
- // Here we'll assign the new sprite to the local fuji variable
- fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
-
- // sets origin to the center of the sprite (half the width and half the height)
- fuji.transform.origin.setTo(0.5, 0.5);
-
- // We'll tween the scale down to zero (which will make the sprite invisible) and then flip it
- // The end result should look like turning over a card
-
- // Create our tween
- tween = game.add.tween(fuji.transform.scale);
-
- // Start it going
- scaleLeft();
-
- }
-
- function scaleLeft() {
-
- tween.clear();
- tween.to({ x: 0 }, 1000);
- tween.onComplete.add(scaleRight, this);
- tween.start();
-
- }
-
- function scaleRight() {
-
- tween.clear();
- tween.to({ x: 1 }, 1000);
- tween.onComplete.add(scaleLeft, this);
- tween.start();
-
- // This line says "if the texture is flippedX then unflip it (set flippedX to false), otherwise set flippedX to true
- (fuji.texture.flippedX) ? fuji.texture.flippedX = false: fuji.texture.flippedX = true;
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/sprite origin 1.ts b/wip/TS Tests/sprites/sprite origin 1.ts
deleted file mode 100644
index ee19522d..00000000
--- a/wip/TS Tests/sprites/sprite origin 1.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
-
-
- }
-
- var fuji: Phaser.Sprite;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,100)';
-
- // Here we'll assign the new sprite to the local fuji variable
- fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
-
- // The sprite is 320 x 200 pixels in size
- // If we don't set an origin then the sprite will rotate around 0,0 - the top left corner
- game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/sprite origin 2.ts b/wip/TS Tests/sprites/sprite origin 2.ts
deleted file mode 100644
index 382b04f1..00000000
--- a/wip/TS Tests/sprites/sprite origin 2.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
-
-
- }
-
- var fuji: Phaser.Sprite;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,100)';
-
- // Here we'll assign the new sprite to the local fuji variable
- fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
-
- // The sprite is 320 x 200 pixels in size
- // Here we set the origin to the center of the sprite (half of its width and height, so 160x100)
- // This will cause it to rotate on its center
- fuji.transform.origin.setTo(0.5, 0.5);
-
- game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/sprite origin 3.ts b/wip/TS Tests/sprites/sprite origin 3.ts
deleted file mode 100644
index 9ca16b55..00000000
--- a/wip/TS Tests/sprites/sprite origin 3.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
-
-
- }
-
- var fuji: Phaser.Sprite;
- var tween: Phaser.Tween;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,100)';
-
- // Here we'll assign the new sprite to the local fuji variable
- fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
-
- // The sprite is 320 x 200 pixels in size
- // Here we set the origin to be the bottom-right of the sprite
- fuji.origin.setTo(1, 1);
-
- game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
-
- }
-
-})();
diff --git a/wip/TS Tests/sprites/sprite origin 4.ts b/wip/TS Tests/sprites/sprite origin 4.ts
deleted file mode 100644
index 7b644dbd..00000000
--- a/wip/TS Tests/sprites/sprite origin 4.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
-
- function preload() {
-
- // Using Phasers asset loader we load up a PNG from the assets folder
- game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
-
-
- }
-
- var fuji: Phaser.Sprite;
- var tweenUp: Phaser.Tween;
- var tweenDown: Phaser.Tween;
-
- function create() {
-
- game.stage.backgroundColor = 'rgb(0,0,100)';
-
- // Here we'll assign the new sprite to the local fuji variable
- fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
-
- // The sprite is 320 x 200 pixels in size
- // Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time
- fuji.transform.origin.setTo(0.5, 0.5);
-
- game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
-
- tweenUp = game.add.tween(fuji.transform.scale);
- tweenUp.onComplete.add(scaleDown, this);
-
- tweenDown = game.add.tween(fuji.transform.scale);
- tweenDown.onComplete.add(scaleUp, this);
-
- scaleUp();
-
- }
-
- function scaleUp() {
-
- tweenUp.to({ x: 2, y: 2 }, 1000, Phaser.Easing.Elastic.Out);
- tweenUp.start();
-
- }
-
- function scaleDown() {
-
- tweenDown.to({ x: 0.5, y: 0.5 }, 1000, Phaser.Easing.Elastic.Out);
- tweenDown.start();
-
- }
-
-})();
diff --git a/wip/TS Tests/stage/blur filter.ts b/wip/TS Tests/stage/blur filter.ts
deleted file mode 100644
index 3f0c3804..00000000
--- a/wip/TS Tests/stage/blur filter.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
-
-
- }
-
- function create() {
-
- game.world.setSize(1920, 1200);
-
- game.add.sprite(0, 0, 'backdrop');
-
- // Apply a 4px blur to the entire game (this value can be tweened, modified in-game, etc)
- game.stage.css3.blur = 4;
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/stage/brightness filter.ts b/wip/TS Tests/stage/brightness filter.ts
deleted file mode 100644
index ba94f875..00000000
--- a/wip/TS Tests/stage/brightness filter.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
-
-
- }
-
- function create() {
-
- game.world.setSize(1920, 1200);
-
- game.add.sprite(0, 0, 'backdrop');
-
- // Apply a 150% brightness filter to the entire game (this value can be tweened, modified in-game, etc)
- game.stage.css3.brightness = 150;
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/stage/contrast filter.ts b/wip/TS Tests/stage/contrast filter.ts
deleted file mode 100644
index ac2d5e27..00000000
--- a/wip/TS Tests/stage/contrast filter.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
-
-
- }
-
- function create() {
-
- game.world.setSize(1920, 1200);
-
- game.add.sprite(0, 0, 'backdrop');
-
- // Apply a 250% contrast filter to the entire game (this value can be tweened, modified in-game, etc)
- game.stage.css3.contrast = 250;
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/stage/grayscale filter.ts b/wip/TS Tests/stage/grayscale filter.ts
deleted file mode 100644
index cc0de18a..00000000
--- a/wip/TS Tests/stage/grayscale filter.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
-
-
- }
-
- function create() {
-
- game.world.setSize(1920, 1200);
-
- game.add.sprite(0, 0, 'backdrop');
-
- // Apply a 100% contrast filter to the entire game (this value can be tweened, modified in-game, etc)
- game.stage.css3.grayscale = 100;
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/stage/hue rotate filter.ts b/wip/TS Tests/stage/hue rotate filter.ts
deleted file mode 100644
index d7fbc122..00000000
--- a/wip/TS Tests/stage/hue rotate filter.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/large-color-wheel.png');
- game.load.image('coke', 'assets/sprites/cokecan.png');
- game.load.image('mushroom', 'assets/sprites/mushroom2.png');
-
-
- }
-
- var hue: number = 0;
-
- function create() {
-
- game.world.setSize(800, 800);
-
- game.add.sprite(0, 0, 'backdrop');
- game.add.sprite(30, 20, 'coke');
- game.add.sprite(600, 20, 'mushroom');
-
- }
-
- function update() {
-
- // The value is given in degrees, so between 0 and 360, hence the wrapValue call below.
- hue = game.math.wrapValue(hue, 1, 360);
-
- // Apply a hue rotation to the stage
- game.stage.css3.hueRotate = hue;
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/stage/sepia filter.ts b/wip/TS Tests/stage/sepia filter.ts
deleted file mode 100644
index 78ca285c..00000000
--- a/wip/TS Tests/stage/sepia filter.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-///
-
-(function () {
-
- var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
-
- function preload() {
-
- game.load.image('backdrop', 'assets/pics/remember-me.jpg');
-
-
- }
-
- function create() {
-
- game.world.setSize(1920, 1200);
-
- game.add.sprite(0, 0, 'backdrop');
-
- // Apply a 100% sepia filter to the entire game (this value can be tweened, modified in-game, etc)
- game.stage.css3.sepia = 100;
-
- }
-
- function update() {
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
- {
- game.camera.x -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
- {
- game.camera.x += 4;
- }
-
- if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
- {
- game.camera.y -= 4;
- }
- else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
- {
- game.camera.y += 4;
- }
-
- }
-
-})();
diff --git a/wip/TS Tests/states/javascript/FakeGame.js b/wip/TS Tests/states/javascript/FakeGame.js
deleted file mode 100644
index 7b2d6aff..00000000
--- a/wip/TS Tests/states/javascript/FakeGame.js
+++ /dev/null
@@ -1,63 +0,0 @@
-// The first parameter to your function should always be 'game' which is an instance of the Game object.
-FakeGame = function (game) {
-
- // Store the reference and then use it through-out your code
- this.game = game;
-
- this.car;
- this.bigCam;
-
-};
-
-FakeGame.prototype = {
-
- init: function () {
-
- this.game.loader.addImageFile('track', '../../assets/games/f1/track.png');
- this.game.loader.addImageFile('car', '../../assets/games/f1/car1.png');
-
- this.game.loader.load();
-
- },
-
- create: function () {
-
- this.game.camera.setBounds(0, 0, this.game.stage.width, this.game.stage.height);
- this.game.createSprite(0, 0, 'track');
-
- this.car = this.game.createSprite(180, 298, 'car');
- this.car.rotation = 180;
- this.car.maxVelocity.setTo(150, 150);
-
- this.bigCam = this.game.createCamera(640, 0, 100, 200);
- this.bigCam.follow(this.car, Camera.STYLE_LOCKON);
- this.bigCam.setBounds(0, 0, this.game.stage.width, this.game.stage.height);
- this.bigCam.showBorder = true;
- this.bigCam.borderColor = 'rgb(0,0,0)';
- this.bigCam.scale.setTo(2, 2);
-
- },
-
- update: function () {
-
- if (this.game.input.keyboard.isDown(Keyboard.LEFT))
- {
- this.car.rotation -= 4;
- }
- else if (this.game.input.keyboard.isDown(Keyboard.RIGHT))
- {
- this.car.rotation += 4;
- }
-
- if (this.game.input.keyboard.isDown(Keyboard.UP))
- {
- this.car.velocity.copyFrom(this.game.math.velocityFromAngle(this.car.angle, 150));
- }
- else
- {
- this.car.velocity.copyFrom(this.game.math.velocityFromAngle(this.car.angle, 60));
- }
-
- }
-
-}
diff --git a/wip/TS Tests/states/javascript/MainMenu.js b/wip/TS Tests/states/javascript/MainMenu.js
deleted file mode 100644
index df391e53..00000000
--- a/wip/TS Tests/states/javascript/MainMenu.js
+++ /dev/null
@@ -1,72 +0,0 @@
-// The first parameter to your function should always be 'game' which is an instance of the Game object.
-MainMenu = function (game) {
-
- // Store the reference and then use it through-out your code
- this.game = game;
-
- this.monster;
- this.isFalling = false;
-
- this.hasClicked = false;
-
-};
-
-MainMenu.prototype = {
-
- init: function () {
-
- this.game.loader.addImageFile('car', '../../assets/pics/supercars_parsec.png');
- this.game.loader.addSpriteSheet('monster', '../../assets/sprites/metalslug_monster39x40.png', 39, 40);
-
- this.game.loader.load();
-
- },
-
- create: function () {
-
- this.game.camera.backgroundColor = 'rgb(85,85,85)';
-
- this.game.createSprite(80, 150, 'car');
-
- this.monster = this.game.createSprite(80, 60, 'monster');
-
- this.monster.animations.add('walk');
- this.monster.animations.play('walk', 30, true);
- this.monster.velocity.x = 50;
-
- },
-
- update: function () {
-
- if (this.monster.x >= 710 && this.isFalling == false)
- {
- this.isFalling = true;
- this.monster.velocity.x = 20;
- this.monster.acceleration.y = 200;
- this.monster.angularAcceleration = 100;
- this.monster.animations.stop('walk');
- }
-
- if (this.game.input.mouse.isDown && this.hasClicked == false)
- {
- this.hasClicked = true;
- this.game.switchState(FakeGame);
- }
-
- },
-
- render: function () {
-
- this.game.stage.context.fillStyle = 'rgb(0,0,0)';
-
- this.game.stage.context.font = 'bold 48px Arial';
- this.game.stage.context.textAlign = 'center';
- this.game.stage.context.fillText('Super Racer', this.game.stage.centerX, 60);
-
- this.game.stage.context.font = 'bold 22px Arial';
- this.game.stage.context.textAlign = 'center';
- this.game.stage.context.fillText('Click to "Play"', this.game.stage.centerX, 370);
-
- }
-
-}
diff --git a/wip/TS Tests/states/javascript/index.html b/wip/TS Tests/states/javascript/index.html
deleted file mode 100644
index 29b2d695..00000000
--- a/wip/TS Tests/states/javascript/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
- Phaser Test Runner : JS State Test 1
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wip/TS Tests/states/typescript/FakeGame.ts b/wip/TS Tests/states/typescript/FakeGame.ts
deleted file mode 100644
index 186598ad..00000000
--- a/wip/TS Tests/states/typescript/FakeGame.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-///
-///
-
-class FakeGame extends State {
-
- constructor(game: Game) {
-
- super(game);
-
- }
-
- private car: Phaser.Sprite;
- private bigCam: Phaser.Camera;
-
- public init() {
-
- this.load.image('track', '../../assets/games/f1/track.png');
- this.load.image('car', '../../assets/games/f1/car1.png');
-
- this.load.start();
-
- }
-
- public create() {
-
- this.camera.setBounds(0, 0, this.stage.width, this.stage.height);
- this.add.sprite(0, 0, 'track');
-
- this.car = this.game.add.sprite(180, 298, 'car');
- this.car.rotation = 180;
- this.car.maxVelocity.setTo(150, 150);
-
- this.bigCam = this.add.camera(640, 0, 100, 200);
- this.bigCam.follow(this.car, Camera.STYLE_LOCKON);
- this.bigCam.setBounds(0, 0, this.stage.width, this.stage.height);
- this.bigCam.showBorder = true;
- this.bigCam.borderColor = 'rgb(0,0,0)';
- this.bigCam.scale.setTo(2, 2);
-
- }
-
- public update() {
-
- if (this.input.keyboard.isDown(Keyboard.LEFT))
- {
- this.car.rotation -= 4;
- }
- else if (this.input.keyboard.isDown(Keyboard.RIGHT))
- {
- this.car.rotation += 4;
- }
-
- if (this.game.input.keyboard.isDown(Keyboard.UP))
- {
- this.car.velocity.copyFrom(this.math.velocityFromAngle(this.car.angle, 150));
- }
- else
- {
- this.car.velocity.copyFrom(this.math.velocityFromAngle(this.car.angle, 60));
- }
-
- }
-
-}
diff --git a/wip/TS Tests/states/typescript/MainMenu.ts b/wip/TS Tests/states/typescript/MainMenu.ts
deleted file mode 100644
index a288b76d..00000000
--- a/wip/TS Tests/states/typescript/MainMenu.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-///
-///
-///
-
-class MainMenu extends State {
-
- constructor(game: Game) {
-
- super(game);
-
- }
-
- private monster: Phaser.Sprite;
- private isFalling: bool = false;
- private hasClicked: bool = false;
-
- public init() {
-
- this.load.image('car', '../../assets/pics/supercars_parsec.png');
- this.loader.addSpriteSheet('monster', '../../assets/sprites/metalslug_monster39x40.png', 39, 40);
-
- this.load.start();
-
- }
-
- public create() {
-
- this.camera.backgroundColor = 'rgb(85,85,85)';
-
- this.add.sprite(80, 150, 'car');
-
- this.monster = this.game.add.sprite(80, 60, 'monster');
-
- this.monster.animations.add('walk');
- this.monster.animations.play('walk', 30, true);
- this.monster.velocity.x = 50;
-
- }
-
- public update() {
-
- if (this.monster.x >= 710 && this.isFalling == false)
- {
- this.isFalling = true;
- this.monster.velocity.x = 20;
- this.monster.acceleration.y = 200;
- this.monster.angularAcceleration = 100;
- this.monster.animations.stop('walk');
- }
-
- if (this.input.mouse.isDown && this.hasClicked == false)
- {
- this.hasClicked = true;
- this.game.switchState(FakeGame);
- }
-
- }
-
- public render() {
-
- this.stage.context.fillStyle = 'rgb(0,0,0)';
-
- this.stage.context.font = 'bold 48px Arial';
- this.stage.context.textAlign = 'center';
- this.stage.context.fillText('Super Racer', this.stage.centerX, 60);
-
- this.stage.context.font = 'bold 22px Arial';
- this.stage.context.textAlign = 'center';
- this.stage.context.fillText('Click to "Play"', this.stage.centerX, 370);
-
- }
-
-}
diff --git a/wip/TS Tests/states/typescript/index.html b/wip/TS Tests/states/typescript/index.html
deleted file mode 100644
index 4475ab79..00000000
--- a/wip/TS Tests/states/typescript/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
- Phaser Test Runner : TypeScript State Test 1
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wip/TS Tests/template_breakout/Boot.js b/wip/TS Tests/template_breakout/Boot.js
deleted file mode 100644
index 722d05c0..00000000
--- a/wip/TS Tests/template_breakout/Boot.js
+++ /dev/null
@@ -1,41 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-///
-var BasicGame;
-(function (BasicGame) {
- var Boot = (function (_super) {
- __extends(Boot, _super);
- function Boot() {
- _super.apply(this, arguments);
- }
- Boot.prototype.preload = function () {
- this.load.image("preloaderBackground", "assets/preloader_background.gif");
- this.load.image("preloaderBar", "assets/preloadr_bar.png");
- };
- Boot.prototype.create = function () {
- this.game.input.maxPointers = 1;
- this.game.stage.disableVisibilityChange = true;
-
- if (this.game.device.desktop) {
- this.game.stage.scale.pageAlignHorizontally = true;
- } else {
- this.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
- this.game.stage.scale.minWidth = 480;
- this.game.stage.scale.minHeight = 260;
- this.game.stage.scale.maxWidth = 1024;
- this.game.stage.scale.maxHeight = 768;
- this.game.stage.scale.forceLandscape = true;
- this.game.stage.scale.pageAlignHorizontally = true;
- this.game.stage.scale.setScreenSize(true);
- }
-
- this.game.state.start("Preloader");
- };
- return Boot;
- })(Phaser.State);
- BasicGame.Boot = Boot;
-})(BasicGame || (BasicGame = {}));
diff --git a/wip/TS Tests/template_breakout/Boot.ts b/wip/TS Tests/template_breakout/Boot.ts
deleted file mode 100644
index 2a08d88b..00000000
--- a/wip/TS Tests/template_breakout/Boot.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-///
-module BasicGame
-{
- export class Boot extends Phaser.State{
- preload() {
- this.load.image("preloaderBackground","assets/preloader_background.gif");
- this.load.image("preloaderBar","assets/preloadr_bar.png");
- }
- create() {
- this.game.input.maxPointers = 1;
- this.game.stage.disableVisibilityChange = true;
-
- if( this.game.device.desktop )
- {
- this.game.stage.scale.pageAlignHorizontally = true;
- }
- else
- {
- this.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
- this.game.stage.scale.minWidth = 480;
- this.game.stage.scale.minHeight = 260;
- this.game.stage.scale.maxWidth = 1024;
- this.game.stage.scale.maxHeight = 768;
- this.game.stage.scale.forceLandscape = true;
- this.game.stage.scale.pageAlignHorizontally = true;
- this.game.stage.scale.setScreenSize( true );
- }
-
- this.game.state.start("Preloader");
- }
- }
-}
\ No newline at end of file
diff --git a/wip/TS Tests/template_breakout/GameState.js b/wip/TS Tests/template_breakout/GameState.js
deleted file mode 100644
index aefe3f6e..00000000
--- a/wip/TS Tests/template_breakout/GameState.js
+++ /dev/null
@@ -1,151 +0,0 @@
-///
-var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var BasicGame;
-(function (BasicGame) {
- var GameState = (function (_super) {
- __extends(GameState, _super);
- function GameState() {
- _super.apply(this, arguments);
- }
- GameState.prototype.create = function () {
- this.game.world.height = 620;
-
- this._ballOnPaddle = true;
- this._score = 0;
- this._lives = 3;
-
- this._s = this.game.add.tileSprite(0, 0, 800, 600, "starfield");
-
- var brick;
- this._bricks = this.game.add.group();
-
- for (var y = 0; y < 4; y++) {
- for (var x = 0; x < 15; x++) {
- brick = this._bricks.create(120 + (x * 36), 100 + (y * 52), "breakout", "brick_" + (y + 1) + "_1.png");
- brick.body.bounce.setTo(1, 1);
- brick.body.immovable = true;
- }
- }
-
- this._paddle = this.game.add.sprite(this.game.world.centerX, 500, "breakout", "paddle_big.png");
- this._paddle.anchor.setTo(0.5, 0.5);
- this._paddle.body.collideWorldBounds = true;
- this._paddle.body.bounce.setTo(1, 1);
- this._paddle.body.immovable = true;
-
- this._ball = this.game.add.sprite(this.game.world.centerX, this._paddle.y - 16, "breakout", 'ball_1.png');
- this._ball.anchor.setTo(0.5, 0.5);
- this._ball.body.collideWorldBounds = true;
-
- this._ball.body.bounce.setTo(1, 1);
- this._ball.animations.add("spin", ["ball_1.png", "ball_2.png", "ball_3.png", "ball_4.png", "ball_5.png"], 50, true, false);
-
- this._scoreText = this.game.add.text(32, 550, "score: 0", { font: "20px Arial", fill: "#ffffff", align: "left" });
- this._livesText = this.game.add.text(680, 550, "lives: 3", { font: "20px Arial", fill: "#ffffff", align: "left" });
- this._introText = this.game.add.text(this.game.world.centerX, 400, "- click to start -", { font: "40px Arial", fill: "#ffffff", align: "center" });
- this._introText.anchor.setTo(0.5, 0.5);
-
- this.game.input.onDown.add(this.releaseBall, this);
-
- this._ballOnPaddle = true;
- };
-
- GameState.prototype.update = function () {
- this._paddle.x = this.game.input.x;
-
- if (this._paddle.x < 24) {
- this._paddle.x = 24;
- } else if (this._paddle.x > this.game.width - 24) {
- this._paddle.x = this.game.width - 24;
- }
-
- if (this._ballOnPaddle) {
- this._ball.x = this._paddle.x;
- } else {
- this.game.physics.collide(this._ball, this._paddle, this.ballHitPaddle, null, this);
- this.game.physics.collide(this._ball, this._bricks, this.ballHitBrick, null, this);
- }
-
- if (this._ball.y > 600 && this._ballOnPaddle == false) {
- this.ballLost();
- }
- };
-
- GameState.prototype.quitGame = function (p_pointer) {
- this.game.state.start("MainMenu");
- };
-
- GameState.prototype.releaseBall = function () {
- if (this._ballOnPaddle) {
- this._ballOnPaddle = false;
- this._ball.body.velocity.y = -300;
- this._ball.body.velocity.x = -75;
- this._ball.animations.play("spin");
- this._introText.visible = false;
- }
- };
-
- GameState.prototype.ballLost = function () {
- this._lives--;
-
- if (this._lives == 0) {
- this.gameOver();
- } else {
- this._livesText.content = "lives: " + this._lives;
- this._ballOnPaddle = true;
- this._ball.body.velocity.setTo(0, 0);
- this._ball.x = this._paddle.x + 16;
- this._ball.y = this._paddle.y - 16;
- this._ball.animations.stop();
- }
- };
-
- GameState.prototype.gameOver = function () {
- this._ball.body.velocity.setTo(0, 0);
-
- this.quitGame();
- };
-
- GameState.prototype.ballHitBrick = function (p_ball, p_brick) {
- p_brick.kill();
-
- this._score += 10;
- this._scoreText.content = "score: " + this._score;
-
- if (this._bricks.countLiving() == 0) {
- this._score += 1000;
- this._scoreText.content = "score: " + this._score;
- this._introText.content = "- Next Level -";
-
- this._ballOnPaddle = true;
- this._ball.body.velocity.setTo(0, 0);
- this._ball.x = this._paddle.x + 16;
- this._ball.y = this._paddle.y - 16;
- this._ball.animations.stop();
-
- this._bricks.callAll('revive');
- }
- };
-
- GameState.prototype.ballHitPaddle = function (p_ball, p_paddle) {
- var l_diff = 0;
-
- if (p_ball.x < p_paddle.x) {
- l_diff = p_paddle.x - p_ball.x;
- p_ball.body.velocity.x = (-10 * l_diff);
- } else if (p_ball.x > p_paddle.x) {
- l_diff = p_ball.x - p_paddle.x;
- p_ball.body.velocity.x = (10 * l_diff);
- } else {
- p_ball.body.velocity.x = 2 + Math.random() * 8;
- }
- };
- return GameState;
- })(Phaser.State);
- BasicGame.GameState = GameState;
-})(BasicGame || (BasicGame = {}));
diff --git a/wip/TS Tests/template_breakout/GameState.ts b/wip/TS Tests/template_breakout/GameState.ts
deleted file mode 100644
index 438a5caf..00000000
--- a/wip/TS Tests/template_breakout/GameState.ts
+++ /dev/null
@@ -1,184 +0,0 @@
-///
-
-module BasicGame
-{
- export class GameState extends Phaser.State {
- private _ball:Phaser.Sprite;
- private _paddle:Phaser.Sprite;
- private _bricks:Phaser.Group;
-
- private _ballOnPaddle:boolean;
-
- private _lives:number;
- private _score:number;
-
- private _scoreText:Phaser.Text;
- private _livesText:Phaser.Text;
- private _introText:Phaser.Text;
-
- private _s:Phaser.TileSprite;
-
- create():void {
- this.game.world.height = 620;
-
- this._ballOnPaddle = true;
- this._score = 0;
- this._lives = 3;
-
- this._s = this.game.add.tileSprite(0,0,800,600,"starfield");
-
- var brick:Phaser.Sprite;
- this._bricks = this.game.add.group();
-
- for( var y=0; y < 4; y++ )
- {
- for( var x=0; x < 15; x++)
- {
- brick = this._bricks.create(120 + ( x * 36 ), 100 + ( y * 52 ),"breakout","brick_" + ( y+1 ) + "_1.png");
- brick.body.bounce.setTo(1, 1);
- brick.body.immovable = true;
- }
- }
-
- this._paddle = this.game.add.sprite( this.game.world.centerX, 500, "breakout", "paddle_big.png");
- this._paddle.anchor.setTo(0.5,0.5);
- this._paddle.body.collideWorldBounds = true;
- this._paddle.body.bounce.setTo(1,1);
- this._paddle.body.immovable = true;
-
- this._ball = this.game.add.sprite( this.game.world.centerX, this._paddle.y - 16, "breakout",'ball_1.png');
- this._ball.anchor.setTo(0.5,0.5);
- this._ball.body.collideWorldBounds = true;
-
- this._ball.body.bounce.setTo(1,1);
- this._ball.animations.add("spin", ["ball_1.png", "ball_2.png", "ball_3.png", "ball_4.png", "ball_5.png" ], 50, true, false);
-
- this._scoreText = this.game.add.text(32, 550, "score: 0", {font: "20px Arial", fill: "#ffffff", align: "left" });
- this._livesText = this.game.add.text(680, 550, "lives: 3", {font: "20px Arial", fill: "#ffffff", align: "left" });
- this._introText = this.game.add.text(this.game.world.centerX, 400, "- click to start -", {font: "40px Arial", fill: "#ffffff", align: "center" });
- this._introText.anchor.setTo(0.5,0.5);
-
- this.game.input.onDown.add( this.releaseBall, this );
-
- this._ballOnPaddle = true;
-
- }
-
- update():void
- {
- this._paddle.x = this.game.input.x;
-
- if( this._paddle.x < 24 )
- {
- this._paddle.x = 24;
- }
- else if( this._paddle.x > this.game.width - 24 )
- {
- this._paddle.x = this.game.width - 24;
- }
-
- if( this._ballOnPaddle )
- {
- this._ball.x = this._paddle.x;
- }
- else
- {
- this.game.physics.collide( this._ball, this._paddle, this.ballHitPaddle, null, this );
- this.game.physics.collide( this._ball, this._bricks, this.ballHitBrick, null, this );
- }
-
- if( this._ball.y > 600 && this._ballOnPaddle == false )
- {
- this.ballLost();
- }
- }
-
- private quitGame( p_pointer?:any ):void
- {
- this.game.state.start("MainMenu");
- }
-
- private releaseBall():void
- {
- if( this._ballOnPaddle )
- {
- this._ballOnPaddle = false;
- this._ball.body.velocity.y = -300;
- this._ball.body.velocity.x = -75;
- this._ball.animations.play("spin");
- this._introText.visible = false;
- }
- }
-
- private ballLost():void
- {
- this._lives--;
-
- if( this._lives == 0)
- {
- this.gameOver();
- }
- else
- {
- this._livesText.content = "lives: " + this._lives;
- this._ballOnPaddle = true;
- this._ball.body.velocity.setTo(0,0);
- this._ball.x = this._paddle.x + 16;
- this._ball.y = this._paddle.y - 16;
- this._ball.animations.stop();
- }
- }
-
- private gameOver():void
- {
- this._ball.body.velocity.setTo(0,0);
-
- this.quitGame();
- }
-
- private ballHitBrick( p_ball:Phaser.Sprite, p_brick:Phaser.Sprite ):void
- {
- p_brick.kill();
-
- this._score += 10;
- this._scoreText.content = "score: " + this._score;
-
- if( this._bricks.countLiving() == 0 )
- {
- this._score += 1000;
- this._scoreText.content = "score: " + this._score;
- this._introText.content = "- Next Level -";
-
- this._ballOnPaddle = true;
- this._ball.body.velocity.setTo(0,0);
- this._ball.x = this._paddle.x + 16;
- this._ball.y = this._paddle.y - 16;
- this._ball.animations.stop();
-
- this._bricks.callAll('revive');
- }
-
-
- }
-
- private ballHitPaddle( p_ball:Phaser.Sprite, p_paddle:Phaser.Sprite ):void
- {
- var l_diff:number = 0;
-
- if( p_ball.x < p_paddle.x )
- {
- l_diff = p_paddle.x - p_ball.x;
- p_ball.body.velocity.x = (-10 * l_diff);
- }
- else if( p_ball.x > p_paddle.x )
- {
- l_diff = p_ball.x - p_paddle.x;
- p_ball.body.velocity.x = (10 * l_diff);
- }
- else
- {
- p_ball.body.velocity.x = 2 + Math.random() * 8;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/wip/TS Tests/template_breakout/Main.js b/wip/TS Tests/template_breakout/Main.js
deleted file mode 100644
index 9a36a21e..00000000
--- a/wip/TS Tests/template_breakout/Main.js
+++ /dev/null
@@ -1,15 +0,0 @@
-///
-///
-///
-///
-///
-window.onload = function () {
- var game = new Phaser.Game(800, 600, Phaser.AUTO, 'gameContainer', null, false, false);
-
- game.state.add("Boot", BasicGame.Boot);
- game.state.add("Preloader", BasicGame.Preloader);
- game.state.add("MainMenu", BasicGame.MainMenu);
- game.state.add("GameState", BasicGame.GameState);
-
- game.state.start("Boot");
-};
diff --git a/wip/TS Tests/template_breakout/Main.ts b/wip/TS Tests/template_breakout/Main.ts
deleted file mode 100644
index a233bd0e..00000000
--- a/wip/TS Tests/template_breakout/Main.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-///
-///
-///
-///
-///
-
-window.onload = function() {
- var game:Phaser.Game = new Phaser.Game(800, 600, Phaser.AUTO, 'gameContainer', null, false, false);
-
- game.state.add("Boot", BasicGame.Boot);
- game.state.add("Preloader", BasicGame.Preloader);
- game.state.add("MainMenu", BasicGame.MainMenu);
- game.state.add("GameState", BasicGame.GameState );
-
- game.state.start("Boot");
-}
-
-
diff --git a/wip/TS Tests/template_breakout/MainMenu.js b/wip/TS Tests/template_breakout/MainMenu.js
deleted file mode 100644
index b130091b..00000000
--- a/wip/TS Tests/template_breakout/MainMenu.js
+++ /dev/null
@@ -1,31 +0,0 @@
-///
-var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var BasicGame;
-(function (BasicGame) {
- var MainMenu = (function (_super) {
- __extends(MainMenu, _super);
- function MainMenu() {
- _super.apply(this, arguments);
- }
- MainMenu.prototype.create = function () {
- this.music = this.add.audio("titleMusic");
- this.music.play();
-
- this.add.sprite(0, 0, "titlepage");
-
- this.playButton = this.add.button(200, 300, "playButton", this.startGame, this);
- };
-
- MainMenu.prototype.startGame = function () {
- this.music.stop();
- this.game.state.start("GameState");
- };
- return MainMenu;
- })(Phaser.State);
- BasicGame.MainMenu = MainMenu;
-})(BasicGame || (BasicGame = {}));
diff --git a/wip/TS Tests/template_breakout/MainMenu.ts b/wip/TS Tests/template_breakout/MainMenu.ts
deleted file mode 100644
index 4103b485..00000000
--- a/wip/TS Tests/template_breakout/MainMenu.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-///
-
-module BasicGame
-{
- export class MainMenu extends Phaser.State{
- music:Phaser.Sound;
- playButton:Phaser.Button;
-
- create():void {
-
- this.music = this.add.audio("titleMusic");
- this.music.play();
-
- this.add.sprite(0,0,"titlepage");
-
- this.playButton = this.add.button(200,300,"playButton", this.startGame, this);
- }
-
- startGame():void {
- this.music.stop();
- this.game.state.start("GameState");
- }
- }
-}
\ No newline at end of file
diff --git a/wip/TS Tests/template_breakout/Preloader.js b/wip/TS Tests/template_breakout/Preloader.js
deleted file mode 100644
index 1754a64d..00000000
--- a/wip/TS Tests/template_breakout/Preloader.js
+++ /dev/null
@@ -1,45 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-///
-var BasicGame;
-(function (BasicGame) {
- var Preloader = (function (_super) {
- __extends(Preloader, _super);
- function Preloader() {
- _super.apply(this, arguments);
- this.background = null;
- this.preloadBar = null;
- this.ready = false;
- }
- Preloader.prototype.preload = function () {
- this.background = this.add.sprite(0.0, 0.0, "preloaderBackground");
- this.preloadBar = this.add.sprite(300, 400, "preloaderBar");
-
- this.load.setPreloadSprite(this.preloadBar);
-
- this.load.image("titlepage", "assets/title.gif");
- this.load.image("playButton", "assets/play_button.png");
- this.load.audio("titleMusic", ["assets/main_menu.mp3", "assets/main_menu.ogg"]);
-
- this.load.atlas("breakout", "assets/breakout.png", "assets/breakout.json");
- this.load.image("starfield", "assets/starfield.jpg");
- };
-
- Preloader.prototype.create = function () {
- this.preloadBar.cropEnabled = false;
- };
-
- Preloader.prototype.update = function () {
- if (this.cache.isSoundDecoded("titleMusic") && this.ready == false) {
- this.ready = true;
- this.game.state.start("MainMenu");
- }
- };
- return Preloader;
- })(Phaser.State);
- BasicGame.Preloader = Preloader;
-})(BasicGame || (BasicGame = {}));
diff --git a/wip/TS Tests/template_breakout/Preloader.ts b/wip/TS Tests/template_breakout/Preloader.ts
deleted file mode 100644
index 376b1f59..00000000
--- a/wip/TS Tests/template_breakout/Preloader.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-///
-module BasicGame
-{
- export class Preloader extends Phaser.State {
- background:Phaser.Sprite = null;
- preloadBar:Phaser.Sprite = null;
- ready:boolean = false;
-
- preload():void {
- this.background = this.add.sprite(0.0,0.0,"preloaderBackground");
- this.preloadBar = this.add.sprite(300,400,"preloaderBar");
-
- this.load.setPreloadSprite( this.preloadBar );
-
- this.load.image("titlepage","assets/title.gif");
- this.load.image("playButton","assets/play_button.png");
- this.load.audio("titleMusic",["assets/main_menu.mp3","assets/main_menu.ogg"]);
-
- this.load.atlas("breakout","assets/breakout.png","assets/breakout.json");
- this.load.image("starfield","assets/starfield.jpg");
- }
-
- create():void {
- this.preloadBar.cropEnabled = false;
- }
-
- update():void {
- if( this.cache.isSoundDecoded("titleMusic") && this.ready == false )
- {
- this.ready = true;
- this.game.state.start("MainMenu");
- }
- }
- }
-}
diff --git a/wip/TS Tests/template_breakout/assets/breakout.json b/wip/TS Tests/template_breakout/assets/breakout.json
deleted file mode 100644
index a21b339d..00000000
--- a/wip/TS Tests/template_breakout/assets/breakout.json
+++ /dev/null
@@ -1,236 +0,0 @@
-{"frames": [
-
-{
- "filename": "ball_1.png",
- "frame": {"x":218,"y":38,"w":16,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
- "sourceSize": {"w":16,"h":16}
-},
-{
- "filename": "ball_2.png",
- "frame": {"x":218,"y":20,"w":16,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
- "sourceSize": {"w":16,"h":16}
-},
-{
- "filename": "ball_3.png",
- "frame": {"x":218,"y":2,"w":16,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
- "sourceSize": {"w":16,"h":16}
-},
-{
- "filename": "ball_4.png",
- "frame": {"x":200,"y":38,"w":16,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
- "sourceSize": {"w":16,"h":16}
-},
-{
- "filename": "ball_5.png",
- "frame": {"x":200,"y":20,"w":16,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
- "sourceSize": {"w":16,"h":16}
-},
-{
- "filename": "brick_1_1.png",
- "frame": {"x":98,"y":21,"w":32,"h":17},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":17},
- "sourceSize": {"w":32,"h":17}
-},
-{
- "filename": "brick_1_2.png",
- "frame": {"x":98,"y":2,"w":32,"h":17},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":17},
- "sourceSize": {"w":32,"h":17}
-},
-{
- "filename": "brick_1_3.png",
- "frame": {"x":270,"y":17,"w":30,"h":13},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":1,"y":1,"w":30,"h":13},
- "sourceSize": {"w":32,"h":17}
-},
-{
- "filename": "brick_1_4.png",
- "frame": {"x":54,"y":52,"w":24,"h":9},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":4,"y":4,"w":24,"h":9},
- "sourceSize": {"w":32,"h":17}
-},
-{
- "filename": "brick_2_1.png",
- "frame": {"x":236,"y":19,"w":32,"h":15},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":15},
- "sourceSize": {"w":32,"h":15}
-},
-{
- "filename": "brick_2_2.png",
- "frame": {"x":236,"y":2,"w":32,"h":15},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":15},
- "sourceSize": {"w":32,"h":15}
-},
-{
- "filename": "brick_2_3.png",
- "frame": {"x":270,"y":2,"w":30,"h":13},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":1,"y":0,"w":30,"h":13},
- "sourceSize": {"w":32,"h":15}
-},
-{
- "filename": "brick_2_4.png",
- "frame": {"x":236,"y":50,"w":24,"h":11},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":4,"y":3,"w":24,"h":11},
- "sourceSize": {"w":32,"h":15}
-},
-{
- "filename": "brick_3_1.png",
- "frame": {"x":166,"y":20,"w":32,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "brick_3_2.png",
- "frame": {"x":166,"y":2,"w":32,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "brick_3_3.png",
- "frame": {"x":236,"y":36,"w":30,"h":12},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":1,"y":2,"w":30,"h":12},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "brick_3_4.png",
- "frame": {"x":28,"y":52,"w":24,"h":10},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":4,"y":3,"w":24,"h":10},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "one.png",
- "frame": {"x":66,"y":2,"w":30,"h":48},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":1,"y":16,"w":30,"h":48},
- "sourceSize": {"w":32,"h":64}
-},
-{
- "filename": "paddle_big.png",
- "frame": {"x":98,"y":40,"w":48,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":48,"h":16},
- "sourceSize": {"w":48,"h":16}
-},
-{
- "filename": "paddle_small.png",
- "frame": {"x":148,"y":38,"w":32,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "power_down.png",
- "frame": {"x":200,"y":2,"w":16,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
- "sourceSize": {"w":16,"h":16}
-},
-{
- "filename": "power_up.png",
- "frame": {"x":182,"y":38,"w":16,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
- "sourceSize": {"w":16,"h":16}
-},
-{
- "filename": "brick_4_1.png",
- "frame": {"x":132,"y":20,"w":32,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "brick_4_2.png",
- "frame": {"x":132,"y":2,"w":32,"h":16},
- "rotated": false,
- "trimmed": false,
- "spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "brick_4_3.png",
- "frame": {"x":270,"y":32,"w":30,"h":12},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":1,"y":2,"w":30,"h":12},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "brick_4_4.png",
- "frame": {"x":2,"y":52,"w":24,"h":10},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":4,"y":3,"w":24,"h":10},
- "sourceSize": {"w":32,"h":16}
-},
-{
- "filename": "three.png",
- "frame": {"x":34,"y":2,"w":30,"h":48},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":1,"y":0,"w":30,"h":48},
- "sourceSize": {"w":32,"h":48}
-},
-{
- "filename": "two.png",
- "frame": {"x":2,"y":2,"w":30,"h":48},
- "rotated": false,
- "trimmed": true,
- "spriteSourceSize": {"x":1,"y":16,"w":30,"h":48},
- "sourceSize": {"w":32,"h":64}
-}],
-"meta": {
- "app": "http://www.texturepacker.com",
- "version": "1.0",
- "image": "breakout.png",
- "format": "RGBA8888",
- "size": {"w":302,"h":64},
- "scale": "1",
- "smartupdate": "$TexturePacker:SmartUpdate:c510ff2f709e8d175b059cd1cbe64773$"
-}
-}
diff --git a/wip/TS Tests/template_breakout/assets/breakout.png b/wip/TS Tests/template_breakout/assets/breakout.png
deleted file mode 100644
index 85f75c82..00000000
Binary files a/wip/TS Tests/template_breakout/assets/breakout.png and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/assets/main_menu.mp3 b/wip/TS Tests/template_breakout/assets/main_menu.mp3
deleted file mode 100644
index 9a106fa5..00000000
Binary files a/wip/TS Tests/template_breakout/assets/main_menu.mp3 and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/assets/main_menu.ogg b/wip/TS Tests/template_breakout/assets/main_menu.ogg
deleted file mode 100644
index 4afaa581..00000000
Binary files a/wip/TS Tests/template_breakout/assets/main_menu.ogg and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/assets/play_button.png b/wip/TS Tests/template_breakout/assets/play_button.png
deleted file mode 100644
index a3352847..00000000
Binary files a/wip/TS Tests/template_breakout/assets/play_button.png and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/assets/preloader_background.gif b/wip/TS Tests/template_breakout/assets/preloader_background.gif
deleted file mode 100644
index 15fc8d3d..00000000
Binary files a/wip/TS Tests/template_breakout/assets/preloader_background.gif and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/assets/preloadr_bar.png b/wip/TS Tests/template_breakout/assets/preloadr_bar.png
deleted file mode 100644
index 71ca1b46..00000000
Binary files a/wip/TS Tests/template_breakout/assets/preloadr_bar.png and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/assets/starfield.jpg b/wip/TS Tests/template_breakout/assets/starfield.jpg
deleted file mode 100644
index 8d07e45b..00000000
Binary files a/wip/TS Tests/template_breakout/assets/starfield.jpg and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/assets/title.gif b/wip/TS Tests/template_breakout/assets/title.gif
deleted file mode 100644
index d8d53d3d..00000000
Binary files a/wip/TS Tests/template_breakout/assets/title.gif and /dev/null differ
diff --git a/wip/TS Tests/template_breakout/phaser.d.ts b/wip/TS Tests/template_breakout/phaser.d.ts
deleted file mode 100644
index 43e150c0..00000000
--- a/wip/TS Tests/template_breakout/phaser.d.ts
+++ /dev/null
@@ -1,1824 +0,0 @@
-declare class Phaser {
- static VERSION: string;
- static DEV_VERSION: string;
- static GAMES: Array;
- static AUTO: number;
- static CANVAS: number;
- static WEBGL: number;
- static SPRITE: number;
- static BUTTON: number;
- static BULLET: number;
- static GRAPHICS: number;
- static TEXT: number;
- static TILESPRITE: number;
- static BITMAPTEXT: number;
- static GROUP: number;
- static RENDERTEXTURE: number;
- static TILEMAP: number;
- static TILEMAPLAYER: number;
- static EMITTER: number;
-}
-
-declare module Phaser {
- class Camera {
- constructor(game: Phaser.Game, id: number, x: number, y: number, width: number, height: number);
- game: Phaser.Game;
- world: Phaser.World;
- id: number;
- x: number;
- y: number;
- width: number;
- height: number;
- view: Phaser.Rectangle;
- screenView: Phaser.Rectangle;
- deadzone: Phaser.Rectangle;
- visible: boolean;
- atLimit: { x: boolean; y: boolean; };
- target: Phaser.Sprite;
- _edge: number;
- static FOLLOW_LOCKON: number;
- static FOLLOW_PLATFORMER: number;
- static FOLLOW_TOPDOWN: number;
- static FOLLOW_TOPDOWN_TIGHT: number;
- follow(target: Phaser.Sprite, style?: number): void;
- focusOnXY(x: number, y: number): void;
- update(): void;
- checkWorldBounds(): void;
- setPosition(x: number, y: number): void;
- setSize(width: number, height: number): void;
- }
-
- class State {
- game: Phaser.Game;
- add: Phaser.GameObjectFactory;
- camera: Phaser.Camera;
- cache: Phaser.Cache;
- input: Phaser.Input;
- stage: Phaser.Stage;
- math: Phaser.Math;
- sound: Phaser.SoundManager;
- time: Phaser.Time;
- tweens: Phaser.TweenManager;
- world: Phaser.World;
- particles: Phaser.Particles;
- physics: Phaser.Physics.Arcade;
- load: Phaser.Loader;
- preload();
- create();
- render();
- update();
- paused();
- destroy();
- }
-
- class StateManager {
- constructor(game: Phaser.Game, pendingState: Phaser.State);
- game: Phaser.Game;
- states: Object;
- current: Phaser.State;
- onInitCallback(): void;
- onPreloadCallback(): void;
- onCreateCallback(): void;
- onUpdateCallback(): void;
- onRenderCallback(): void;
- onPreRenderCallback(): void;
- onLoadUpdateCallback(): void;
- onLoadRenderCallback(): void;
- onPausedCallback(): void;
- onShutDownCallback(): void;
- boot(): void;
- add(key: string, state: typeof Phaser.State, autoStart?: boolean): void;
- remove(key: string): void;
- start(key: string, clearWorld?: boolean, clearCache?: boolean): void;
- dummy(): void;
- checkState(key: string): boolean;
- link(key: string): void;
- setCurrentState(key: string): void;
- loadComplete(): void;
- update(): void;
- preRender(): void;
- render(): void;
- destroy(): void;
- }
-
- class LinkedListItem {
- next: LinkedListItem;
- prev: LinkedListItem;
- first: LinkedListItem;
- last: LinkedListItem;
- }
-
- class LinkedList extends LinkedListItem {
- total: number;
- add(child: LinkedListItem): LinkedListItem;
- remove(child: LinkedListItem): void;
- callAll(callback: string): void;
- dump(): void;
- }
-
- class Signal {
- memorize: boolean;
- active: boolean;
- validateListener(listener: Function, fnName: string): void;
- has(listener: Function, context?: any): boolean;
- add(listener: Function, listenerContext?: any, priority?: number): Phaser.SignalBinding;
- addOnce(listener: Function, listenerContext?: any, priority?: number): Phaser.SignalBinding;
- remove(listener: Function, context?: any): Function;
- removeAll(): void;
- getNumListeners(): number;
- halt(): void;
- dispatch(...params: any[]): void;
- forget(): void;
- dispose(): void;
- toString(): string;
- }
-
- class SignalBinding {
- constructor(signal: Phaser.Signal, listener: Function, isOnce: boolean, listenerContext: Object, priority?: number);
- context: Object;
- active: boolean;
- params: Array;
- execute(paramsArr?: Array): void;
- detach(): Function;
- isBound(): boolean;
- isOnce(): boolean;
- getListener(): Function;
- getSignal(): Phaser.Signal;
- toString(): string;
- }
-
- class StateCycle {
- preUpdate(): void;
- update(): void;
- render(): void;
- postRender(): void;
- destroy(): void;
- }
-
- class Plugin extends StateCycle {
- constructor(game: Phaser.Game, parent: any);
- game: Phaser.Game;
- parent: any;
- active: boolean;
- visible: boolean;
- hasPreUpdate: boolean;
- hasUpdate: boolean;
- hasRender: boolean;
- hasPostRender: boolean;
- }
-
- class PluginManager extends StateCycle {
- constructor(game: Phaser.Game, parent: any);
- game: Phaser.Game;
- private _parent: any;
- plugins: Phaser.Plugin[];
- add(plugin: Phaser.Plugin): Phaser.Plugin;
- remove(plugin: Phaser.Plugin): void;
- }
-
- class Stage {
- constructor(game: Phaser.Game, width: number, height: number);
- game: Phaser.Game;
- offset: Phaser.Point;
- canvas: HTMLCanvasElement;
- scaleMode: number;
- scale: Phaser.StageScaleMode;
- aspectRatio: number;
- backgroundColor: string;
- disableVisibilityChange: boolean;
- boot(): void;
- visibilityChange(event: Event): void;
- }
-
- class Group {
- constructor(game: Phaser.Game, parent: any, name: string, useStage: boolean);
- game: Phaser.Game;
- name: string;
- type: number;
- exists: boolean;
- sortIndex: string;
- length: number;
- x: number;
- y: number;
- angle: number;
- rotation: number;
- visible: boolean;
- add(child: any): any;
- addAt(child: any, index: number): any;
- getAt(index: number): any;
- create(x: number, y: number, key: string, frame: string, exists?: boolean): any;
- swap(child1: any, child2: any): boolean;
- bringToTop(child: any): any;
- getIndex(child: any): number;
- replace(oldChild: any, newChild: any): void;
- setProperty(child: any, key: string[], value: string, operation: number): void;
- setAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void;
- subAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void;
- multiplyAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void;
- divideAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void;
- callAllExists(callback: Function, callbackContext: Object, existsValue: boolean): void;
- callAll(callback: string, callbackContext?: Object): void;
- forEach(callback: Function, callbackContext: Object, checkExists: boolean): void;
- forEachAlive(callback: Function, callbackContext: Object): void;
- forEachDead(callback: Function, callbackContext: Object): void;
- getFirstExists(state: boolean): any;
- getFirstAlive(): any;
- getFirstDead(): any;
- countLiving(): number;
- countDead(): number;
- getRandom(startIndex: number, length: number): any;
- remove(child: any): void;
- removeAll(): void;
- removeBetween(startIndex: number, endIndex: number): void;
- destroy(): void;
- dump(full: boolean): void;
- }
-
- class World {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- bounds: Phaser.Rectangle;
- camera: Phaser.Camera;
- currentRenderOrderID: number;
- group: Phaser.Group;
- width: number;
- height: number;
- centerX: number;
- centerY: number;
- randomX: number;
- randomY: number;
- boot(): void;
- update(): void;
- setSize(width: number, height: number): void;
- destroy(): void;
- }
-
- class Game {
- constructor(width: number, height: number, renderer: number, parent: string, state: Object, transparent: boolean, antialias: boolean);
- id: number;
- width: number;
- height: number;
- renderer: number;
- transparent: boolean;
- antialias: boolean;
- parent: string;
- state: Phaser.StateManager;
- renderType: number;
- isBooted: boolean;
- raf: Phaser.RequestAnimationFrame;
- add: Phaser.GameObjectFactory;
- cache: Phaser.Cache;
- input: Phaser.Input;
- load: Phaser.Loader;
- math: Phaser.Math;
- sound: Phaser.SoundManager;
- stage: Phaser.Stage;
- time: Phaser.Time;
- tweens: Phaser.TweenManager;
- world: Phaser.World;
- physics: Phaser.Physics.Arcade;
- rnd: Phaser.RandomDataGenerator;
- device: Phaser.Device;
- camera: Phaser.Camera;
- canvas: HTMLCanvasElement;
- context: Object;
- debug: Phaser.Utils.Debug;
- particles: Phaser.Particles;
- _paused: boolean;
- paused: boolean;
- boot(): void;
- setUpRenderer(): void;
- loadComplete(): void;
- update(): void;
- destroy(): void;
- }
-
- class Input {
- constructor(game: Phaser.Game);
- static MOUSE_OVERRIDES_TOUCH: number;
- static TOUCH_OVERRIDES_MOUSE: number;
- static MOUSE_TOUCH_COMBINE: number;
- id: number;
- active: boolean;
- game: Phaser.Game;
- hitCanvas: any;
- hitContext: any;
- pollRate: number;
- disabled: boolean;
- multiInputOverride: number;
- position: Phaser.Point;
- speed: Phaser.Point;
- circle: Phaser.Circle;
- scale: Phaser.Point;
- maxPointers: number;
- currentPointers: number;
- tapRate: number;
- doubleTapRate: number;
- holdRate: number;
- justPressedRate: number;
- justReleasedRate: number;
- recordPointerHistory: boolean;
- recordRate: number;
- recordLimit: number;
- x: number;
- y: number;
- totalInactivePointers: number;
- totalActivePointers: number;
- worldX: number;
- worldY: number;
- pollLocked: boolean;
- pointer1: Phaser.Pointer;
- pointer2: Phaser.Pointer;
- pointer3: Phaser.Pointer;
- pointer4: Phaser.Pointer;
- pointer5: Phaser.Pointer;
- pointer6: Phaser.Pointer;
- pointer7: Phaser.Pointer;
- pointer8: Phaser.Pointer;
- pointer9: Phaser.Pointer;
- pointer10: Phaser.Pointer;
- activePointer: Phaser.Pointer;
- mousePointer: Phaser.Pointer;
- mouse: Phaser.Mouse;
- keyboard: Phaser.Keyboard;
- touch: Phaser.Touch;
- mspointer: Phaser.MSPointer;
- interactiveItems: Phaser.LinkedList;
- onDown: Phaser.Signal;
- onUp: Phaser.Signal;
- onTap: Phaser.Signal;
- onHold: Phaser.Signal;
- boot(): void;
- update(): void;
- reset(hard?: boolean);
- resetSpeed(x: number, y: number);
- startPointer(event: Event): Phaser.Pointer;
- updatePointer(event: Event): Phaser.Pointer;
- stopPointer(event: Event): Phaser.Pointer;
- getPointer(state: boolean): Phaser.Pointer;
- getPointerFromIdentifier(identifier: number): Phaser.Pointer;
- addPointer(): Phaser.Pointer;
- }
-
- class Keyboard {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- disabled: boolean;
- static A: number;
- static B: number;
- static C: number;
- static D: number;
- static E: number;
- static F: number;
- static G: number;
- static H: number;
- static I: number;
- static J: number;
- static K: number;
- static L: number;
- static M: number;
- static N: number;
- static O: number;
- static P: number;
- static Q: number;
- static R: number;
- static S: number;
- static T: number;
- static U: number;
- static V: number;
- static W: number;
- static X: number;
- static Y: number;
- static Z: number;
- static ZERO: number;
- static ONE: number;
- static TWO: number;
- static THREE: number;
- static FOUR: number;
- static FIVE: number;
- static SIX: number;
- static SEVEN: number;
- static EIGHT: number;
- static NINE: number;
- static NUMPAD_0: number;
- static NUMPAD_1: number;
- static NUMPAD_2: number;
- static NUMPAD_3: number;
- static NUMPAD_4: number;
- static NUMPAD_5: number;
- static NUMPAD_6: number;
- static NUMPAD_7: number;
- static NUMPAD_8: number;
- static NUMPAD_9: number;
- static NUMPAD_MULTIPLY: number;
- static NUMPAD_ADD: number;
- static NUMPAD_ENTER: number;
- static NUMPAD_SUBTRACT: number;
- static NUMPAD_DECIMAL: number;
- static NUMPAD_DIVIDE: number;
- static F1: number;
- static F2: number;
- static F3: number;
- static F4: number;
- static F5: number;
- static F6: number;
- static F7: number;
- static F8: number;
- static F9: number;
- static F10: number;
- static F11: number;
- static F12: number;
- static F13: number;
- static F14: number;
- static F15: number;
- static COLON: number;
- static EQUALS: number;
- static UNDERSCORE: number;
- static QUESTION_MARK: number;
- static TILDE: number;
- static OPEN_BRACKET: number;
- static BACKWARD_SLASH: number;
- static CLOSED_BRACKET: number;
- static QUOTES: number;
- static BACKSPACE: number;
- static TAB: number;
- static CLEAR: number;
- static ENTER: number;
- static SHIFT: number;
- static CONTROL: number;
- static ALT: number;
- static CAPS_LOCK: number;
- static ESC: number;
- static SPACEBAR: number;
- static PAGE_UP: number;
- static PAGE_DOWN: number;
- static END: number;
- static HOME: number;
- static LEFT: number;
- static UP: number;
- static RIGHT: number;
- static DOWN: number;
- static INSERT: number;
- static DELETE: number;
- static HELP: number;
- static NUM_LOCK: number;
- start(): void;
- stop(): void;
- addKeyCapture(keycode: any): void;
- removeKeyCapture(keycode: number): void;
- clearCaptures(): void;
- onKeyDown(event: any): void;
- onKeyUp(event: any): void;
- reset(): void;
- justPressed(keycode: number, duration?: number): boolean;
- justReleased(keycode: number, duration?: number): boolean;
- isDown(keycode: number): boolean;
- }
-
- class Mouse {
- constructor(game: Phaser.Game)
- game: Phaser.Game;
- callbackContext: Object;
- disabled: boolean;
- locked: boolean;
- static LEFT_BUTTON: number;
- static MIDDLE_BUTTON: number;
- static RIGHT_BUTTON: number;
- mouseDownCallback(): void;
- mouseMoveCallback(): void;
- mouseUpCallback(): void;
- start(): void;
- onMouseDown(): void;
- onMouseUp(): void;
- onMouseMove(): void;
- requestPointerLock(): void;
- pointerLockChange(): void;
- releasePointerLock(): void;
- stop();
- }
-
- class MSPointer {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- callbackContext: Object;
- disabled: boolean;
- mouseDownCallback(): void;
- mouseMoveCallback(): void;
- mouseUpCallback(): void;
- start(): void;
- onPointerDown(): void;
- onPointerUp(): void;
- onPointerMove(): void;
- stop(): void;
- }
-
- class Pointer {
- constructor(game: Phaser.Game, id: number);
- game: Phaser.Game;
- id: number;
- active: boolean;
- positionDown: Phaser.Point;
- position: Phaser.Point;
- circle: Phaser.Circle;
- withinGame: boolean;
- clientX: number;
- clientY: number;
- pageX: number;
- pageY: number;
- screenX: number;
- screenY: number;
- duation: number;
- worldX: number;
- worldY: number;
- x: number;
- y: number;
- isMouse: boolean;
- isDown: boolean;
- isUp: boolean;
- timeDown: number;
- timeUp: number;
- previousTapTime: number;
- totalTouches: number;
- msSinceLastClick: number;
- targetObject: any;
- start(event: any): Phaser.Pointer;
- update(): void;
- move(event: any): void;
- leave(event: any): void;
- stop(event: any): void;
- justPressed(duration?: number): boolean;
- justReleased(duration?: number): boolean;
- reset(): void;
- toString(): string;
- }
-
- class Touch {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- callbackContext: any;
- touchStartCallback: Function;
- touchMoveCallback: Function;
- touchEndCallback: Function;
- touchEnterCallback: Function;
- touchLeaveCallback: Function;
- touchCancelCallback: Function;
- preventDefault: boolean;
- disabled: boolean;
- start(): void;
- consumeDocumentTouches(): void;
- onTouchStart(event: any): void;
- onTouchCancel(event: any): void;
- onTouchEnter(event: any): void;
- onTouchLeave(event: any): void;
- onTouchMove(event: any): void;
- onTouchEnd(event: any): void;
- stop(): void;
- }
-
- class InputHandler extends LinkedListItem {
- constructor(sprite: Phaser.Sprite);
- game: Phaser.Game;
- sprite: Phaser.Sprite;
- enabled: boolean;
- priorityID: number;
- useHandCursor: boolean;
- isDragged: boolean;
- allowHorizontalDrag: boolean;
- allowVerticalDrag: boolean;
- bringToTop: boolean;
- snapOffset: number;
- snapOnDrag: boolean;
- snapOnRelease: boolean;
- snapX: number;
- snapY: number;
- pixelPerfect: boolean;
- pixelPerfectAlpha: number;
- draggable: boolean;
- boundsSprite: Phaser.Sprite;
- consumePointerEvent: boolean;
- start(priority: number, useHandCursor: boolean): void;
- reset(): void;
- stop(): void;
- destroy(): void;
- pointerX(pointer: number): number;
- pointerY(pointer: number): number;
- pointerDown(pointer: number): boolean;
- pointerUp(pointer: number): boolean;
- pointerTimeDown(pointer: number): number;
- pointerTimeUp(pointer: number): number;
- pointerOver(pointer: number): boolean;
- pointerOut(pointer: number): boolean;
- pointerTimeOver(pointer: number): number;
- pointerTimeOut(pointer: number): number;
- pointerDragged(pointer: number): boolean;
- checkPointerOver(pointer: number): boolean;
- checkPixel(x: number, y: number): boolean;
- update(pointer: number): void;
- updateDrag(pointer: number): boolean;
- justOver(pointer: number, delay: number): boolean;
- justOut(pointer: number, delay: number): boolean;
- justPressed(pointer: number, delay: number): boolean;
- justReleased(pointer: number, delay: number): boolean;
- overDuration(pointer: number): number;
- downDuration(pointer: number): number;
- enableDrag(lockCenter: boolean, bringToTop: boolean, pixelPerfect: boolean, alphaThreshold?: number, boundsRect?: Phaser.Rectangle, boundsSprite?: Phaser.Rectangle): void;
- disableDrag(): void;
- startDrag(): void;
- stopDrag(): void;
- setDragLock(allowHorizontal: boolean, allowVertical: boolean): void;
- enableSnap(snapX: number, snapY: number, onDrag?: boolean, onRelease?: boolean): void;
- disableSnap(): void;
- checkBoundsRect(): void;
- checkBoundsSprite(): void;
- }
-
- class Event {
- constructor(sprite: Phaser.Sprite);
- parent: Phaser.Sprite;
- onAddedToGroup: Phaser.Signal;
- onRemovedFromGroup: Phaser.Signal;
- onKilled: Phaser.Signal;
- onRevived: Phaser.Signal;
- onOutOfBounds: Phaser.Signal;
- onInputOver: Phaser.Signal;
- onInputOut: Phaser.Signal;
- onInputDown: Phaser.Signal;
- onInputUp: Phaser.Signal;
- onDragStart: Phaser.Signal;
- onDragStop: Phaser.Signal;
- onAnimationStart: Phaser.Signal;
- onAnimationComplete: Phaser.Signal;
- onAnimationLoop: Phaser.Signal;
- }
-
- class GameObjectFactory {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- world: Phaser.World;
- existing(object: any): boolean;
- sprite(x: number, y: number, key?: string, frame?: any): Phaser.Sprite;
- child(parent: any, x: number, y: number, key?: string, frame?: number): Phaser.Sprite;
- tween(obj: Object): Phaser.Tween;
- group(parent?: any, name?: string): Phaser.Group;
- audio(key: string, volume?: number, loop?: boolean): Phaser.Sound;
- tileSprite(x: number, y: number, width: number, height: number, key?: string, frame?: number): Phaser.TileSprite;
- text(x: number, y: number, text: string, style: any): Phaser.Text;
- button(x: number, y: number, key: string, callback: Function, callbackContext: Object, overFrame?: any, outFrame?: any, downFrame?: any): Phaser.Button;
- graphics(x: number, y: number): Phaser.Graphics;
- emitter(x: number, y: number, maxParticles: number): Phaser.Particles.Arcade.Emitter;
- bitmapText(x: number, y: number, text: string, style: string): Phaser.BitmapText;
- tilemap(x: number, y: number, key: string, resizeWorld: boolean, tileWidth: number, tileHeight: number): Phaser.Tilemap;
- renderTexture(key: string, width: number, height: number): Phaser.RenderTexture;
- }
-
- class Sprite {
- constructor(game: Phaser.Game, x: number, y: number, key: string, frame: number);
- game: Phaser.Game;
- exists: boolean;
- alive: boolean;
- group: Phaser.Group;
- name: string;
- type: number;
- renderOrderID: number;
- lifespan: number;
- events: Phaser.Event[];
- animations: Phaser.AnimationManager;
- input: Phaser.InputHandler;
- key: string;
- currentFrame: number;
- anchor: Phaser.Point;
- x: number;
- y: number;
- position: Phaser.Point;
- autoCull: boolean;
- scale: Phaser.Point;
- scrollFactor: Phaser.Point;
- offset: Phaser.Point;
- center: Phaser.Point;
- topLeft: Phaser.Point;
- topRight: Phaser.Point;
- bottomRight: Phaser.Point;
- bottomLeft: Phaser.Point;
- bounds: Phaser.Rectangle;
- body: Phaser.Physics.Arcade.Body;
- velocity: number;
- acceleration: number;
- inWorld: boolean;
- inWorldThreshold: number;
- angle: number;
- frame: number;
- frameName: string;
- inCamera: boolean;
- crop: boolean;
- cropEnabled: boolean;
- inputEnabled: boolean;
- preUpdate(): void;
- postUpdate(): void;
- centerOn(x: number, y: number): void;
- revive(): void;
- kill(): void;
- reset(x: number, y: number): void;
- updateBounds(): void;
- getLocalPosition(p: Phaser.Point, x: number, y: number): Phaser.Point;
- getLocalUnmodifiedPosition(p: Phaser.Point, x: number, y: number): Phaser.Point;
- bringToTop(): void;
- getBounds(rect: Phaser.Rectangle): Phaser.Rectangle;
- }
-
- class TileSprite {
- constructor(game: Phaser.Game, x: number, y: number, width: number, height: number, key?: string, frame?: number);
- texture: Phaser.RenderTexture;
- type: number;
- tileScale: Phaser.Point;
- tilePosition: Phaser.Point;
- }
-
- class Text {
- constructor(game: Phaser.Game, x: number, y: number, text: string, style: string);
- exists: boolean;
- alive: boolean;
- group: Phaser.Group;
- content: string;
- name: string;
- game: Phaser.Game;
- type: number;
- text: string;
- angle: number;
- style: string;
- visible: boolean;
- position: Phaser.Point;
- anchor: Phaser.Point;
- scale: Phaser.Point;
- scrollFactor: Phaser.Point;
- renderable: boolean;
- update(): void;
- }
-
- class BitmapText extends Phaser.Text {
- }
-
- class Button {
- constructor(game: Phaser.Game, x: number, y: number, key: string, callback: Function, overFrame: number, outFrame: number, downFrame: number);
- input: Phaser.InputHandler;
- onInputUp: Phaser.Signal;
- onInputDown: Phaser.Signal;
- onInputOut: Phaser.Signal;
- onInputOver: Phaser.Signal;
- events: Phaser.Event[];
- setFrames(overFrame?: number, outFrame?: number, downFrame?: number): void;
- onInputOverHandler(pointer: Phaser.Pointer): void;
- onInputUpHandler(pointer: Phaser.Pointer): void;
- onInputDownHandler(pointer: Phaser.Pointer): void;
- onInputOutHandler(pointer: Phaser.Pointer): void;
- }
-
- class Graphics extends Phaser.Sprite {
- constructor(game: Phaser.Game, x: number, y: number);
- angle: number;
- }
-
- class RenderTexture {
- constructor(game: Phaser.Game, key: string, width: number, height: number);
- name: string;
- type: number;
- }
-
- class Canvas {
- create(width: number, height: number): HTMLCanvasElement;
- getOffset(element: HTMLElement, point?: Phaser.Point): Phaser.Point;
- getAspectRatio(canvas: HTMLCanvasElement): number;
- setBackgroundColor(canvas: HTMLCanvasElement, color: string): HTMLCanvasElement;
- setTouchAction(canvas: HTMLCanvasElement, value: string): HTMLCanvasElement;
- addToDOM(canvas: HTMLCanvasElement, parent: string, overflowHidden: boolean): HTMLCanvasElement;
- setTransform(context: CanvasRenderingContext2D, translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number): CanvasRenderingContext2D;
- setSmoothingEnabled(context: CanvasRenderingContext2D, value: boolean): CanvasRenderingContext2D;
- setImageRenderingCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement;
- setImageRenderingBicubic(canvas: HTMLCanvasElement): HTMLCanvasElement;
- }
-
- class StageScaleMode {
- constructor(game: Phaser.Game, width: number, height: number);
- static EXACT_FIT: number;
- static NO_SCALE: number;
- static SHOW_ALL: number;
- forceLandscape: boolean;
- forcePortrait: boolean;
- incorrectOrientation: boolean;
- pageAlignHorizontally: boolean;
- pageAlignVeritcally: boolean;
- minWidth: number;
- maxWidth: number;
- minHeight: number;
- maxHeight: number;
- width: number;
- height: number;
- maxIterations: number;
- game: Phaser.Game;
- enterLandscape: Phaser.Signal;
- enterPortrait: Phaser.Signal;
- orientation: number;
- scaleFactor: Phaser.Point;
- aspectRatio: number;
- isFullScreen: boolean;
- isPortrait: boolean;
- isLandscape: boolean;
- startFullScreen(): void;
- stopFullScreen(): void;
- checkOrientationState(): void;
- checkOrientation(): void;
- checkResize(event: any): void;
- refresh(): void;
- setScreenSize(force: boolean): void;
- setSize(): void;
- setMaximum(): void;
- setShowAll(): void;
- setExactFit(): void;
- }
-
- class Device {
- patchAndroidClearRect: boolean;
- desktop: boolean;
- iOS: boolean;
- android: boolean;
- chromeOS: boolean;
- linux: boolean;
- macOS: boolean;
- windows: boolean;
- canvas: boolean;
- file: boolean;
- fileSystem: boolean;
- localStorage: boolean;
- webGL: boolean;
- worker: boolean;
- touch: boolean;
- mspointer: boolean;
- css3D: boolean;
- pointerLock: boolean;
- arora: boolean;
- chrome: boolean;
- epiphany: boolean;
- firefox: boolean;
- ie: boolean;
- ieVersion: number;
- mobileSafari: boolean;
- midori: boolean;
- opera: boolean;
- safari: boolean;
- webApp: boolean;
- audioData: boolean;
- webAudio: boolean;
- ogg: boolean;
- opus: boolean;
- mp3: boolean;
- wav: boolean;
- m4a: boolean;
- webm: boolean;
- iPhone: boolean;
- iPhone4: boolean;
- iPad: boolean;
- pixelRatio: number;
- canPlayAudio(type: string): boolean;
- isConsoleOpen(): boolean;
- }
-
- class RequestAnimationFrame {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- isRunning: boolean;
- start(): boolean;
- updateRAF(time: number): void;
- updateSetTimeout(): void;
- stop(): void;
- isSetTimeOut(): boolean;
- isRAF(): boolean;
- }
-
- class RandomDataGenerator {
- constructor(seeds: Array);
- c: number;
- s0: number;
- s1: number;
- s2: number;
- rnd(): number;
- sow(seeds: Array): void;
- hash(data: any): number;
- integer(): number;
- frac(): number;
- real(): number;
- integerInRange(min: number, max: number): number;
- realInRange(min: number, max: number): number;
- normal(): number;
- uuid(): number;
- pick(ary: number[]): number;
- weightedPick(ary: number[]): number;
- timestamp(a?: number, b?: number): number;
- angle(): number;
- }
-
- class Math {
- static PI2: number;
- static fuzzyEqual(a: number, b: number, epsilon?: number): boolean;
- static fuzzyLessThan(a: number, b: number, epsilon?: number): boolean;
- static fuzzyGreaterThan(a: number, b: number, epsilon?: number): boolean;
- static fuzzyCeil(a: number, b: number, epsilon?: number): boolean;
- static fuzzyFloor(a: number, b: number, epsilon?: number): boolean;
- static average(...numbers: number[]): number;
- static truncate(n: number): number;
- static shear(n: number): number;
- static snapTo(input: number, gap: number, start?: number): number;
- static snapToFloor(input: number, gap: number, start?: number): number;
- static snapToCeil(input: number, gap: number, start?: number): number;
- static snapToInArray(input: number, arr: number[], sort?: boolean): number;
- static roundTo(value: number, place?: number, base?: number): number;
- static floorTo(value: number, place?: number, base?: number): number;
- static ceilTo(value: number, place?: number, base?: number): number;
- static interpolateFloat(a: number, b: number, weight: number): number;
- static angleBetween(x1: number, y1: number, x2: number, y2: number): number;
- static normalizeAngle(angle: number, radians?: boolean): number;
- static nearestAngleBetween(a1: number, a2: number, radians?: boolean): number;
- static interpolateAngles(a1: number, a2: number, weight: number, radians?: boolean, ease?: any): number;
- static chanceRoll(chance?: number): boolean;
- static numberArray(min: number, max: number): number[];
- static maxAdd(value: number, amount: number, max: number): number;
- static minSub(value: number, amount: number, min: number): number;
- static wrap(value: number, min: number, max: number): number;
- static wrapValue(value: number, amount: number, max: number): number;
- static randomSign(): number;
- static isOdd(n: number): boolean;
- static isEven(n: number): boolean;
- static max(...numbers: number[]): number;
- static min(...numbers: number[]): number;
- static wrapAngle(angle: number): number;
- static angleLimit(angle: number, min: number, max: number): number;
- static linearInterpolation(v: number[], k: number): number;
- static bezierInterpolation(v: number[], k: number): number;
- static catmullRomInterpolation(v: number[], k: number): number;
- static linear(p0: number, p1: number, t: number): number;
- static bernstein(n: number, i: number): number;
- static catmullRom(p0: number, p1: number, p2: number, p3: number, t: number): number;
- static difference(a: number, b: number): number;
- static getRandom(objects: Object[], startIndex?: number, length?: number): Object;
- static floor(value: number): number;
- static ceil(value: number): number;
- static sinCosGenerator(length: number, sinAmplitude?: number, cosAmplitude?: number, frequency?: number): { sin: number[]; cos: number[]; };
- static shift(stack: Array): any;
- static shuffleArray(array: Array): Array;
- static distance(x1: number, y1: number, x2: number, y2: number): number;
- static distanceRounded(x1: number, y1: number, x2: number, y2: number): number;
- static clamp(x: number, a: number, b: number): number;
- static clampBottom(x: number, a: number): number;
- static mapLinear(x: number, a1: number, a2: number, b1: number, b2: number): number;
- static smoothstep(x: number, min: number, max: number): number;
- static smootherstep(x: number, min: number, max: number): number;
- static sign(x: number): number;
- static degToRad(degrees: number): number;
- static radToDeg(radians: number): number;
- }
-
- class QuadTree {
- constructor(physicsManager: Phaser.Physics.Arcade, x: number, y: number, width: number, height: number, maxObject?: number, maxLevels?: number, level?: number);
- physicsManager: Phaser.Physics.Arcade;
- ID: number;
- maxObjects: number;
- maxLevels: number;
- level: number;
- bounds: {
- x: number;
- y: number;
- width: number;
- height: number;
- subWidth: number;
- subHeight: number;
- right: number;
- bottom: number;
- };
- objects: Array;
- nodes: Array;
- split(): void;
- insert(body: Object): void;
- getIndex(rect: Object): number;
- retrieve(sprite: Object): Array;
- clear(): void;
- }
-
- class Circle {
- constructor(x?: number, y?: number, diameter?: number);
- x: number;
- y: number;
- diameter: number;
- radius: number;
- left: number;
- right: number;
- top: number;
- bottom: number;
- area: number;
- empty: boolean;
- circumference(): number;
- setTo(x: number, y: number, diameter: number): Circle;
- copyFrom(source: any): Circle;
- copyTo(dest: Object): Object;
- distance(dest: Object, round: boolean): number;
- clone(out: Phaser.Circle): Phaser.Circle;
- contains(x: number, y: number): Phaser.Circle;
- circumferencePoint(angle: number, asDegrees: number, output?: Phaser.Point): Phaser.Point;
- offset(dx: number, dy: number): Phaser.Circle;
- offsetPoint(point: Phaser.Point): Phaser.Circle;
- toString(): string;
- static contains(a: Phaser.Circle, x: number, y: number): boolean;
- static equals(a: Phaser.Circle, b: Phaser.Circle): boolean;
- static intersects(a: Phaser.Circle, b: Phaser.Circle): boolean;
- static circumferencePoint(a: Phaser.Circle, angle: number, asDegrees: boolean, output?: Phaser.Point): Phaser.Point;
- static intersectsRectangle(c: Phaser.Circle, r: Phaser.Rectangle): boolean;
- }
-
- class Point {
- constructor(x: number, y: number);
- x: number;
- y: number;
- copyFrom(source: any): Phaser.Point;
- invert(): Phaser.Point;
- setTo(x: number, y: number): Phaser.Point;
- add(x: number, y: number): Phaser.Point;
- subtract(x: number, y: number): Phaser.Point;
- multiply(x: number, y: number): Phaser.Point;
- divide(x: number, y: number): Phaser.Point;
- clampX(min: number, max: number): Phaser.Point;
- clampY(min: number, max: number): Phaser.Point;
- clamp(min: number, max: number): Phaser.Point;
- clone(output: Phaser.Point): Phaser.Point;
- copyTo(dest: any): Object;
- distance(dest: Object, round?: boolean): number;
- equals(a: Phaser.Point): boolean;
- rotate(x: number, y: number, angle: number, asDegrees: boolean, distance: number): Phaser.Point;
- toString(): string;
- static add(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point;
- static subtract(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point;
- static multiply(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point;
- static divide(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point;
- static equals(a: Phaser.Point, b: Phaser.Point): boolean;
- static distance(a: Phaser.Point, b: Phaser.Point, round: boolean): number;
- static rotate(a: Phaser.Point, x: number, y: number, angle: number, asDegrees: boolean, distance: boolean): Phaser.Point;
- }
-
- class Rectangle {
- constructor(x: number, y: number, width: number, height: number);
- x: number;
- y: number;
- width: number;
- height: number;
- halfWidth: number;
- halfHeight: number;
- bottom: number;
- bottomRight: Phaser.Point;
- left: number;
- right: number;
- volume: number;
- perimeter: number;
- centerX: number;
- centerY: number;
- top: number;
- topLeft: Phaser.Point;
- empty: boolean;
- offset(dx: number, dy: number): Phaser.Rectangle;
- offsetPoint(point: Phaser.Point): Phaser.Rectangle;
- setTo(x: number, y: number, width: number, height: number): Phaser.Rectangle;
- floor(): void;
- copyFrom(source: any): Phaser.Rectangle;
- copyTo(dest: any): Object;
- inflate(dx: number, dy: number): Phaser.Rectangle;
- size(output: Phaser.Point): Phaser.Point;
- clone(output: Phaser.Rectangle): Phaser.Rectangle;
- contains(x: number, y: number): boolean;
- containsRect(b: Phaser.Rectangle): boolean;
- equals(b: Phaser.Rectangle): boolean;
- intersection(b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle;
- intersects(b: Phaser.Rectangle, tolerance: number): boolean;
- intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number): boolean;
- union(b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle;
- toString(): string;
- static inflate(a: Phaser.Rectangle, dx: number, dy: number): Phaser.Rectangle;
- static inflatePoint(a: Phaser.Rectangle, point: Phaser.Point): Phaser.Rectangle;
- static size(a: Phaser.Rectangle, output: Phaser.Point): Phaser.Point;
- static clone(a: Phaser.Rectangle, output: Phaser.Rectangle): Phaser.Rectangle;
- static contains(a: Phaser.Rectangle, x: number, y: number): boolean;
- static containsPoint(a: Phaser.Rectangle, point: Phaser.Point): boolean;
- static containsRect(a: Phaser.Rectangle, b: Phaser.Rectangle): boolean;
- static equals(a: Phaser.Rectangle, b: Phaser.Rectangle): boolean;
- static intersection(a: Phaser.Rectangle, b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle;
- static intersects(a: Phaser.Rectangle, b: Phaser.Rectangle, tolerance: number): boolean;
- static intersectsRaw(a: Phaser.Rectangle, left: number, right: number, top: number, bottom: number, tolerance: number): boolean;
- static union(a: Phaser.Rectangle, b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle;
- }
-
- class Net {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- getHostName(): string;
- checkDomainName(domain: string): string;
- updateQueryString(key: string, value: any, redirect?: boolean, url?: string): string;
- getQueryString(parameter?: string): string;
- decodeURI(value: string): string;
- }
-
- class TweenManager {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- REVISION: string;
- getAll(): Phaser.Tween[];
- removeAll(): void;
- add(tween: Phaser.Tween): Phaser.Tween;
- create(object: Object): Phaser.Tween;
- remove(tween: Phaser.Tween): void;
- update(): boolean;
- pauseAll(): void;
- resumeAll(): void;
- }
-
- class Tween {
- constructor(object: Object, game: Phaser.Game);
- game: Phaser.Game;
- pending: boolean;
- pendingDelete: boolean;
- onStart: Phaser.Signal;
- onComplete: Phaser.Signal;
- isRunning: boolean;
- to(properties: Object, duration?: number, ease?: any, autoStart?: boolean, delay?: number, loop?: boolean): Phaser.Tween;
- start(time: number): Phaser.Tween;
- stop(): Phaser.Tween;
- delay(amount: number): Phaser.Tween;
- repeat(times: number): Phaser.Tween;
- yoyo(yoyo: boolean): Phaser.Tween;
- easing(easing: any): Phaser.Tween;
- interpolation(interpolation: Function): Phaser.Tween;
- chain(...tweens: Phaser.Tween[]): Phaser.Tween;
- loop(): Phaser.Tween;
- onStartCallback(callback: Function): Phaser.Tween;
- onUpdateCallback(callback: Function): Phaser.Tween;
- onCompleteCallback(callback: Function): Phaser.Tween;
- pause(): void;
- resume(): void;
- update(time: number): boolean;
- }
-
- class Easing {
- Linear: {
- None: (k: number) => number;
- };
- Quadratic: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Cubic: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Quartic: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Quintic: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Sinusoidal: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Exponential: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Circular: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Elastic: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Back: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- Bounce: {
- In: (k: number) => number;
- Out: (k: number) => number;
- InOut: (k: number) => number;
- };
- }
-
- class Time {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- physicsElapsed: number;
- time: number;
- pausedTime: number;
- now: number;
- elapsed: number;
- fps: number;
- fpsMin: number;
- fpsMax: number;
- msMin: number;
- msMax: number;
- frames: number;
- pauseDuration: number;
- timeToCall: number;
- lastTime: number;
- totalElapsedSeconds(): number;
- update(time: number): number;
- gamePaused(): void;
- gameResumed(): void;
- elapsedSince(since: number): number;
- elapsedSecondsSince(since: number): number;
- reset(): void;
- }
-
- class AnimationManager {
- constructor(sprite);
- sprite: Phaser.Sprite;
- game: Phaser.Game;
- currentFrame: Phaser.Animation.Frame;
- updateIfVisible: boolean;
- frameData: Phaser.Animation.FrameData;
- frameTotal: number;
- frame: number;
- frameName: string;
- loadFrameData(frameData: Phaser.Animation.FrameData): void;
- add(name: string, frames?: Array, frameRate?: number, loop?: boolean, useNumericIndex?: boolean): Phaser.Animation;
- validateFrames(frames: Array, useNumericIndex?: boolean): boolean;
- play(name: string, frameRate?: number, loop?: boolean): Phaser.Animation;
- stop(name?: string, resetFrame?: boolean): void;
- update(): boolean;
- destroy(): void;
- }
-
- class Animation {
- constructor(game: Phaser.Game, parent: Phaser.Sprite, name: string, frameData: Phaser.Animation.FrameData, frames: any[], delay: number, looped: boolean);
- game: Phaser.Game;
- name: string;
- delay: number;
- looped: boolean;
- isFinished: boolean;
- isPlaying: boolean;
- currentFrame: Phaser.Animation.Frame;
- frameTotal: number;
- frame: number;
- play(frameRate?: number, loop?: boolean): Phaser.Animation;
- restart(): void;
- stop(resetFrame?: boolean): void;
- update(): boolean;
- destroy(): void;
- onComplete(): void;
- }
-
- module Animation {
- class Frame {
- constructor(index: number, x: number, y: number, width: number, height: number, name: string, uuid: string);
- index: number;
- x: number;
- y: number;
- width: number;
- height: number;
- centerX: number;
- centerY: number;
- distance: number;
- name: string;
- uuid: string;
- rotated: boolean;
- rotationDirection: string;
- trimmed: boolean;
- sourceSizeW: number;
- sourceSizeH: number;
- spriteSourceSizeX: number;
- spriteSourceSizeY: number;
- spriteSourceSizeW: number;
- spriteSourcesizeH: number;
- setTrim(trimmed: boolean, actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): void;
- }
-
- class FrameData {
- addFrame(frame: Frame): Frame;
- getFrame(index: number): Frame;
- getFrameByName(name: string): Frame;
- checkFrame(name: string): boolean;
- getFrameRange(start: number, end: number, output: Array): Array;
- getFrames(frames: Array, useNumericIndex?: boolean, output?: Array): Array;
- getFrameIndexes(frames: Array, useNumericIndex?: boolean, output?: Array): Array;
- total: number;
- }
-
- class Parser {
- spriteSheet(game: Phaser.Game, key: string, frameWidth: number, frameHeight: number, frameMax?: number): Phaser.Animation.FrameData;
- JSONData(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData;
- JSONDataHash(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData;
- XMLData(game: Phaser.Game, xml: Object, cacheKey: string): Phaser.Animation.FrameData;
- }
- }
-
- class Cache {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- onSoundUnlock: Phaser.Signal;
- addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void;
- addRenderTexture(key: string, texture: RenderTexture): void;
- addSpriteSheet(key: string, url: string, data: Object, frameWidth: number, frameHeight: number, frameMax: number): void;
- addTilemap(key: string, url: string, data: Object, mapData: Object, atlasData: Object): void;
- addTextureAtlas(key: string, url: string, data: Object, atlasData: Object): void;
- addBitmapFont(key: string, url: string, data: Object, xmlData: Object): void;
- addDefaultImage(): void;
- addImage(key: string, url: string, data: Object): void;
- addSound(key: string, url: string, data: Object): void;
- reloadSound(key: string): void;
- reloadSoundComplete(key: string): void;
- updateSound(key: string, property: string, value: Phaser.Sound): void;
- decodedSound(key: string, data: Object): void;
- addText(key: string, url: string, data: Object): void;
- getCanvas(key: string): Object;
- checkImageKey(key: string): boolean;
- getImage(key: string): Object;
- getTilemap(key: string): Phaser.Tilemap;
- getFrameData(key: string): Phaser.Animation.FrameData;
- getFrameByIndex(key: string, frame: string): Phaser.Animation.Frame;
- getFrameByName(key: string, frame: string): Phaser.Animation.Frame;
- getFrame(key: string): Phaser.Animation.Frame;
- getTextureFrame(key: string): Phaser.Animation.Frame;
- getTexture(key: string): Phaser.RenderTexture;
- getSound(key: string): Phaser.Sound;
- getSoundData(key: string): Object;
- isSoundDecoded(key: string): boolean;
- isSoundReady(key: string): boolean;
- isSpriteSheet(key: string): boolean;
- getText(key: string): Object;
- getKeys(array: Array): Array;
- getImageKeys(): string[];
- getSoundKeys(): string[];
- getTextKeys(): string[];
- removeCanvas(key: string): void;
- removeImage(key: string): void;
- removeSound(key: string): void;
- removeText(key: string): void;
- destroy(): void;
- }
-
- class Loader {
- static TEXTURE_ATLAS_JSON_ARRAY: number;
- static TEXTURE_ATLAS_JSON_HASH: number;
- static TEXTURE_ATLAS_XML_STARLING: number;
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- queueSize: number;
- isLoading: boolean;
- hasLoaded: boolean;
- progress: number;
- preloadSprite: Phaser.Sprite;
- crossOrigin: string;
- baseURL: string;
- onFileComplete: Phaser.Signal;
- onFileError: Phaser.Signal;
- onLoadStart: Phaser.Signal;
- onLoadComplete: Phaser.Signal;
- setPreloadSprite(sprite: Phaser.Sprite, direction?: number): void;
- checkKeyExists(key: string): boolean;
- reset(): void;
- addToFileList(type: string, key: string, url: string, properties: Array): void;
- image(key: string, url: string, overwrite?: boolean): void;
- text(key: string, url: string, overwrite?: boolean): void;
- spritesheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax: number): void;
- audio(key: string, urls: string[], autoDecode?: boolean): void;
- tilemap(key: string, tilesetURL: string, mapDataURL?: string, mapData?: Object, format?: string): void;
- bitmapFont(key: string, textureURL: string, xmlURL?: string, xmlData?: Object): void;
- atlasJSONArray(key: string, textureURL: string, atlasURL: string, atlasData: Object): void;
- atlasJSONHash(key: string, textureURL: string, atlasURL: string, atlasData: Object): void;
- atlasXML(key: string, textureURL: string, atlasURL: string, atlasData: Object): void;
- atlas(key: string, textureURL: string, atlasURL?: string, atlasData?: Object, format?: number): void;
- removeFile(key: string): void;
- removeAll(): void;
- start(): void;
- loadFile(): void;
- getAudioURL(urls: string[]): string;
- fileError(key: string): void;
- fileComplete(key: string): void;
- jsonLoadComplete(key: string): void;
- csvLoadComplete(key: string): void;
- dataLoadError(key: string): void;
- xmlLoadComplete(key: string): void;
- nextFile(previousKey: string, success: boolean): void;
- }
-
- module Loader {
- class Parser {
- bitmapFont(game: Phaser.Game, xml: Object, cacheKey: Phaser.Animation.FrameData): void;
- }
- }
-
- class Sound {
- constructor(game: Phaser.Game, key: string, volume?: number, loop?: boolean);
- game: Phaser.Game;
- name: string;
- key: string;
- loop: boolean;
- markers: Object;
- context: any;
- autoplay: boolean;
- totalDuration: number;
- startTime: number;
- currentTime: number;
- duration: number;
- stopTime: number;
- paused: boolean;
- isPlaying: boolean;
- currentMarker: string;
- pendingPlayback: boolean;
- override: boolean;
- usingWebAudio: boolean;
- usingAudioTag: boolean;
- onDecoded: Phaser.Signal;
- onPlay: Phaser.Signal;
- onPause: Phaser.Signal;
- onResume: Phaser.Signal;
- onLoop: Phaser.Signal;
- onStop: Phaser.Signal;
- onMute: Phaser.Signal;
- isDecoded: boolean;
- isDecoding: boolean;
- mute: boolean;
- volume: number;
- onMarkerComplete: Phaser.Signal;
- soundHasUnlocked(key: string): void;
- addMarker(name: string, start: number, stop: number, volume?: number, loop?: boolean): void;
- removeMarker(name: string): void;
- update(): void;
- play(marker?: string, position?: number, volume?: number, loop?: boolean): Phaser.Sound;
- restart(marker: string, position: number, volume?: number, loop?: boolean): void;
- pause(): void;
- resume(): void;
- stop(): void;
- }
-
- class SoundManager {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- onSoundDecode: Phaser.Signal;
- context: any;
- usingWebAudio: boolean;
- usingAudioTag: boolean;
- noAudio: boolean;
- touchLocked: boolean;
- channels: number;
- mute: boolean;
- volume: number;
- boot(): void;
- unlock(): void;
- stopAll(): void;
- pauseAll(): void;
- resumeAll(): void;
- decode(key: string, sound?: Phaser.Sound): void;
- update(): void;
- add(key: string, volume: number, loop: boolean): Phaser.Sound;
- }
-
- module Utils {
- class Debug {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- font: string;
- lineHeight: number;
- renderShadow: boolean;
- currentX: number;
- currentY: number;
- currentAlpha: number;
- start(x?: number, y?: number, color?: string): void;
- stop(): void;
- line(text: string, x: number, y: number): void;
- renderQuadTree(quadtree: Phaser.QuadTree, color?: string): void;
- renderSpriteCorners(sprite: Phaser.Sprite, showText?: boolean, showBounds?: boolean, color?: string): void;
- renderSoundInfo(sound: Phaser.Sound, x: number, y: number, color?: string): void;
- renderCameraInfo(camera: Phaser.Camera, x: number, y: number, color?: string): void;
- renderPointer(pointer: Phaser.Pointer, hideIfUp?: boolean, downColor?: string, upColor?: string, color?: string): void;
- renderSpriteInputInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void;
- renderSpriteCollision(sprite: Phaser.Sprite, x: number, y: number, color?: string): void;
- renderInputInfo(x: number, y: number, color?: string): void;
- renderSpriteInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void;
- renderWorldTransformInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void;
- renderLocalTransformInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void;
- renderPointInfo(point: Phaser.Point, x: number, y: number, color?: string): void;
- renderSpriteBody(sprite: Phaser.Sprite, color?: string): void;
- renderSpriteBounds(sprite: Phaser.Sprite, color?: string, fill?: boolean): void;
- renderPixel(x: number, y: number, fillStyle?: string): void;
- renderPoint(point: Phaser.Point, fillStyle?: string): void;
- renderRectangle(rect: Phaser.Rectangle, fillStyle?: string): void;
- renderCircle(circle: Phaser.Circle, fillStyle?: string): void;
- renderText(text: string, x: number, y: number, color?: string, font?: string): void;
- }
- }
-
- class Color {
- getColor32(alpha: number, red: number, green: number, blue: number): number;
- getColor(red: number, green: number, blue: number): number;
- hexToRGB(h: string): number;
- getColorInfo(color: number): string;
- RGBtoHexstring(color: number): string;
- RGBtoWebstring(color: number): string;
- colorToHexstring(color: number): string;
- interpolateColor(color1: number, color2: number, steps: number, currentStep: number, alpha: number): number;
- interpolateColorWithRGB(color: number, r: number, g: number, b: number, steps: number, currentStep: number): number;
- interpolateRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, steps: number, currentStep: number): number;
- getRandomColor(min?: number, max?: number, alpha?: number): number;
- getRGB(color: number): Object;
- getWebRGB(color: number): string;
- getAlpha(color: number): number;
- getAlphaFloat(color: number): number;
- getRed(color: number): number;
- getGreen(color: number): number;
- getBlue(color: number): number;
- }
-
- module Physics {
- class Arcade {
- constructor(game: Phaser.Game)
- game: Phaser.Game;
- gravity: Phaser.Point;
- bounds: Phaser.Rectangle;
- maxObjects: number;
- maxLevels: number;
- OVERLAP_BIAS: number;
- TILE_OVERLAP: number;
- quadTree: Phaser.QuadTree;
- quadTreeID: number;
- updateMotion(body: Phaser.Physics.Arcade.Body);
- computeVelocity(axis: number, body: Phaser.Physics.Arcade.Body, velocity: number, acceleration: number, drag: number, max: number): void;
- preUpdate(): void;
- postUpdate(): void;
- collide(object1: any, object2: any, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
- collideSpriteVsSprite(sprite1: Phaser.Sprite, sprite2: Phaser.Sprite, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
- collideSpriteVsTilemap(sprite1: Phaser.Sprite, tilemap: Phaser.Tilemap, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
- collideSpriteVsGroup(sprite1: Phaser.Sprite, group: Phaser.Group, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
- collideGroupVsTilemap(group: Phaser.Group, tilemap: Phaser.Tilemap, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
- collideGroupVsGroup(group: Phaser.Group, group2: Phaser.Group, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
- separate(body: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): void;
- separateX(body: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): void;
- separateY(body: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): void;
- separateTile(object: Object, x: number, y: number, width: number, height: number, mass: number, collideLeft: boolean, collideRight: boolean, collideUp: boolean, collideDown: boolean, separateX: boolean, separateY: boolean): boolean;
- separateTileX(object: Object, x: number, y: number, width: number, height: number, mass: number, collideLeft: boolean, collideRight: boolean, collideUp: boolean, collideDown: boolean, separateX: boolean, separateY: boolean): boolean;
- separateTileY(object: Object, x: number, y: number, width: number, height: number, mass: number, collideLeft: boolean, collideRight: boolean, collideUp: boolean, collideDown: boolean, separateX: boolean, separateY: boolean): boolean;
- velocityFromAngle(angle: number, speed?: number, point?: Phaser.Point): Phaser.Point;
- moveTowardsObject(source: Phaser.Sprite, dest: Phaser.Sprite, speed?: number, maxTime?: number): void;
- accelerateTowardsObject(source: Phaser.Sprite, dest: Phaser.Sprite, speed?: number, xSpeedMax?: number, ySpeedMax?: number): void;
- moveTowardsMouse(source: Phaser.Sprite, speed?: number, maxTime?: number): void;
- accelerateTowardsMouse(source: Phaser.Sprite, speed: number, xSpeedMax?: number, ySpeedMax?: number): void;
- moveTowardsPoint(source: Phaser.Sprite, target: Phaser.Point, speed?: number, maxTime?: number): void;
- accelerateTowardsPoint(source: Phaser.Sprite, target: Phaser.Point, speed: number, xSpeedMax?: number, ySpeedMax?: number): void;
- distanceBetween(a: Phaser.Sprite, b: Phaser.Sprite): number;
- distanceToPoint(a: Phaser.Sprite, target: Phaser.Point): number;
- distanceToMouse(a: Phaser.Sprite): number;
- angleBetweenPoint(a: Phaser.Sprite, target: Phaser.Point, asDegrees?: boolean): number;
- angleBetween(a: Phaser.Sprite, b: Phaser.Sprite, asDegrees?: boolean): number;
- velocityFromFacing(parent: Phaser.Sprite, speed: number): Phaser.Point;
- angleBetweenMouse(a: Phaser.Sprite, asDegress?: boolean): number;
- }
-
- module Arcade {
- class BorderChoices {
- none: boolean;
- any: boolean;
- up: boolean;
- down: boolean;
- left: boolean;
- right: boolean;
- }
-
- class Body {
- constructor(sprite: Phaser.Sprite);
- sprite: Phaser.Sprite;
- game: Phaser.Game;
- offset: Phaser.Point;
- x: number;
- y: number;
- lastX: number;
- lastY: number;
- sourceWidth: number;
- sourceHeight: number;
- width: number;
- height: number;
- halfWidth: number;
- helfHeight: number;
- velocity: Phaser.Point;
- acceleration: Phaser.Point;
- drag: Phaser.Point;
- gravity: Phaser.Point;
- bounce: Phaser.Point;
- maxVelocity: Phaser.Point;
- angularVelocity: number;
- angularAcceleration: number;
- angularDrag: number;
- maxAngular: number;
- mass: number;
- quadTreeIDs: string[];
- quadTreeIndex: number;
- allowCollision: BorderChoices;
- touching: BorderChoices;
- wasTouching: BorderChoices;
- immovable: boolean;
- moves: boolean;
- rotation: number;
- allowRotation: boolean;
- allowGravity: boolean;
- customSeparateX: boolean;
- customSeparateY: boolean;
- overlapX: number;
- overlapY: number;
- collideWorldBounds: boolean;
- bottom: number;
- right: number;
- updateBounds(centerX: number, centerY: number, scaleX: number, scaleY: number): void;
- update(): void;
- postUpdate(): void;
- checkWorldBounds(): void;
- setSize(width: number, height: number, offsetX: number, offsetY: number): void;
- reset(): void;
- deltaAbsX(): number;
- deltaAbsY(): number;
- deltaX(): number;
- deltaY(): number;
- }
- }
- }
-
- class Particles {
- constructor(game: Phaser.Game);
- emitters: Object;
- ID: number;
- add(emitter: Phaser.Particles.Arcade.Emitter): Phaser.Particles.Arcade.Emitter;
- remove(emitter: Phaser.Particles.Arcade.Emitter): void;
- update(): void;
- }
-
- module Particles {
- module Arcade {
- class Emitter {
- constructor(game: Phaser.Game, x: number, y: number, maxParticles?: number);
- name: string;
- type: number;
- x: number;
- y: number;
- width: number;
- height: number;
- minParticleSpeed: Phaser.Point;
- maxParticleSpeed: Phaser.Point;
- minParticleScale: number;
- maxParticleScale: number;
- minRotation: number;
- maxRotation: number;
- gravity: number;
- particleClass: string;
- particleDrag: Phaser.Point;
- angularDrag: number;
- frequency: number;
- maxParticles: number;
- lifespan: number;
- bounce: Phaser.Point;
- on: boolean;
- exists: boolean;
- emitX: number;
- emitY: number;
- alpha: number;
- visible: boolean;
- left: number;
- top: number;
- bottom: number;
- right: number;
- update(): void;
- makeParticles(keys: string[], frames: string[], quantity: number, collide: boolean, collideWorldBounds: boolean): Phaser.Particles.Arcade.Emitter;
- kill(): void;
- revive(): void;
- start(explode: boolean, lifespan: number, frequency: number, quantity: number): void;
- emitParticle(): void;
- setSize(width: number, height: number): void;
- setXSpeed(min: number, max: number): void;
- setYSpeed(min: number, max: number): void;
- setRotation(min: number, max: number): void;
- at(object: Object): void;
-
- }
- }
- }
-
- class Tilemap {
- constructor(game: Phaser.Game, key: string, x: number, y: number, resizeWorld?: boolean, tileWidth?: number, tileHeight?: number);
- game: Phaser.Game;
- group: Phaser.Group;
- name: string;
- key: string;
- renderOrderID: number;
- collisionCallback: Function;
- exists: boolean;
- visible: boolean;
- tiles: Array;
- layers: Array;
- position: Phaser.Point;
- type: number;
- renderer: Phaser.TilemapRenderer;
- mapFormat: string;
- widthInPixels: number;
- heightInPixels: number;
- static CSV: number;
- static JSON: number;
- parseCSV(data: string, key: string, tileWidth: number, tileHeight: number): void;
- parseTiledJSON(json: string, key: string): void;
- generateTiles(quantity: number): void;
- setCollisionCallback(context: Object, callback: Function): void;
- setCollisionRange(start: number, end: number, collision: number, resetCollisions?: boolean, separateX?: boolean, separateY?: boolean): void;
- setCollisionByIndex(value: number[], collision: number, resetCollisions?: boolean, separateX?: boolean, separateY?: boolean): void;
- getTileByIndex(value: number): Tile;
- getTile(x: number, y: number, layer?: number): Tile;
- getTileFromWorldXY(x: number, y: number, layer?: number): Tile;
- getTileFromInputXY(layer?: number): Tile;
- getTileOverlaps(object: Object): Array;
- collide(objectOrGroup: any, callback: Function, context: Object): boolean;
- collideGameObject(object: Object): boolean;
- putTile(x: number, y: number, index: number, layer?: number): void;
- update(): void;
- destroy(): void;
- }
-
- class TilemapLayer {
- constructor(parent: Tilemap, id: number, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number);
- exists: boolean;
- visible: boolean;
- widthInTiles: number;
- heightInTiles: number;
- widthInPixels: number;
- heightInPixels: number;
- tileMargin: number;
- tileSpacing: number;
- parent: Tilemap;
- game: Phaser.Game;
- ID: number;
- name: string;
- key: string;
- type: number;
- mapFormat: number;
- tileWidth: number;
- tileHeight: number;
- boundsInTiles: Phaser.Rectangle;
- tileset: Object;
- canvas: any;
- context: any;
- baseTexture: any;
- texture: any;
- sprite: Phaser.Sprite;
- mapData: Array;
- alpha: number;
- putTileWorldXY(x: number, y: number, index: number): void;
- putTile(x: number, y: number, index: number): void;
- swapTile(tileA: number, tileB: number, x?: number, y?: number, width?: number, height?: number): void;
- fillTile(index: number, x?: number, y?: number, width?: number, height?: number): void;
- randomiseTiles(tiles: number[], x?: number, y?: number, width?: number, height?: number): void;
- replaceTile(tileA: number, tileB: number, x?: number, y?: number, width?: number, height?: number): void;
- getTileBlock(x: number, y: number, width: number, height: number): Array;
- getTileFromWorldXY(x: number, y: number): Tile;
- getTileOverlaps(object: Object): Array;
- getTempBlock(x: number, y: number, width: number, height: number, collisionOnly?: boolean): void;
- getTileIndex(x: number, y: number): number;
- addColumn(column: string[]): void;
- createCanvas(): void;
- updateBounds(): void;
- parseTileOffsets(): number;
- }
-
- class Tile {
- constructor(game: Phaser.Game, tilemap: Tilemap, index: number, width: number, height: number);
- mass: number;
- collideNone: boolean;
- collideLeft: boolean;
- collideRight: boolean;
- collideUp: boolean;
- collideDown: boolean;
- separateX: boolean;
- separateY: boolean;
- game: Phaser.Game;
- tilemap: Tilemap;
- index: number;
- width: number;
- height: number;
- destroy(): void;
- setCollision(left: boolean, right: boolean, up: boolean, down: boolean, reset: boolean, seperateX: boolean, seperateY: boolean): void;
- resetCollsion(): void;
- toString(): string;
- }
-
- class TilemapRenderer {
- constructor(game: Phaser.Game);
- game: Phaser.Game;
- render(tilemap: Tilemap): void;
- }
-}
\ No newline at end of file
diff --git a/wip/TS Tests/template_breakout/phaser.js b/wip/TS Tests/template_breakout/phaser.js
deleted file mode 100644
index 0c44531d..00000000
--- a/wip/TS Tests/template_breakout/phaser.js
+++ /dev/null
@@ -1,37938 +0,0 @@
-!function(root, factory) {
- if (typeof define === "function" && define.amd) {
- define(factory);
- } else if (typeof exports === "object") {
- module.exports = factory();
- } else {
- root.Phaser = factory();
- }
-}(this, function() {
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* @overview
-*
-* Phaser - http://www.phaser.io
-*
-* v1.1.3 - Built at: Thu Nov 07 2013 06:09:12
-*
-* By Richard Davey http://www.photonstorm.com @photonstorm
-*
-* A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and
-* constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm).
-*
-* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com/ @Doormat23.
-*
-* Follow Phaser development progress at http://www.photonstorm.com
-*
-* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser
-* and my love of game development originate.
-*
-* "If you want your children to be intelligent, read them fairy tales."
-* "If you want them to be more intelligent, read them more fairy tales."
-* -- Albert Einstein
-*/
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- * @module PIXI
- */
-var PIXI = PIXI || {};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* @namespace Phaser
-*/
-var Phaser = Phaser || {
-
- VERSION: '1.1.3',
- DEV_VERSION: '1.1.3',
- GAMES: [],
- AUTO: 0,
- CANVAS: 1,
- WEBGL: 2,
-
- SPRITE: 0,
- BUTTON: 1,
- BULLET: 2,
- GRAPHICS: 3,
- TEXT: 4,
- TILESPRITE: 5,
- BITMAPTEXT: 6,
- GROUP: 7,
- RENDERTEXTURE: 8,
- TILEMAP: 9,
- TILEMAPLAYER: 10,
- EMITTER: 11,
- POLYGON: 12,
-
- NONE: 0,
- LEFT: 1,
- RIGHT: 2,
- UP: 3,
- DOWN: 4
-
- };
-
-PIXI.InteractionManager = function (dummy) {
- // We don't need this in Pixi, so we've removed it to save space
- // however the Stage object expects a reference to it, so here is a dummy entry.
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* @class Phaser.Utils
-* @static
-*/
-Phaser.Utils = {
-
- /**
- * A standard Fisher-Yates Array shuffle implementation.
- * @method Phaser.Utils.shuffle
- * @param {array} array - The array to shuffle.
- * @return {array} The shuffled array.
- */
- shuffle: function (array) {
-
- for (var i = array.length - 1; i > 0; i--)
- {
- var j = Math.floor(Math.random() * (i + 1));
- var temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
-
- return array;
-
- },
-
- /**
- * Javascript string pad http://www.webtoolkit.info/.
- * pad = the string to pad it out with (defaults to a space)
- * dir = 1 (left), 2 (right), 3 (both)
- * @method Phaser.Utils.pad
- * @param {string} str - The target string.
- * @param {number} len - Description.
- * @param {number} pad - the string to pad it out with (defaults to a space).
- * @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both).
- * @return {string} The padded string
- */
- pad: function (str, len, pad, dir) {
-
- if (typeof(len) == "undefined") { var len = 0; }
- if (typeof(pad) == "undefined") { var pad = ' '; }
- if (typeof(dir) == "undefined") { var dir = 3; }
-
- if (len + 1 >= str.length)
- {
- switch (dir)
- {
- case 1:
- str = Array(len + 1 - str.length).join(pad) + str;
- break;
-
- case 3:
- var right = Math.ceil((padlen = len - str.length) / 2);
- var left = padlen - right;
- str = Array(left+1).join(pad) + str + Array(right+1).join(pad);
- break;
-
- default:
- str = str + Array(len + 1 - str.length).join(pad);
- break;
- }
- }
-
- return str;
-
- },
-
- /**
- * This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object].
- * @method Phaser.Utils.isPlainObject
- * @param {object} obj - The object to inspect.
- * @return {boolean} - true if the object is plain, otherwise false.
- */
- isPlainObject: function (obj) {
-
- // Not plain objects:
- // - Any object or value whose internal [[Class]] property is not "[object Object]"
- // - DOM nodes
- // - window
- if (typeof(obj) !== "object" || obj.nodeType || obj === obj.window)
- {
- return false;
- }
-
- // Support: Firefox <20
- // The try/catch suppresses exceptions thrown when attempting to access
- // the "constructor" property of certain host objects, ie. |window.location|
- // https://bugzilla.mozilla.org/show_bug.cgi?id=814622
- try {
- if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf"))
- {
- return false;
- }
- } catch (e) {
- return false;
- }
-
- // If the function hasn't returned already, we're confident that
- // |obj| is a plain object, created by {} or constructed with new Object
- return true;
- },
-
-
- // deep, target, objects to copy to the target object
- // This is a slightly modified version of {@link http://api.jquery.com/jQuery.extend/|jQuery.extend}
- // deep (boolean)
- // target (object to add to)
- // objects ... (objects to recurse and copy from)
-
- /**
- * This is a slightly modified version of http://api.jquery.com/jQuery.extend/
- * @method Phaser.Utils.extend
- * @param {boolean} deep - Perform a deep copy?
- * @param {object} target - The target object to copy to.
- * @return {object} The extended object.
- */
- extend: function () {
-
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if (typeof target === "boolean")
- {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // extend Phaser if only one argument is passed
- if (length === i)
- {
- target = this;
- --i;
- }
-
- for ( ; i < length; i++ )
- {
- // Only deal with non-null/undefined values
- if ((options = arguments[i]) != null)
- {
- // Extend the base object
- for (name in options)
- {
- src = target[name];
- copy = options[name];
-
- // Prevent never-ending loop
- if (target === copy)
- {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if (deep && copy && (Phaser.Utils.isPlainObject(copy) || (copyIsArray = Array.isArray(copy))))
- {
- if (copyIsArray)
- {
- copyIsArray = false;
- clone = src && Array.isArray(src) ? src : [];
- }
- else
- {
- clone = src && Phaser.Utils.isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[name] = Phaser.Utils.extend(deep, clone, copy);
-
- // Don't bring in undefined values
- }
- else if (copy !== undefined)
- {
- target[name] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
- }
-
-};
-
-// Global functions that PIXI needs
-
- /**
- * Converts a hex color number to an [R, G, B] array
- *
- * @param {number} hex
- * @return {array}
- */
-function HEXtoRGB(hex) {
- return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
-}
-
- /**
- * A polyfill for Function.prototype.bind
- */
-if (typeof Function.prototype.bind != 'function') {
- Function.prototype.bind = (function () {
- var slice = Array.prototype.slice;
- return function (thisArg) {
- var target = this, boundArgs = slice.call(arguments, 1);
-
- if (typeof target != 'function') throw new TypeError();
-
- function bound() {
- var args = boundArgs.concat(slice.call(arguments));
- target.apply(this instanceof bound ? this : thisArg, args);
- }
-
- bound.prototype = (function F(proto) {
- proto && (F.prototype = proto);
- if (!(this instanceof F)) return new F;
- })(target.prototype);
-
- return bound;
- };
- })();
-}
-
-
-
-
-/*
- * A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV
- * you both rock!
- */
-
-function determineMatrixArrayType() {
- PIXI.Matrix = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
- return PIXI.Matrix;
-}
-
-determineMatrixArrayType();
-
-PIXI.mat3 = {};
-
-PIXI.mat3.create = function()
-{
- var matrix = new PIXI.Matrix(9);
-
- matrix[0] = 1;
- matrix[1] = 0;
- matrix[2] = 0;
- matrix[3] = 0;
- matrix[4] = 1;
- matrix[5] = 0;
- matrix[6] = 0;
- matrix[7] = 0;
- matrix[8] = 1;
-
- return matrix;
-}
-
-
-PIXI.mat3.identity = function(matrix)
-{
- matrix[0] = 1;
- matrix[1] = 0;
- matrix[2] = 0;
- matrix[3] = 0;
- matrix[4] = 1;
- matrix[5] = 0;
- matrix[6] = 0;
- matrix[7] = 0;
- matrix[8] = 1;
-
- return matrix;
-}
-
-
-PIXI.mat4 = {};
-
-PIXI.mat4.create = function()
-{
- var matrix = new PIXI.Matrix(16);
-
- matrix[0] = 1;
- matrix[1] = 0;
- matrix[2] = 0;
- matrix[3] = 0;
- matrix[4] = 0;
- matrix[5] = 1;
- matrix[6] = 0;
- matrix[7] = 0;
- matrix[8] = 0;
- matrix[9] = 0;
- matrix[10] = 1;
- matrix[11] = 0;
- matrix[12] = 0;
- matrix[13] = 0;
- matrix[14] = 0;
- matrix[15] = 1;
-
- return matrix;
-}
-
-PIXI.mat3.multiply = function (mat, mat2, dest)
-{
- if (!dest) { dest = mat; }
-
- // Cache the matrix values (makes for huge speed increases!)
- var a00 = mat[0], a01 = mat[1], a02 = mat[2],
- a10 = mat[3], a11 = mat[4], a12 = mat[5],
- a20 = mat[6], a21 = mat[7], a22 = mat[8],
-
- b00 = mat2[0], b01 = mat2[1], b02 = mat2[2],
- b10 = mat2[3], b11 = mat2[4], b12 = mat2[5],
- b20 = mat2[6], b21 = mat2[7], b22 = mat2[8];
-
- dest[0] = b00 * a00 + b01 * a10 + b02 * a20;
- dest[1] = b00 * a01 + b01 * a11 + b02 * a21;
- dest[2] = b00 * a02 + b01 * a12 + b02 * a22;
-
- dest[3] = b10 * a00 + b11 * a10 + b12 * a20;
- dest[4] = b10 * a01 + b11 * a11 + b12 * a21;
- dest[5] = b10 * a02 + b11 * a12 + b12 * a22;
-
- dest[6] = b20 * a00 + b21 * a10 + b22 * a20;
- dest[7] = b20 * a01 + b21 * a11 + b22 * a21;
- dest[8] = b20 * a02 + b21 * a12 + b22 * a22;
-
- return dest;
-}
-
-PIXI.mat3.clone = function(mat)
-{
- var matrix = new PIXI.Matrix(9);
-
- matrix[0] = mat[0];
- matrix[1] = mat[1];
- matrix[2] = mat[2];
- matrix[3] = mat[3];
- matrix[4] = mat[4];
- matrix[5] = mat[5];
- matrix[6] = mat[6];
- matrix[7] = mat[7];
- matrix[8] = mat[8];
-
- return matrix;
-}
-
-PIXI.mat3.transpose = function (mat, dest)
-{
- // If we are transposing ourselves we can skip a few steps but have to cache some values
- if (!dest || mat === dest) {
- var a01 = mat[1], a02 = mat[2],
- a12 = mat[5];
-
- mat[1] = mat[3];
- mat[2] = mat[6];
- mat[3] = a01;
- mat[5] = mat[7];
- mat[6] = a02;
- mat[7] = a12;
- return mat;
- }
-
- dest[0] = mat[0];
- dest[1] = mat[3];
- dest[2] = mat[6];
- dest[3] = mat[1];
- dest[4] = mat[4];
- dest[5] = mat[7];
- dest[6] = mat[2];
- dest[7] = mat[5];
- dest[8] = mat[8];
- return dest;
-}
-
-PIXI.mat3.toMat4 = function (mat, dest)
-{
- if (!dest) { dest = PIXI.mat4.create(); }
-
- dest[15] = 1;
- dest[14] = 0;
- dest[13] = 0;
- dest[12] = 0;
-
- dest[11] = 0;
- dest[10] = mat[8];
- dest[9] = mat[7];
- dest[8] = mat[6];
-
- dest[7] = 0;
- dest[6] = mat[5];
- dest[5] = mat[4];
- dest[4] = mat[3];
-
- dest[3] = 0;
- dest[2] = mat[2];
- dest[1] = mat[1];
- dest[0] = mat[0];
-
- return dest;
-}
-
-
-/////
-
-
-PIXI.mat4.create = function()
-{
- var matrix = new PIXI.Matrix(16);
-
- matrix[0] = 1;
- matrix[1] = 0;
- matrix[2] = 0;
- matrix[3] = 0;
- matrix[4] = 0;
- matrix[5] = 1;
- matrix[6] = 0;
- matrix[7] = 0;
- matrix[8] = 0;
- matrix[9] = 0;
- matrix[10] = 1;
- matrix[11] = 0;
- matrix[12] = 0;
- matrix[13] = 0;
- matrix[14] = 0;
- matrix[15] = 1;
-
- return matrix;
-}
-
-PIXI.mat4.transpose = function (mat, dest)
-{
- // If we are transposing ourselves we can skip a few steps but have to cache some values
- if (!dest || mat === dest)
- {
- var a01 = mat[1], a02 = mat[2], a03 = mat[3],
- a12 = mat[6], a13 = mat[7],
- a23 = mat[11];
-
- mat[1] = mat[4];
- mat[2] = mat[8];
- mat[3] = mat[12];
- mat[4] = a01;
- mat[6] = mat[9];
- mat[7] = mat[13];
- mat[8] = a02;
- mat[9] = a12;
- mat[11] = mat[14];
- mat[12] = a03;
- mat[13] = a13;
- mat[14] = a23;
- return mat;
- }
-
- dest[0] = mat[0];
- dest[1] = mat[4];
- dest[2] = mat[8];
- dest[3] = mat[12];
- dest[4] = mat[1];
- dest[5] = mat[5];
- dest[6] = mat[9];
- dest[7] = mat[13];
- dest[8] = mat[2];
- dest[9] = mat[6];
- dest[10] = mat[10];
- dest[11] = mat[14];
- dest[12] = mat[3];
- dest[13] = mat[7];
- dest[14] = mat[11];
- dest[15] = mat[15];
- return dest;
-}
-
-PIXI.mat4.multiply = function (mat, mat2, dest)
-{
- if (!dest) { dest = mat; }
-
- // Cache the matrix values (makes for huge speed increases!)
- var a00 = mat[ 0], a01 = mat[ 1], a02 = mat[ 2], a03 = mat[3];
- var a10 = mat[ 4], a11 = mat[ 5], a12 = mat[ 6], a13 = mat[7];
- var a20 = mat[ 8], a21 = mat[ 9], a22 = mat[10], a23 = mat[11];
- var a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15];
-
- // Cache only the current line of the second matrix
- var b0 = mat2[0], b1 = mat2[1], b2 = mat2[2], b3 = mat2[3];
- dest[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
- dest[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
- dest[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
- dest[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
-
- b0 = mat2[4];
- b1 = mat2[5];
- b2 = mat2[6];
- b3 = mat2[7];
- dest[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
- dest[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
- dest[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
- dest[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
-
- b0 = mat2[8];
- b1 = mat2[9];
- b2 = mat2[10];
- b3 = mat2[11];
- dest[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
- dest[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
- dest[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
- dest[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
-
- b0 = mat2[12];
- b1 = mat2[13];
- b2 = mat2[14];
- b3 = mat2[15];
- dest[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
- dest[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
- dest[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
- dest[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
-
- return dest;
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
- *
- * @class Point
- * @constructor
- * @param x {Number} position of the point
- * @param y {Number} position of the point
- */
-PIXI.Point = function(x, y)
-{
- /**
- * @property x
- * @type Number
- * @default 0
- */
- this.x = x || 0;
-
- /**
- * @property y
- * @type Number
- * @default 0
- */
- this.y = y || 0;
-}
-
-/**
- * Creates a clone of this point
- *
- * @method clone
- * @return {Point} a copy of the point
- */
-PIXI.Point.prototype.clone = function()
-{
- return new PIXI.Point(this.x, this.y);
-}
-
-// constructor
-PIXI.Point.prototype.constructor = PIXI.Point;
-
-
-/**
- * @author Mat Groves http://matgroves.com/
- */
-
-/**
- * the Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its width and its height.
- *
- * @class Rectangle
- * @constructor
- * @param x {Number} The X coord of the upper-left corner of the rectangle
- * @param y {Number} The Y coord of the upper-left corner of the rectangle
- * @param width {Number} The overall width of this rectangle
- * @param height {Number} The overall height of this rectangle
- */
-PIXI.Rectangle = function(x, y, width, height)
-{
- /**
- * @property x
- * @type Number
- * @default 0
- */
- this.x = x || 0;
-
- /**
- * @property y
- * @type Number
- * @default 0
- */
- this.y = y || 0;
-
- /**
- * @property width
- * @type Number
- * @default 0
- */
- this.width = width || 0;
-
- /**
- * @property height
- * @type Number
- * @default 0
- */
- this.height = height || 0;
-}
-
-/**
- * Creates a clone of this Rectangle
- *
- * @method clone
- * @return {Rectangle} a copy of the rectangle
- */
-PIXI.Rectangle.prototype.clone = function()
-{
- return new PIXI.Rectangle(this.x, this.y, this.width, this.height);
-}
-
-/**
- * Checks if the x, and y coords passed to this function are contained within this Rectangle
- *
- * @method contains
- * @param x {Number} The X coord of the point to test
- * @param y {Number} The Y coord of the point to test
- * @return {Boolean} if the x/y coords are within this Rectangle
- */
-PIXI.Rectangle.prototype.contains = function(x, y)
-{
- if(this.width <= 0 || this.height <= 0)
- return false;
-
- var x1 = this.x;
- if(x >= x1 && x <= x1 + this.width)
- {
- var y1 = this.y;
-
- if(y >= y1 && y <= y1 + this.height)
- {
- return true;
- }
- }
-
- return false;
-}
-
-// constructor
-PIXI.Rectangle.prototype.constructor = PIXI.Rectangle;
-
-
-/**
- * @author Adrien Brault
- */
-
-/**
- * @class Polygon
- * @constructor
- * @param points* {Array|Array|Point...|Number...} This can be an array of Points that form the polygon,
- * a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be
- * all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the
- * arguments passed can be flat x,y values e.g. `new PIXI.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are
- * Numbers.
- */
-PIXI.Polygon = function(points)
-{
- //if points isn't an array, use arguments as the array
- if(!(points instanceof Array))
- points = Array.prototype.slice.call(arguments);
-
- //if this is a flat array of numbers, convert it to points
- if(typeof points[0] === 'number') {
- var p = [];
- for(var i = 0, il = points.length; i < il; i+=2) {
- p.push(
- new PIXI.Point(points[i], points[i + 1])
- );
- }
-
- points = p;
- }
-
- this.points = points;
-}
-
-/**
- * Creates a clone of this polygon
- *
- * @method clone
- * @return {Polygon} a copy of the polygon
- */
-PIXI.Polygon.prototype.clone = function()
-{
- var points = [];
- for (var i=0; i y) != (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
-
- if(intersect) inside = !inside;
- }
-
- return inside;
-}
-
-// constructor
-PIXI.Polygon.prototype.constructor = PIXI.Polygon;
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- * The base class for all objects that are rendered on the screen.
- *
- * @class DisplayObject
- * @constructor
- */
-PIXI.DisplayObject = function()
-{
- this.last = this;
- this.first = this;
- /**
- * The coordinate of the object relative to the local coordinates of the parent.
- *
- * @property position
- * @type Point
- */
- this.position = new PIXI.Point();
-
- /**
- * The scale factor of the object.
- *
- * @property scale
- * @type Point
- */
- this.scale = new PIXI.Point(1,1);//{x:1, y:1};
-
- /**
- * The pivot point of the displayObject that it rotates around
- *
- * @property pivot
- * @type Point
- */
- this.pivot = new PIXI.Point(0,0);
-
- /**
- * The rotation of the object in radians.
- *
- * @property rotation
- * @type Number
- */
- this.rotation = 0;
-
- /**
- * The opacity of the object.
- *
- * @property alpha
- * @type Number
- */
- this.alpha = 1;
-
- /**
- * The visibility of the object.
- *
- * @property visible
- * @type Boolean
- */
- this.visible = true;
-
- /**
- * This is the defined area that will pick up mouse / touch events. It is null by default.
- * Setting it is a neat way of optimising the hitTest function that the interactionManager will use (as it will not need to hit test all the children)
- *
- * @property hitArea
- * @type Rectangle|Circle|Ellipse|Polygon
- */
- this.hitArea = null;
-
- /**
- * This is used to indicate if the displayObject should display a mouse hand cursor on rollover
- *
- * @property buttonMode
- * @type Boolean
- */
- this.buttonMode = false;
-
- /**
- * Can this object be rendered
- *
- * @property renderable
- * @type Boolean
- */
- this.renderable = false;
-
- /**
- * [read-only] The display object container that contains this display object.
- *
- * @property parent
- * @type DisplayObjectContainer
- * @readOnly
- */
- this.parent = null;
-
- /**
- * [read-only] The stage the display object is connected to, or undefined if it is not connected to the stage.
- *
- * @property stage
- * @type Stage
- * @readOnly
- */
- this.stage = null;
-
- /**
- * [read-only] The multiplied alpha of the displayobject
- *
- * @property worldAlpha
- * @type Number
- * @readOnly
- */
- this.worldAlpha = 1;
-
- /**
- * [read-only] Whether or not the object is interactive, do not toggle directly! use the `interactive` property
- *
- * @property _interactive
- * @type Boolean
- * @readOnly
- * @private
- */
- this._interactive = false;
-
- /**
- * [read-only] Current transform of the object based on world (parent) factors
- *
- * @property worldTransform
- * @type Mat3
- * @readOnly
- * @private
- */
- this.worldTransform = PIXI.mat3.create()//mat3.identity();
-
- /**
- * [read-only] Current transform of the object locally
- *
- * @property localTransform
- * @type Mat3
- * @readOnly
- * @private
- */
- this.localTransform = PIXI.mat3.create()//mat3.identity();
-
- /**
- * [NYI] Unkown
- *
- * @property color
- * @type Array<>
- * @private
- */
- this.color = [];
-
- /**
- * [NYI] Holds whether or not this object is dynamic, for rendering optimization
- *
- * @property dynamic
- * @type Boolean
- * @private
- */
- this.dynamic = true;
-
- // chach that puppy!
- this._sr = 0;
- this._cr = 1;
-
-
- this.filterArea = new PIXI.Rectangle(0,0,1,1);
-
- /*
- * MOUSE Callbacks
- */
-
- /**
- * A callback that is used when the users clicks on the displayObject with their mouse
- * @method click
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the user clicks the mouse down over the sprite
- * @method mousedown
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the user releases the mouse that was over the displayObject
- * for this callback to be fired the mouse must have been pressed down over the displayObject
- * @method mouseup
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the user releases the mouse that was over the displayObject but is no longer over the displayObject
- * for this callback to be fired, The touch must have started over the displayObject
- * @method mouseupoutside
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the users mouse rolls over the displayObject
- * @method mouseover
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the users mouse leaves the displayObject
- * @method mouseout
- * @param interactionData {InteractionData}
- */
-
-
- /*
- * TOUCH Callbacks
- */
-
- /**
- * A callback that is used when the users taps on the sprite with their finger
- * basically a touch version of click
- * @method tap
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the user touch's over the displayObject
- * @method touchstart
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the user releases a touch over the displayObject
- * @method touchend
- * @param interactionData {InteractionData}
- */
-
- /**
- * A callback that is used when the user releases the touch that was over the displayObject
- * for this callback to be fired, The touch must have started over the sprite
- * @method touchendoutside
- * @param interactionData {InteractionData}
- */
-}
-
-// constructor
-PIXI.DisplayObject.prototype.constructor = PIXI.DisplayObject;
-
-/**
- * [Deprecated] Indicates if the sprite will have touch and mouse interactivity. It is false by default
- * Instead of using this function you can now simply set the interactive property to true or false
- *
- * @method setInteractive
- * @param interactive {Boolean}
- * @deprecated Simply set the `interactive` property directly
- */
-PIXI.DisplayObject.prototype.setInteractive = function(interactive)
-{
- this.interactive = interactive;
-}
-
-/**
- * Indicates if the sprite will have touch and mouse interactivity. It is false by default
- *
- * @property interactive
- * @type Boolean
- * @default false
- */
-Object.defineProperty(PIXI.DisplayObject.prototype, 'interactive', {
- get: function() {
- return this._interactive;
- },
- set: function(value) {
- this._interactive = value;
-
- // TODO more to be done here..
- // need to sort out a re-crawl!
- if(this.stage)this.stage.dirty = true;
- }
-});
-
-/**
- * Sets a mask for the displayObject. A mask is an object that limits the visibility of an object to the shape of the mask applied to it.
- * In PIXI a regular mask must be a PIXI.Ggraphics object. This allows for much faster masking in canvas as it utilises shape clipping.
- * To remove a mask, set this property to null.
- *
- * @property mask
- * @type Graphics
- */
-Object.defineProperty(PIXI.DisplayObject.prototype, 'mask', {
- get: function() {
- return this._mask;
- },
- set: function(value) {
-
-
- if(value)
- {
- if(this._mask)
- {
- value.start = this._mask.start;
- value.end = this._mask.end;
- }
- else
- {
- this.addFilter(value);
- value.renderable = false;
- }
- }
- else
- {
- this.removeFilter(this._mask);
- this._mask.renderable = true;
- }
-
- this._mask = value;
- }
-});
-
-/**
- * Sets the filters for the displayObject.
- * * IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer.
- * To remove filters simply set this property to 'null'
- * @property filters
- * @type Array An array of filters
- */
-Object.defineProperty(PIXI.DisplayObject.prototype, 'filters', {
- get: function() {
- return this._filters;
- },
- set: function(value) {
-
- if(value)
- {
- if(this._filters)this.removeFilter(this._filters);
- this.addFilter(value);
-
- // now put all the passes in one place..
- var passes = [];
- for (var i = 0; i < value.length; i++)
- {
- var filterPasses = value[i].passes;
- for (var j = 0; j < filterPasses.length; j++)
- {
- passes.push(filterPasses[j]);
- };
- };
-
- value.start.filterPasses = passes;
- }
- else
- {
- if(this._filters)this.removeFilter(this._filters);
- }
-
- this._filters = value;
-
-
-
-
- }
-});
-
-/*
- * Adds a filter to this displayObject
- *
- * @method addFilter
- * @param mask {Graphics} the graphics object to use as a filter
- * @private
- */
-PIXI.DisplayObject.prototype.addFilter = function(data)
-{
- //if(this.filter)return;
- //this.filter = true;
-// data[0].target = this;
-
-
- // insert a filter block..
- // TODO Onject pool thease bad boys..
- var start = new PIXI.FilterBlock();
- var end = new PIXI.FilterBlock();
-
- data.start = start;
- data.end = end;
-
- start.data = data;
- end.data = data;
-
- start.first = start.last = this;
- end.first = end.last = this;
-
- start.open = true;
-
- start.target = this;
-
- /*
- * insert start
- */
-
- var childFirst = start
- var childLast = start
- var nextObject;
- var previousObject;
-
- previousObject = this.first._iPrev;
-
- if(previousObject)
- {
- nextObject = previousObject._iNext;
- childFirst._iPrev = previousObject;
- previousObject._iNext = childFirst;
- }
- else
- {
- nextObject = this;
- }
-
- if(nextObject)
- {
- nextObject._iPrev = childLast;
- childLast._iNext = nextObject;
- }
-
-
- // now insert the end filter block..
-
- /*
- * insert end filter
- */
- var childFirst = end
- var childLast = end
- var nextObject = null;
- var previousObject = null;
-
- previousObject = this.last;
- nextObject = previousObject._iNext;
-
- if(nextObject)
- {
- nextObject._iPrev = childLast;
- childLast._iNext = nextObject;
- }
-
- childFirst._iPrev = previousObject;
- previousObject._iNext = childFirst;
-
- var updateLast = this;
-
- var prevLast = this.last;
- while(updateLast)
- {
- if(updateLast.last == prevLast)
- {
- updateLast.last = end;
- }
- updateLast = updateLast.parent;
- }
-
- this.first = start;
-
- // if webGL...
- if(this.__renderGroup)
- {
- this.__renderGroup.addFilterBlocks(start, end);
- }
-
-}
-
-/*
- * Removes the filter to this displayObject
- *
- * @method removeFilter
- * @private
- */
-PIXI.DisplayObject.prototype.removeFilter = function(data)
-{
- //if(!this.filter)return;
- //this.filter = false;
- console.log("YUOIO")
- // modify the list..
- var startBlock = data.start;
-
-
- var nextObject = startBlock._iNext;
- var previousObject = startBlock._iPrev;
-
- if(nextObject)nextObject._iPrev = previousObject;
- if(previousObject)previousObject._iNext = nextObject;
-
- this.first = startBlock._iNext;
-
- // remove the end filter
- var lastBlock = data.end;
-
- var nextObject = lastBlock._iNext;
- var previousObject = lastBlock._iPrev;
-
- if(nextObject)nextObject._iPrev = previousObject;
- previousObject._iNext = nextObject;
-
- // this is always true too!
- var tempLast = lastBlock._iPrev;
- // need to make sure the parents last is updated too
- var updateLast = this;
- while(updateLast.last == lastBlock)
- {
- updateLast.last = tempLast;
- updateLast = updateLast.parent;
- if(!updateLast)break;
- }
-
- // if webGL...
- if(this.__renderGroup)
- {
- this.__renderGroup.removeFilterBlocks(startBlock, lastBlock);
- }
-}
-
-/*
- * Updates the object transform for rendering
- *
- * @method updateTransform
- * @private
- */
-PIXI.DisplayObject.prototype.updateTransform = function()
-{
- // TODO OPTIMIZE THIS!! with dirty
- if(this.rotation !== this.rotationCache)
- {
- this.rotationCache = this.rotation;
- this._sr = Math.sin(this.rotation);
- this._cr = Math.cos(this.rotation);
- }
-
- var localTransform = this.localTransform;
- var parentTransform = this.parent.worldTransform;
- var worldTransform = this.worldTransform;
- //console.log(localTransform)
- localTransform[0] = this._cr * this.scale.x;
- localTransform[1] = -this._sr * this.scale.y
- localTransform[3] = this._sr * this.scale.x;
- localTransform[4] = this._cr * this.scale.y;
-
- // TODO --> do we even need a local matrix???
-
- var px = this.pivot.x;
- var py = this.pivot.y;
-
- // Cache the matrix values (makes for huge speed increases!)
- var a00 = localTransform[0], a01 = localTransform[1], a02 = this.position.x - localTransform[0] * px - py * localTransform[1],
- a10 = localTransform[3], a11 = localTransform[4], a12 = this.position.y - localTransform[4] * py - px * localTransform[3],
-
- b00 = parentTransform[0], b01 = parentTransform[1], b02 = parentTransform[2],
- b10 = parentTransform[3], b11 = parentTransform[4], b12 = parentTransform[5];
-
- localTransform[2] = a02
- localTransform[5] = a12
-
- worldTransform[0] = b00 * a00 + b01 * a10;
- worldTransform[1] = b00 * a01 + b01 * a11;
- worldTransform[2] = b00 * a02 + b01 * a12 + b02;
-
- worldTransform[3] = b10 * a00 + b11 * a10;
- worldTransform[4] = b10 * a01 + b11 * a11;
- worldTransform[5] = b10 * a02 + b11 * a12 + b12;
-
- // because we are using affine transformation, we can optimise the matrix concatenation process.. wooo!
- // mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform);
- this.worldAlpha = this.alpha * this.parent.worldAlpha;
-
- this.vcount = PIXI.visibleCount;
-
-}
-
-PIXI.visibleCount = 0;
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- * A DisplayObjectContainer represents a collection of display objects.
- * It is the base class of all display objects that act as a container for other objects.
- *
- * @class DisplayObjectContainer
- * @extends DisplayObject
- * @constructor
- */
-PIXI.DisplayObjectContainer = function()
-{
- PIXI.DisplayObject.call( this );
-
- /**
- * [read-only] The of children of this container.
- *
- * @property children
- * @type Array
- * @readOnly
- */
- this.children = [];
-}
-
-// constructor
-PIXI.DisplayObjectContainer.prototype = Object.create( PIXI.DisplayObject.prototype );
-PIXI.DisplayObjectContainer.prototype.constructor = PIXI.DisplayObjectContainer;
-
-/**
- * Adds a child to the container.
- *
- * @method addChild
- * @param child {DisplayObject} The DisplayObject to add to the container
- */
-PIXI.DisplayObjectContainer.prototype.addChild = function(child)
-{
- if(child.parent != undefined)
- {
-
- //// COULD BE THIS???
- child.parent.removeChild(child);
- // return;
- }
-
- child.parent = this;
-
- this.children.push(child);
-
- // update the stage refference..
-
- if(this.stage)
- {
- var tmpChild = child;
- do
- {
- if(tmpChild.interactive)this.stage.dirty = true;
- tmpChild.stage = this.stage;
- tmpChild = tmpChild._iNext;
- }
- while(tmpChild)
- }
-
- // LINKED LIST //
-
- // modify the list..
- var childFirst = child.first
- var childLast = child.last;
- var nextObject;
- var previousObject;
-
- // this could be wrong if there is a filter??
- if(this._filters || this._mask)
- {
- previousObject = this.last._iPrev;
- }
- else
- {
- previousObject = this.last;
- }
-
- nextObject = previousObject._iNext;
-
- // always true in this case
- // need to make sure the parents last is updated too
- var updateLast = this;
- var prevLast = previousObject;
-
- while(updateLast)
- {
- if(updateLast.last == prevLast)
- {
- updateLast.last = child.last;
- }
- updateLast = updateLast.parent;
- }
-
- if(nextObject)
- {
- nextObject._iPrev = childLast;
- childLast._iNext = nextObject;
- }
-
- childFirst._iPrev = previousObject;
- previousObject._iNext = childFirst;
-
- // need to remove any render groups..
- if(this.__renderGroup)
- {
- // being used by a renderTexture.. if it exists then it must be from a render texture;
- if(child.__renderGroup)child.__renderGroup.removeDisplayObjectAndChildren(child);
- // add them to the new render group..
- this.__renderGroup.addDisplayObjectAndChildren(child);
- }
-
-}
-
-/**
- * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown
- *
- * @method addChildAt
- * @param child {DisplayObject} The child to add
- * @param index {Number} The index to place the child in
- */
-PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
-{
- if(index >= 0 && index <= this.children.length)
- {
- if(child.parent != undefined)
- {
- child.parent.removeChild(child);
- }
- child.parent = this;
-
- if(this.stage)
- {
- var tmpChild = child;
- do
- {
- if(tmpChild.interactive)this.stage.dirty = true;
- tmpChild.stage = this.stage;
- tmpChild = tmpChild._iNext;
- }
- while(tmpChild)
- }
-
- // modify the list..
- var childFirst = child.first;
- var childLast = child.last;
- var nextObject;
- var previousObject;
-
- if(index == this.children.length)
- {
- previousObject = this.last;
- var updateLast = this;
- var prevLast = this.last;
- while(updateLast)
- {
- if(updateLast.last == prevLast)
- {
- updateLast.last = child.last;
- }
- updateLast = updateLast.parent;
- }
- }
- else if(index == 0)
- {
- previousObject = this;
- }
- else
- {
- previousObject = this.children[index-1].last;
- }
-
- nextObject = previousObject._iNext;
-
- // always true in this case
- if(nextObject)
- {
- nextObject._iPrev = childLast;
- childLast._iNext = nextObject;
- }
-
- childFirst._iPrev = previousObject;
- previousObject._iNext = childFirst;
-
- this.children.splice(index, 0, child);
- // need to remove any render groups..
- if(this.__renderGroup)
- {
- // being used by a renderTexture.. if it exists then it must be from a render texture;
- if(child.__renderGroup)child.__renderGroup.removeDisplayObjectAndChildren(child);
- // add them to the new render group..
- this.__renderGroup.addDisplayObjectAndChildren(child);
- }
-
- }
- else
- {
- throw new Error(child + " The index "+ index +" supplied is out of bounds " + this.children.length);
- }
-}
-
-/**
- * [NYI] Swaps the depth of 2 displayObjects
- *
- * @method swapChildren
- * @param child {DisplayObject}
- * @param child2 {DisplayObject}
- * @private
- */
-PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2)
-{
- /*
- * this funtion needs to be recoded..
- * can be done a lot faster..
- */
- return;
-
- // need to fix this function :/
- /*
- // TODO I already know this??
- var index = this.children.indexOf( child );
- var index2 = this.children.indexOf( child2 );
-
- if ( index !== -1 && index2 !== -1 )
- {
- // cool
-
- /*
- if(this.stage)
- {
- // this is to satisfy the webGL batching..
- // TODO sure there is a nicer way to achieve this!
- this.stage.__removeChild(child);
- this.stage.__removeChild(child2);
-
- this.stage.__addChild(child);
- this.stage.__addChild(child2);
- }
-
- // swap the positions..
- this.children[index] = child2;
- this.children[index2] = child;
-
- }
- else
- {
- throw new Error(child + " Both the supplied DisplayObjects must be a child of the caller " + this);
- }*/
-}
-
-/**
- * Returns the Child at the specified index
- *
- * @method getChildAt
- * @param index {Number} The index to get the child from
- */
-PIXI.DisplayObjectContainer.prototype.getChildAt = function(index)
-{
- if(index >= 0 && index < this.children.length)
- {
- return this.children[index];
- }
- else
- {
- throw new Error(child + " Both the supplied DisplayObjects must be a child of the caller " + this);
- }
-}
-
-/**
- * Removes a child from the container.
- *
- * @method removeChild
- * @param child {DisplayObject} The DisplayObject to remove
- */
-PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
-{
- var index = this.children.indexOf( child );
- if ( index !== -1 )
- {
- // unlink //
- // modify the list..
- var childFirst = child.first;
- var childLast = child.last;
-
- var nextObject = childLast._iNext;
- var previousObject = childFirst._iPrev;
-
- if(nextObject)nextObject._iPrev = previousObject;
- previousObject._iNext = nextObject;
-
- if(this.last == childLast)
- {
- var tempLast = childFirst._iPrev;
- // need to make sure the parents last is updated too
- var updateLast = this;
- while(updateLast.last == childLast.last)
- {
- updateLast.last = tempLast;
- updateLast = updateLast.parent;
- if(!updateLast)break;
- }
- }
-
- childLast._iNext = null;
- childFirst._iPrev = null;
-
- // update the stage reference..
- if(this.stage)
- {
- var tmpChild = child;
- do
- {
- if(tmpChild.interactive)this.stage.dirty = true;
- tmpChild.stage = null;
- tmpChild = tmpChild._iNext;
- }
- while(tmpChild)
- }
-
- // webGL trim
- if(child.__renderGroup)
- {
- child.__renderGroup.removeDisplayObjectAndChildren(child);
- }
-
- child.parent = undefined;
- this.children.splice( index, 1 );
- }
- else
- {
- throw new Error(child + " The supplied DisplayObject must be a child of the caller " + this);
- }
-}
-
-/*
- * Updates the container's children's transform for rendering
- *
- * @method updateTransform
- * @private
- */
-PIXI.DisplayObjectContainer.prototype.updateTransform = function()
-{
- if(!this.visible)return;
-
- PIXI.DisplayObject.prototype.updateTransform.call( this );
-
- for(var i=0,j=this.children.length; i 1)ratio = 1;
-
- var perpLength = Math.sqrt(perp.x * perp.x + perp.y * perp.y);
- var num = this.texture.height/2//(20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio;
- perp.x /= perpLength;
- perp.y /= perpLength;
-
- perp.x *= num;
- perp.y *= num;
-
- verticies[index] = point.x + perp.x
- verticies[index+1] = point.y + perp.y
- verticies[index+2] = point.x - perp.x
- verticies[index+3] = point.y - perp.y
-
- lastPoint = point;
- }
-
- PIXI.DisplayObjectContainer.prototype.updateTransform.call( this );
-}
-
-PIXI.Rope.prototype.setTexture = function(texture)
-{
- // stop current texture
- this.texture = texture;
- this.updateFrame = true;
-}
-
-
-
-
-
-/**
- * @author Mat Groves http://matgroves.com/
- */
-
-/**
- * A tiling sprite is a fast way of rendering a tiling image
- *
- * @class TilingSprite
- * @extends DisplayObjectContainer
- * @constructor
- * @param texture {Texture} the texture of the tiling sprite
- * @param width {Number} the width of the tiling sprite
- * @param height {Number} the height of the tiling sprite
- */
-PIXI.TilingSprite = function(texture, width, height)
-{
- PIXI.DisplayObjectContainer.call( this );
-
- /**
- * The texture that the sprite is using
- *
- * @property texture
- * @type Texture
- */
- this.texture = texture;
-
- /**
- * The width of the tiling sprite
- *
- * @property width
- * @type Number
- */
- this.width = width;
-
- /**
- * The height of the tiling sprite
- *
- * @property height
- * @type Number
- */
- this.height = height;
-
- /**
- * The scaling of the image that is being tiled
- *
- * @property tileScale
- * @type Point
- */
- this.tileScale = new PIXI.Point(1,1);
-
- /**
- * The offset position of the image that is being tiled
- *
- * @property tilePosition
- * @type Point
- */
- this.tilePosition = new PIXI.Point(0,0);
-
- this.renderable = true;
-
- this.blendMode = PIXI.blendModes.NORMAL
-}
-
-// constructor
-PIXI.TilingSprite.prototype = Object.create( PIXI.DisplayObjectContainer.prototype );
-PIXI.TilingSprite.prototype.constructor = PIXI.TilingSprite;
-
-/**
- * Sets the texture of the tiling sprite
- *
- * @method setTexture
- * @param texture {Texture} The PIXI texture that is displayed by the sprite
- */
-PIXI.TilingSprite.prototype.setTexture = function(texture)
-{
- //TODO SET THE TEXTURES
- //TODO VISIBILITY
-
- // stop current texture
- this.texture = texture;
- this.updateFrame = true;
-}
-
-/**
- * When the texture is updated, this event will fire to update the frame
- *
- * @method onTextureUpdate
- * @param event
- * @private
- */
-PIXI.TilingSprite.prototype.onTextureUpdate = function(event)
-{
- this.updateFrame = true;
-}
-
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- * This is the base class for creating a pixi.js filter. Currently only webGL supports filters.
- * If you want to make a custom filter this should be your base class.
- * @class AbstractFilter
- * @constructor
- * @param fragmentSrc
- * @param unifroms
- */
-PIXI.AbstractFilter = function(fragmentSrc, unifroms)
-{
- /**
- * An array of passes - some filters contain a few steps this array simply stores the steps in a liniear fashion.
- * For example the blur filter has two passes blurX and blurY.
- * @property passes
- * @type Array an array of filter objects
- * @private
- */
- this.passes = [this];
-
-
- this.dirty = true;
- this.padding = 0;
-
- /**
- @property uniforms
- @private
- */
- this.uniforms = unifroms || {};
-
- this.fragmentSrc = fragmentSrc || [];
-}
-
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- *
- * The BlurFilter applies a Gaussian blur to an object.
- * The strength of the blur can be set for x- and y-axis separately (always relative to the stage).
- *
- * @class BlurFilter
- * @contructor
- */
-PIXI.BlurFilter = function()
-{
-
- this.blurXFilter = new PIXI.BlurXFilter();
- this.blurYFilter = new PIXI.BlurYFilter();
-
- this.passes =[this.blurXFilter, this.blurYFilter];
-
-}
-
-/**
- * Sets the strength of both the blurX and blurY properties simultaneously
- *
- * @property blur
- * @type Number the strength of the blur
- * @default 2
- */
-Object.defineProperty(PIXI.BlurFilter.prototype, 'blur', {
- get: function() {
- return this.blurXFilter.blur;
- },
- set: function(value) {
- this.blurXFilter.blur = this.blurYFilter.blur = value;
- }
-});
-
-/**
- * Sets the strength of the blurX property simultaneously
- *
- * @property blurX
- * @type Number the strength of the blurX
- * @default 2
- */
-Object.defineProperty(PIXI.BlurFilter.prototype, 'blurX', {
- get: function() {
- return this.blurXFilter.blur;
- },
- set: function(value) {
- this.blurXFilter.blur = value;
- }
-});
-
-/**
- * Sets the strength of the blurX property simultaneously
- *
- * @property blurY
- * @type Number the strength of the blurY
- * @default 2
- */
-Object.defineProperty(PIXI.BlurFilter.prototype, 'blurY', {
- get: function() {
- return this.blurYFilter.blur;
- },
- set: function(value) {
- this.blurYFilter.blur = value;
- }
-});
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-
-PIXI.BlurXFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- blur: {type: 'f', value: 1/512},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform float blur;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "vec4 sum = vec4(0.0);",
-
- "sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;",
-
- "gl_FragColor = sum;",
-
- "}"
- ];
-}
-
-PIXI.BlurXFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.BlurXFilter.prototype.constructor = PIXI.BlurXFilter;
-
-
-Object.defineProperty(PIXI.BlurXFilter.prototype, 'blur', {
- get: function() {
- return this.uniforms.blur.value / (1/7000);
- },
- set: function(value) {
-
- this.dirty = true;
- this.uniforms.blur.value = (1/7000) * value;
- }
-});
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-
-PIXI.BlurYFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- blur: {type: 'f', value: 1/512},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform float blur;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "vec4 sum = vec4(0.0);",
-
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;",
- "sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;",
-
- "gl_FragColor = sum;",
-
- "}"
- ];
-}
-
-PIXI.BlurYFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.BlurYFilter.prototype.constructor = PIXI.BlurYFilter;
-
-Object.defineProperty(PIXI.BlurYFilter.prototype, 'blur', {
- get: function() {
- return this.uniforms.blur.value / (1/7000);
- },
- set: function(value) {
- //this.padding = value;
- this.uniforms.blur.value = (1/7000) * value;
- }
-});
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- *
- * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA
- * color and alpha values of every pixel on your displayObject to produce a result
- * with a new set of RGBA color and alpha values. Its pretty powerful!
- * @class ColorMatrixFilter
- * @contructor
- */
-PIXI.ColorMatrixFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- matrix: {type: 'mat4', value: [1,0,0,0,
- 0,1,0,0,
- 0,0,1,0,
- 0,0,0,1]},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform float invert;",
- "uniform mat4 matrix;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;",
- "gl_FragColor = gl_FragColor * vColor;",
- "}"
- ];
-
-}
-
-PIXI.ColorMatrixFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.ColorMatrixFilter.prototype.constructor = PIXI.ColorMatrixFilter;
-
-/**
- * Sets the matrix of the color matrix filter
- *
- * @property matrix
- * @type Array and array of 26 numbers
- * @default [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
- */
-Object.defineProperty(PIXI.ColorMatrixFilter.prototype, 'matrix', {
- get: function() {
- return this.uniforms.matrix.value;
- },
- set: function(value) {
- this.uniforms.matrix.value = value;
- }
-});
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-
-PIXI.CrossHatchFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- blur: {type: 'f', value: 1/512},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform float blur;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
-
-
- " float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);",
- " ",
- " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);",
- " ",
- " if (lum < 1.00) {",
- " if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {",
- " gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
- " }",
- " }",
- " ",
- " if (lum < 0.75) {",
- " if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {",
- " gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
- " }",
- " }",
- " ",
- " if (lum < 0.50) {",
- " if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
- " gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
- " }",
- " }",
- " ",
- " if (lum < 0.3) {",
- " if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
- " gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
- " }",
- " }",
- "}"
- ];
-}
-
-PIXI.CrossHatchFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.CrossHatchFilter.prototype.constructor = PIXI.BlurYFilter;
-
-Object.defineProperty(PIXI.CrossHatchFilter.prototype, 'blur', {
- get: function() {
- return this.uniforms.blur.value / (1/7000);
- },
- set: function(value) {
- //this.padding = value;
- this.uniforms.blur.value = (1/7000) * value;
- }
-});
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- *
- * The DisplacementFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object.
- * You can use this filter to apply all manor of crazy warping effects
- * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y.
- * @class DisplacementFilter
- * @contructor
- * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment
- */
-PIXI.DisplacementFilter = function(texture)
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
- texture.baseTexture._powerOf2 = true;
-
- // set the uniforms
- //console.log()
- this.uniforms = {
- displacementMap: {type: 'sampler2D', value:texture},
- scale: {type: 'f2', value:{x:30, y:30}},
- offset: {type: 'f2', value:{x:0, y:0}},
- mapDimensions: {type: 'f2', value:{x:1, y:5112}},
- dimensions: {type: 'f4', value:[0,0,0,0]}
- };
-
-
- if(texture.baseTexture.hasLoaded)
- {
- this.uniforms.mapDimensions.value.x = texture.width;
- this.uniforms.mapDimensions.value.y = texture.height;
- }
- else
- {
- this.boundLoadedFunction = this.onTextureLoaded.bind(this);
-
- texture.baseTexture.on("loaded", this.boundLoadedFunction);
- }
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform sampler2D displacementMap;",
- "uniform sampler2D uSampler;",
- "uniform vec2 scale;",
- "uniform vec2 offset;",
- "uniform vec4 dimensions;",
- "uniform vec2 mapDimensions;",// = vec2(256.0, 256.0);",
- // "const vec2 textureDimensions = vec2(750.0, 750.0);",
-
- "void main(void) {",
- "vec2 mapCords = vTextureCoord.xy;",
-// "mapCords -= ;",
- "mapCords += (dimensions.zw + offset)/ dimensions.xy ;",
- "mapCords.y *= -1.0;",
- "mapCords.y += 1.0;",
- "vec2 matSample = texture2D(displacementMap, mapCords).xy;",
- "matSample -= 0.5;",
- "matSample *= scale;",
- "matSample /= mapDimensions;",
- "gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));",
- "gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);",
- "vec2 cord = vTextureCoord;",
-
- //"gl_FragColor = texture2D(displacementMap, cord);",
- "gl_FragColor = gl_FragColor * vColor;",
-
- "}"
- ];
-
-}
-
-PIXI.DisplacementFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.DisplacementFilter.prototype.constructor = PIXI.DisplacementFilter;
-
-PIXI.DisplacementFilter.prototype.onTextureLoaded = function()
-{
-
- this.uniforms.mapDimensions.value.x = this.uniforms.displacementMap.value.width;
- this.uniforms.mapDimensions.value.y = this.uniforms.displacementMap.value.height;
-
- this.uniforms.displacementMap.value.baseTexture.off("loaded", this.boundLoadedFunction)
-
-}
-
-/**
- * The texture used for the displacemtent map * must be power of 2 texture at the moment
- *
- * @property map
- * @type Texture
- */
-Object.defineProperty(PIXI.DisplacementFilter.prototype, 'map', {
- get: function() {
- return this.uniforms.displacementMap.value;
- },
- set: function(value) {
- this.uniforms.displacementMap.value = value;
- }
-});
-
-/**
- * The multiplier used to scale the displacement result from the map calculation.
- *
- * @property scale
- * @type Point
- */
-Object.defineProperty(PIXI.DisplacementFilter.prototype, 'scale', {
- get: function() {
- return this.uniforms.scale.value;
- },
- set: function(value) {
- this.uniforms.scale.value = value;
- }
-});
-
-/**
- * The offset used to move the displacement map.
- *
- * @property offset
- * @type Point
- */
-Object.defineProperty(PIXI.DisplacementFilter.prototype, 'offset', {
- get: function() {
- return this.uniforms.offset.value;
- },
- set: function(value) {
- this.uniforms.offset.value = value;
- }
-});
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js
- */
-
-/**
- *
- * This filter applies a pixlate effect making display objects appear "blocky"
- * @class PixelateFilter
- * @contructor
- */
-PIXI.DotScreenFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- scale: {type: 'f', value:1},
- angle: {type: 'f', value:5},
- dimensions: {type: 'f4', value:[0,0,0,0]}
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform vec4 dimensions;",
- "uniform sampler2D uSampler;",
-
- "uniform float angle;",
- "uniform float scale;",
-
- "float pattern() {",
- "float s = sin(angle), c = cos(angle);",
- "vec2 tex = vTextureCoord * dimensions.xy;",
- "vec2 point = vec2(",
- "c * tex.x - s * tex.y,",
- "s * tex.x + c * tex.y",
- ") * scale;",
- "return (sin(point.x) * sin(point.y)) * 4.0;",
- "}",
-
- "void main() {",
- "vec4 color = texture2D(uSampler, vTextureCoord);",
- "float average = (color.r + color.g + color.b) / 3.0;",
- "gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);",
- "}",
- ];
-}
-
-PIXI.DotScreenFilter.prototype = Object.create( PIXI.DotScreenFilter.prototype );
-PIXI.DotScreenFilter.prototype.constructor = PIXI.DotScreenFilter;
-
-/**
- *
- * This describes the the scale
- * @property scale
- * @type Number
- */
-Object.defineProperty(PIXI.DotScreenFilter.prototype, 'scale', {
- get: function() {
- return this.uniforms.scale.value;
- },
- set: function(value) {
- this.dirty = true;
- this.uniforms.scale.value = value;
- }
-});
-
-/**
- *
- * This radius describes angle
- * @property angle
- * @type Number
- */
-Object.defineProperty(PIXI.DotScreenFilter.prototype, 'angle', {
- get: function() {
- return this.uniforms.angle.value;
- },
- set: function(value) {
- this.dirty = true;
- this.uniforms.angle.value = value;
- }
-});
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-
-PIXI.FilterBlock = function()
-{
- this.visible = true;
- this.renderable = true;
-}
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- *
- * This turns your displayObjects to black and white.
- * @class GreyFilter
- * @contructor
- */
-PIXI.GreyFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- grey: {type: 'f', value: 1},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform sampler2D uSampler;",
- "uniform float grey;",
- "void main(void) {",
- "gl_FragColor = texture2D(uSampler, vTextureCoord);",
- "gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);",
- "gl_FragColor = gl_FragColor * vColor;",
- "}"
- ];
-}
-
-PIXI.GreyFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.GreyFilter.prototype.constructor = PIXI.GreyFilter;
-
-/**
-The strength of the grey. 1 will make the object black and white, 0 will make the object its normal color
-@property grey
-*/
-Object.defineProperty(PIXI.GreyFilter.prototype, 'grey', {
- get: function() {
- return this.uniforms.grey.value;
- },
- set: function(value) {
- this.uniforms.grey.value = value;
- }
-});
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- *
- * This inverts your displayObjects colors.
- * @class InvertFilter
- * @contructor
- */
-PIXI.InvertFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- invert: {type: 'f', value: 1},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform float invert;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "gl_FragColor = texture2D(uSampler, vTextureCoord);",
- "gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);",
- //"gl_FragColor.rgb = gl_FragColor.rgb * gl_FragColor.a;",
- "gl_FragColor = gl_FragColor * vColor;",
- "}"
- ];
-
-}
-
-PIXI.InvertFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.InvertFilter.prototype.constructor = PIXI.InvertFilter;
-
-/**
-The strength of the invert. 1 will fully invert the colors, 0 will make the object its normal color
-@property invert
-*/
-Object.defineProperty(PIXI.InvertFilter.prototype, 'invert', {
- get: function() {
- return this.uniforms.invert.value;
- },
- set: function(value) {
- this.uniforms.invert.value = value;
- }
-});
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- *
- * This filter applies a pixlate effect making display objects appear "blocky"
- * @class PixelateFilter
- * @contructor
- */
-PIXI.PixelateFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- invert: {type: 'f', value: 0},
- dimensions: {type: 'f4', value:new Float32Array([10000, 100, 10, 10])},
- pixelSize: {type: 'f2', value:{x:10, y:10}},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform vec2 testDim;",
- "uniform vec4 dimensions;",
- "uniform vec2 pixelSize;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "vec2 coord = vTextureCoord;",
-
- "vec2 size = dimensions.xy/pixelSize;",
-
- "vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;",
- "gl_FragColor = texture2D(uSampler, color);",
- "}"
- ];
-
-
-}
-
-PIXI.PixelateFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.PixelateFilter.prototype.constructor = PIXI.PixelateFilter;
-
-/**
- *
- * This a point that describes the size of the blocs. x is the width of the block and y is the the height
- * @property size
- * @type Point
- */
-Object.defineProperty(PIXI.PixelateFilter.prototype, 'size', {
- get: function() {
- return this.uniforms.pixelSize.value;
- },
- set: function(value) {
- this.dirty = true;
- this.uniforms.pixelSize.value = value;
- }
-});
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-
-PIXI.RGBSplitFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- red: {type: 'f2', value: {x:20, y:20}},
- green: {type: 'f2', value: {x:-20, y:20}},
- blue: {type: 'f2', value: {x:20, y:-20}},
- dimensions: {type: 'f4', value:[0,0,0,0]}
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform vec2 red;",
- "uniform vec2 green;",
- "uniform vec2 blue;",
- "uniform vec4 dimensions;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;",
- "gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;",
- "gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;",
- "gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;",
- "}"
- ];
-}
-
-PIXI.RGBSplitFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.RGBSplitFilter.prototype.constructor = PIXI.RGBSplitFilter;
-
-Object.defineProperty(PIXI.RGBSplitFilter.prototype, 'angle', {
- get: function() {
- return this.uniforms.blur.value / (1/7000);
- },
- set: function(value) {
- //this.padding = value;
- this.uniforms.blur.value = (1/7000) * value;
- }
-});
-
-/**
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- *
- * This applies a sepia effect to your displayObjects.
- * @class SepiaFilter
- * @contructor
- */
-PIXI.SepiaFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- sepia: {type: 'f', value: 1},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform float sepia;",
- "uniform sampler2D uSampler;",
-
- "const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);",
- "void main(void) {",
- "gl_FragColor = texture2D(uSampler, vTextureCoord);",
- "gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);",
- "gl_FragColor = gl_FragColor * vColor;",
- "}"
- ];
-
-}
-
-PIXI.SepiaFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.SepiaFilter.prototype.constructor = PIXI.SepiaFilter;
-
-/**
-The strength of the sepia. 1 will apply the full sepia effect, 0 will make the object its normal color
-@property sepia
-*/
-Object.defineProperty(PIXI.SepiaFilter.prototype, 'sepia', {
- get: function() {
- return this.uniforms.sepia.value;
- },
- set: function(value) {
- this.uniforms.sepia.value = value;
- }
-});
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-
-PIXI.SmartBlurFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- blur: {type: 'f', value: 1/512},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "uniform sampler2D uSampler;",
- // "uniform vec2 delta;",
- "const vec2 delta = vec2(1.0/10.0, 0.0);",
- // "uniform float darkness;",
-
- "float random(vec3 scale, float seed) {",
- "return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);",
- "}",
-
-
- "void main(void) {",
-
- "vec4 color = vec4(0.0);",
- "float total = 0.0;",
-
- "float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);",
-
- "for (float t = -30.0; t <= 30.0; t++) {",
- "float percent = (t + offset - 0.5) / 30.0;",
- "float weight = 1.0 - abs(percent);",
- "vec4 sample = texture2D(uSampler, vTextureCoord + delta * percent);",
- "sample.rgb *= sample.a;",
- "color += sample * weight;",
- "total += weight;",
- "}",
-
- "gl_FragColor = color / total;",
- "gl_FragColor.rgb /= gl_FragColor.a + 0.00001;",
- // "gl_FragColor.rgb *= darkness;",
- "}"
- ];
-}
-
-PIXI.SmartBlurFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.SmartBlurFilter.prototype.constructor = PIXI.SmartBlurFilter;
-
-Object.defineProperty(PIXI.SmartBlurFilter.prototype, 'blur', {
- get: function() {
- return this.uniforms.blur.value;
- },
- set: function(value) {
- this.uniforms.blur.value = value;
- }
-});
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- *
- * This filter applies a pixlate effect making display objects appear "blocky"
- * @class PixelateFilter
- * @contructor
- */
-PIXI.TwistFilter = function()
-{
- PIXI.AbstractFilter.call( this );
-
- this.passes = [this];
-
- // set the uniforms
- this.uniforms = {
- radius: {type: 'f', value:0.5},
- angle: {type: 'f', value:5},
- offset: {type: 'f2', value:{x:0.5, y:0.5}},
- };
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform vec4 dimensions;",
- "uniform sampler2D uSampler;",
-
- "uniform float radius;",
- "uniform float angle;",
- "uniform vec2 offset;",
-
- "void main(void) {",
- "vec2 coord = vTextureCoord - offset;",
- "float distance = length(coord);",
-
- "if (distance < radius){",
-
- "float ratio = (radius - distance) / radius;",
- "float angleMod = ratio * ratio * angle;",
- "float s = sin(angleMod);",
- "float c = cos(angleMod);",
- "coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);",
-
- "}",
-
- "gl_FragColor = texture2D(uSampler, coord+offset);",
- "}"
- ];
-}
-
-PIXI.TwistFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
-PIXI.TwistFilter.prototype.constructor = PIXI.TwistFilter;
-
-/**
- *
- * This point describes the the offset of the twist
- * @property size
- * @type Point
- */
-Object.defineProperty(PIXI.TwistFilter.prototype, 'offset', {
- get: function() {
- return this.uniforms.offset.value;
- },
- set: function(value) {
- this.dirty = true;
- this.uniforms.offset.value = value;
- }
-});
-
-/**
- *
- * This radius describes size of the twist
- * @property size
- * @type Number
- */
-Object.defineProperty(PIXI.TwistFilter.prototype, 'radius', {
- get: function() {
- return this.uniforms.radius.value;
- },
- set: function(value) {
- this.dirty = true;
- this.uniforms.radius.value = value;
- }
-});
-
-/**
- *
- * This radius describes angle of the twist
- * @property angle
- * @type Number
- */
-Object.defineProperty(PIXI.TwistFilter.prototype, 'angle', {
- get: function() {
- return this.uniforms.angle.value;
- },
- set: function(value) {
- this.dirty = true;
- this.uniforms.angle.value = value;
- }
-});
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- * The Graphics class contains a set of methods that you can use to create primitive shapes and lines.
- * It is important to know that with the webGL renderer only simple polys can be filled at this stage
- * Complex polys will not be filled. Heres an example of a complex poly: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png
- *
- * @class Graphics
- * @extends DisplayObjectContainer
- * @constructor
- */
-PIXI.Graphics = function()
-{
- PIXI.DisplayObjectContainer.call( this );
-
- this.renderable = true;
-
- /**
- * The alpha of the fill of this graphics object
- *
- * @property fillAlpha
- * @type Number
- */
- this.fillAlpha = 1;
-
- /**
- * The width of any lines drawn
- *
- * @property lineWidth
- * @type Number
- */
- this.lineWidth = 0;
-
- /**
- * The color of any lines drawn
- *
- * @property lineColor
- * @type String
- */
- this.lineColor = "black";
-
- /**
- * Graphics data
- *
- * @property graphicsData
- * @type Array
- * @private
- */
- this.graphicsData = [];
-
- /**
- * Current path
- *
- * @property currentPath
- * @type Object
- * @private
- */
- this.currentPath = {points:[]};
-}
-
-// constructor
-PIXI.Graphics.prototype = Object.create( PIXI.DisplayObjectContainer.prototype );
-PIXI.Graphics.prototype.constructor = PIXI.Graphics;
-
-/**
- * Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method.
- *
- * @method lineStyle
- * @param lineWidth {Number} width of the line to draw, will update the object's stored style
- * @param color {Number} color of the line to draw, will update the object's stored style
- * @param alpha {Number} alpha of the line to draw, will update the object's stored style
- */
-PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha)
-{
- if(this.currentPath.points.length == 0)this.graphicsData.pop();
-
- this.lineWidth = lineWidth || 0;
- this.lineColor = color || 0;
- this.lineAlpha = (alpha == undefined) ? 1 : alpha;
-
- this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
- fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
-
- this.graphicsData.push(this.currentPath);
-}
-
-/**
- * Moves the current drawing position to (x, y).
- *
- * @method moveTo
- * @param x {Number} the X coord to move to
- * @param y {Number} the Y coord to move to
- */
-PIXI.Graphics.prototype.moveTo = function(x, y)
-{
- if(this.currentPath.points.length == 0)this.graphicsData.pop();
-
- this.currentPath = this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
- fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
-
- this.currentPath.points.push(x, y);
-
- this.graphicsData.push(this.currentPath);
-}
-
-/**
- * Draws a line using the current line style from the current drawing position to (x, y);
- * the current drawing position is then set to (x, y).
- *
- * @method lineTo
- * @param x {Number} the X coord to draw to
- * @param y {Number} the Y coord to draw to
- */
-PIXI.Graphics.prototype.lineTo = function(x, y)
-{
- this.currentPath.points.push(x, y);
- this.dirty = true;
-}
-
-/**
- * Specifies a simple one-color fill that subsequent calls to other Graphics methods
- * (such as lineTo() or drawCircle()) use when drawing.
- *
- * @method beginFill
- * @param color {uint} the color of the fill
- * @param alpha {Number} the alpha
- */
-PIXI.Graphics.prototype.beginFill = function(color, alpha)
-{
- this.filling = true;
- this.fillColor = color || 0;
- this.fillAlpha = (alpha == undefined) ? 1 : alpha;
-}
-
-/**
- * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method.
- *
- * @method endFill
- */
-PIXI.Graphics.prototype.endFill = function()
-{
- this.filling = false;
- this.fillColor = null;
- this.fillAlpha = 1;
-}
-
-/**
- * @method drawRect
- *
- * @param x {Number} The X coord of the top-left of the rectangle
- * @param y {Number} The Y coord of the top-left of the rectangle
- * @param width {Number} The width of the rectangle
- * @param height {Number} The height of the rectangle
- */
-PIXI.Graphics.prototype.drawRect = function( x, y, width, height )
-{
- if(this.currentPath.points.length == 0)this.graphicsData.pop();
-
- this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
- fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling,
- points:[x, y, width, height], type:PIXI.Graphics.RECT};
-
- this.graphicsData.push(this.currentPath);
- this.dirty = true;
-}
-
-/**
- * Draws a circle.
- *
- * @method drawCircle
- * @param x {Number} The X coord of the center of the circle
- * @param y {Number} The Y coord of the center of the circle
- * @param radius {Number} The radius of the circle
- */
-PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
-{
- if(this.currentPath.points.length == 0)this.graphicsData.pop();
-
- this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
- fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling,
- points:[x, y, radius, radius], type:PIXI.Graphics.CIRC};
-
- this.graphicsData.push(this.currentPath);
- this.dirty = true;
-}
-
-/**
- * Draws an elipse.
- *
- * @method drawElipse
- * @param x {Number}
- * @param y {Number}
- * @param width {Number}
- * @param height {Number}
- */
-PIXI.Graphics.prototype.drawElipse = function( x, y, width, height)
-{
- if(this.currentPath.points.length == 0)this.graphicsData.pop();
-
- this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
- fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling,
- points:[x, y, width, height], type:PIXI.Graphics.ELIP};
-
- this.graphicsData.push(this.currentPath);
- this.dirty = true;
-}
-
-/**
- * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
- *
- * @method clear
- */
-PIXI.Graphics.prototype.clear = function()
-{
- this.lineWidth = 0;
- this.filling = false;
-
- this.dirty = true;
- this.clearDirty = true;
- this.graphicsData = [];
-
- this.bounds = null//new PIXI.Rectangle();
-}
-
-
-PIXI.Graphics.prototype.updateFilterBounds = function()
-{
- if(!this.bounds)
- {
- var minX = Infinity;
- var maxX = -Infinity;
-
- var minY = Infinity;
- var maxY = -Infinity;
-
- var points, x, y;
-
- for (var i = 0; i < this.graphicsData.length; i++) {
-
-
- var data = this.graphicsData[i];
- var type = data.type;
- var lineWidth = data.lineWidth;
-
- points = data.points;
-
- if(type === PIXI.Graphics.RECT)
- {
- x = points.x - lineWidth/2;
- y = points.y - lineWidth/2;
- var width = points.width + lineWidth;
- var height = points.height + lineWidth;
-
- minX = x < minX ? x : minX;
- maxX = x + width > maxX ? x + width : maxX;
-
- minY = y < minY ? x : minY;
- maxY = y + height > maxY ? y + height : maxY;
- }
- else if(type === PIXI.Graphics.CIRC || type === PIXI.Graphics.ELIP)
- {
- x = points.x;
- y = points.y;
- var radius = points.radius + lineWidth/2;
-
- minX = x - radius < minX ? x - radius : minX;
- maxX = x + radius > maxX ? x + radius : maxX;
-
- minY = y - radius < minY ? y - radius : minY;
- maxY = y + radius > maxY ? y + radius : maxY;
- }
- else
- {
- // POLY
- for (var j = 0; j < points.length; j+=2)
- {
-
- x = points[j];
- y = points[j+1];
-
- minX = x-lineWidth < minX ? x-lineWidth : minX;
- maxX = x+lineWidth > maxX ? x+lineWidth : maxX;
-
- minY = y-lineWidth < minY ? y-lineWidth : minY;
- maxY = y+lineWidth > maxY ? y+lineWidth : maxY;
- };
- }
-
- };
-
- this.bounds = new PIXI.Rectangle(minX, minY, maxX - minX, maxY - minY);
-
- }
-
-// console.log(this.bounds);
-}
-
-// SOME TYPES:
-PIXI.Graphics.POLY = 0;
-PIXI.Graphics.RECT = 1;
-PIXI.Graphics.CIRC = 2;
-PIXI.Graphics.ELIP = 3;
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- * A set of functions used by the canvas renderer to draw the primitive graphics data
- *
- * @class CanvasGraphics
- */
-PIXI.CanvasGraphics = function()
-{
-
-}
-
-
-/*
- * Renders the graphics object
- *
- * @static
- * @private
- * @method renderGraphics
- * @param graphics {Graphics}
- * @param context {Context2D}
- */
-PIXI.CanvasGraphics.renderGraphics = function(graphics, context)
-{
- var worldAlpha = graphics.worldAlpha;
-
- for (var i=0; i < graphics.graphicsData.length; i++)
- {
- var data = graphics.graphicsData[i];
- var points = data.points;
-
- context.strokeStyle = color = '#' + ('00000' + ( data.lineColor | 0).toString(16)).substr(-6);
-
- context.lineWidth = data.lineWidth;
-
- if(data.type == PIXI.Graphics.POLY)
- {
- context.beginPath();
-
- context.moveTo(points[0], points[1]);
-
- for (var j=1; j < points.length/2; j++)
- {
- context.lineTo(points[j * 2], points[j * 2 + 1]);
- }
-
- // if the first and last point are the same close the path - much neater :)
- if(points[0] == points[points.length-2] && points[1] == points[points.length-1])
- {
- context.closePath();
- }
-
- if(data.fill)
- {
- context.globalAlpha = data.fillAlpha * worldAlpha;
- context.fillStyle = color = '#' + ('00000' + ( data.fillColor | 0).toString(16)).substr(-6);
- context.fill();
- }
- if(data.lineWidth)
- {
- context.globalAlpha = data.lineAlpha * worldAlpha;
- context.stroke();
- }
- }
- else if(data.type == PIXI.Graphics.RECT)
- {
-
- if(data.fillColor || data.fillColor === 0)
- {
- context.globalAlpha = data.fillAlpha * worldAlpha;
- context.fillStyle = color = '#' + ('00000' + ( data.fillColor | 0).toString(16)).substr(-6);
- context.fillRect(points[0], points[1], points[2], points[3]);
-
- }
- if(data.lineWidth)
- {
- context.globalAlpha = data.lineAlpha * worldAlpha;
- context.strokeRect(points[0], points[1], points[2], points[3]);
- }
-
- }
- else if(data.type == PIXI.Graphics.CIRC)
- {
- // TODO - need to be Undefined!
- context.beginPath();
- context.arc(points[0], points[1], points[2],0,2*Math.PI);
- context.closePath();
-
- if(data.fill)
- {
- context.globalAlpha = data.fillAlpha * worldAlpha;
- context.fillStyle = color = '#' + ('00000' + ( data.fillColor | 0).toString(16)).substr(-6);
- context.fill();
- }
- if(data.lineWidth)
- {
- context.globalAlpha = data.lineAlpha * worldAlpha;
- context.stroke();
- }
- }
- else if(data.type == PIXI.Graphics.ELIP)
- {
-
- // elipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
-
- var elipseData = data.points;
-
- var w = elipseData[2] * 2;
- var h = elipseData[3] * 2;
-
- var x = elipseData[0] - w/2;
- var y = elipseData[1] - h/2;
-
- context.beginPath();
-
- var kappa = .5522848,
- ox = (w / 2) * kappa, // control point offset horizontal
- oy = (h / 2) * kappa, // control point offset vertical
- xe = x + w, // x-end
- ye = y + h, // y-end
- xm = x + w / 2, // x-middle
- ym = y + h / 2; // y-middle
-
- context.moveTo(x, ym);
- context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
- context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
- context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
- context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
-
- context.closePath();
-
- if(data.fill)
- {
- context.globalAlpha = data.fillAlpha * worldAlpha;
- context.fillStyle = color = '#' + ('00000' + ( data.fillColor | 0).toString(16)).substr(-6);
- context.fill();
- }
- if(data.lineWidth)
- {
- context.globalAlpha = data.lineAlpha * worldAlpha;
- context.stroke();
- }
- }
-
- };
-}
-
-/*
- * Renders a graphics mask
- *
- * @static
- * @private
- * @method renderGraphicsMask
- * @param graphics {Graphics}
- * @param context {Context2D}
- */
-PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
-{
- var worldAlpha = graphics.worldAlpha;
-
- var len = graphics.graphicsData.length;
- if(len === 0)return;
-
- if(len > 1)
- {
- len = 1;
- console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object")
- }
-
- for (var i=0; i < 1; i++)
- {
- var data = graphics.graphicsData[i];
- var points = data.points;
-
- if(data.type == PIXI.Graphics.POLY)
- {
- context.beginPath();
- context.moveTo(points[0], points[1]);
-
- for (var j=1; j < points.length/2; j++)
- {
- context.lineTo(points[j * 2], points[j * 2 + 1]);
- }
-
- // if the first and last point are the same close the path - much neater :)
- if(points[0] == points[points.length-2] && points[1] == points[points.length-1])
- {
- context.closePath();
- }
-
- }
- else if(data.type == PIXI.Graphics.RECT)
- {
- context.beginPath();
- context.rect(points[0], points[1], points[2], points[3]);
- context.closePath();
- }
- else if(data.type == PIXI.Graphics.CIRC)
- {
- // TODO - need to be Undefined!
- context.beginPath();
- context.arc(points[0], points[1], points[2],0,2*Math.PI);
- context.closePath();
- }
- else if(data.type == PIXI.Graphics.ELIP)
- {
-
- // elipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
- var elipseData = data.points;
-
- var w = elipseData[2] * 2;
- var h = elipseData[3] * 2;
-
- var x = elipseData[0] - w/2;
- var y = elipseData[1] - h/2;
-
- context.beginPath();
-
- var kappa = .5522848,
- ox = (w / 2) * kappa, // control point offset horizontal
- oy = (h / 2) * kappa, // control point offset vertical
- xe = x + w, // x-end
- ye = y + h, // y-end
- xm = x + w / 2, // x-middle
- ym = y + h / 2; // y-middle
-
- context.moveTo(x, ym);
- context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
- context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
- context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
- context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
- context.closePath();
- }
-
-
- };
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-/**
- * the CanvasRenderer draws the stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL.
- * Dont forget to add the view to your DOM or you will not see anything :)
- *
- * @class CanvasRenderer
- * @constructor
- * @param width=0 {Number} the width of the canvas view
- * @param height=0 {Number} the height of the canvas view
- * @param view {Canvas} the canvas to use as a view, optional
- * @param transparent=false {Boolean} the transparency of the render view, default false
- */
-PIXI.CanvasRenderer = function(width, height, view, transparent)
-{
- this.transparent = transparent;
-
- /**
- * The width of the canvas view
- *
- * @property width
- * @type Number
- * @default 800
- */
- this.width = width || 800;
-
- /**
- * The height of the canvas view
- *
- * @property height
- * @type Number
- * @default 600
- */
- this.height = height || 600;
-
- /**
- * The canvas element that the everything is drawn to
- *
- * @property view
- * @type Canvas
- */
- this.view = view || document.createElement( 'canvas' );
-
- /**
- * The canvas context that the everything is drawn to
- * @property context
- * @type Canvas 2d Context
- */
- this.context = this.view.getContext("2d");
-
- this.refresh = true;
- // hack to enable some hardware acceleration!
- //this.view.style["transform"] = "translatez(0)";
-
- this.view.width = this.width;
- this.view.height = this.height;
- this.count = 0;
-}
-
-// constructor
-PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer;
-
-/**
- * Renders the stage to its canvas view
- *
- * @method render
- * @param stage {Stage} the Stage element to be rendered
- */
-PIXI.CanvasRenderer.prototype.render = function(stage)
-{
-
- //stage.__childrenAdded = [];
- //stage.__childrenRemoved = [];
-
- // update textures if need be
- PIXI.texturesToUpdate = [];
- PIXI.texturesToDestroy = [];
-
- PIXI.visibleCount++;
- stage.updateTransform();
-
- // update the background color
- if(this.view.style.backgroundColor!=stage.backgroundColorString && !this.transparent)this.view.style.backgroundColor = stage.backgroundColorString;
-
- this.context.setTransform(1,0,0,1,0,0);
- this.context.clearRect(0, 0, this.width, this.height)
- this.renderDisplayObject(stage);
- //as
-
- // run interaction!
- if(stage.interactive)
- {
- //need to add some events!
- if(!stage._interactiveEventsAdded)
- {
- stage._interactiveEventsAdded = true;
- stage.interactionManager.setTarget(this);
- }
- }
-
- // remove frame updates..
- if(PIXI.Texture.frameUpdates.length > 0)
- {
- PIXI.Texture.frameUpdates = [];
- }
-
-
-}
-
-/**
- * resizes the canvas view to the specified width and height
- *
- * @method resize
- * @param width {Number} the new width of the canvas view
- * @param height {Number} the new height of the canvas view
- */
-PIXI.CanvasRenderer.prototype.resize = function(width, height)
-{
- this.width = width;
- this.height = height;
-
- this.view.width = width;
- this.view.height = height;
-}
-
-/**
- * Renders a display object
- *
- * @method renderDisplayObject
- * @param displayObject {DisplayObject} The displayObject to render
- * @private
- */
-PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
-{
- // no loger recurrsive!
- var transform;
- var context = this.context;
-
- context.globalCompositeOperation = 'source-over';
-
- // one the display object hits this. we can break the loop
- var testObject = displayObject.last._iNext;
- displayObject = displayObject.first;
-
- do
- {
- transform = displayObject.worldTransform;
-
- if(!displayObject.visible)
- {
- displayObject = displayObject.last._iNext;
- continue;
- }
-
- if(!displayObject.renderable)
- {
- displayObject = displayObject._iNext;
- continue;
- }
-
- if(displayObject instanceof PIXI.Sprite)
- {
-
- var frame = displayObject.texture.frame;
-
- if(frame && frame.width && frame.height)
- {
- context.globalAlpha = displayObject.worldAlpha;
-
- context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
-
- context.drawImage(displayObject.texture.baseTexture.source,
- frame.x,
- frame.y,
- frame.width,
- frame.height,
- (displayObject.anchor.x) * -frame.width,
- (displayObject.anchor.y) * -frame.height,
- frame.width,
- frame.height);
- }
- }
- else if(displayObject instanceof PIXI.Strip)
- {
- context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5])
- this.renderStrip(displayObject);
- }
- else if(displayObject instanceof PIXI.TilingSprite)
- {
- context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5])
- this.renderTilingSprite(displayObject);
- }
- else if(displayObject instanceof PIXI.CustomRenderable)
- {
- context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
- displayObject.renderCanvas(this);
- }
- else if(displayObject instanceof PIXI.Graphics)
- {
- context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5])
- PIXI.CanvasGraphics.renderGraphics(displayObject, context);
- }
- else if(displayObject instanceof PIXI.FilterBlock)
- {
- if(displayObject.data instanceof PIXI.Graphics)
- {
- var mask = displayObject.data;
-
- if(displayObject.open)
- {
- context.save();
-
- var cacheAlpha = mask.alpha;
- var maskTransform = mask.worldTransform;
-
- context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5])
-
- mask.worldAlpha = 0.5;
-
- context.worldAlpha = 0;
-
- PIXI.CanvasGraphics.renderGraphicsMask(mask, context);
- context.clip();
-
- mask.worldAlpha = cacheAlpha;
- }
- else
- {
- context.restore();
- }
- }
- else
- {
- // only masks supported right now!
- }
- }
- // count++
- displayObject = displayObject._iNext;
-
-
- }
- while(displayObject != testObject)
-
-
-}
-
-/**
- * Renders a flat strip
- *
- * @method renderStripFlat
- * @param strip {Strip} The Strip to render
- * @private
- */
-PIXI.CanvasRenderer.prototype.renderStripFlat = function(strip)
-{
- var context = this.context;
- var verticies = strip.verticies;
- var uvs = strip.uvs;
-
- var length = verticies.length/2;
- this.count++;
-
- context.beginPath();
- for (var i=1; i < length-2; i++)
- {
-
- // draw some triangles!
- var index = i*2;
-
- var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4];
- var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5];
-
- context.moveTo(x0, y0);
- context.lineTo(x1, y1);
- context.lineTo(x2, y2);
-
- };
-
- context.fillStyle = "#FF0000";
- context.fill();
- context.closePath();
-}
-
-/**
- * Renders a tiling sprite
- *
- * @method renderTilingSprite
- * @param sprite {TilingSprite} The tilingsprite to render
- * @private
- */
-PIXI.CanvasRenderer.prototype.renderTilingSprite = function(sprite)
-{
- var context = this.context;
-
- context.globalAlpha = sprite.worldAlpha;
-
- if(!sprite.__tilePattern) sprite.__tilePattern = context.createPattern(sprite.texture.baseTexture.source, "repeat");
-
- context.beginPath();
-
- var tilePosition = sprite.tilePosition;
- var tileScale = sprite.tileScale;
-
- // offset
- context.scale(tileScale.x,tileScale.y);
- context.translate(tilePosition.x, tilePosition.y);
-
- context.fillStyle = sprite.__tilePattern;
- context.fillRect(-tilePosition.x,-tilePosition.y,sprite.width / tileScale.x, sprite.height / tileScale.y);
-
- context.scale(1/tileScale.x, 1/tileScale.y);
- context.translate(-tilePosition.x, -tilePosition.y);
-
- context.closePath();
-}
-
-/**
- * Renders a strip
- *
- * @method renderStrip
- * @param strip {Strip} The Strip to render
- * @private
- */
-PIXI.CanvasRenderer.prototype.renderStrip = function(strip)
-{
- var context = this.context;
-
- // draw triangles!!
- var verticies = strip.verticies;
- var uvs = strip.uvs;
-
- var length = verticies.length/2;
- this.count++;
- for (var i=1; i < length-2; i++)
- {
-
- // draw some triangles!
- var index = i*2;
-
- var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4];
- var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5];
-
- var u0 = uvs[index] * strip.texture.width, u1 = uvs[index+2] * strip.texture.width, u2 = uvs[index+4]* strip.texture.width;
- var v0 = uvs[index+1]* strip.texture.height, v1 = uvs[index+3] * strip.texture.height, v2 = uvs[index+5]* strip.texture.height;
-
-
- context.save();
- context.beginPath();
- context.moveTo(x0, y0);
- context.lineTo(x1, y1);
- context.lineTo(x2, y2);
- context.closePath();
-
- context.clip();
-
-
- // Compute matrix transform
- var delta = u0*v1 + v0*u2 + u1*v2 - v1*u2 - v0*u1 - u0*v2;
- var delta_a = x0*v1 + v0*x2 + x1*v2 - v1*x2 - v0*x1 - x0*v2;
- var delta_b = u0*x1 + x0*u2 + u1*x2 - x1*u2 - x0*u1 - u0*x2;
- var delta_c = u0*v1*x2 + v0*x1*u2 + x0*u1*v2 - x0*v1*u2 - v0*u1*x2 - u0*x1*v2;
- var delta_d = y0*v1 + v0*y2 + y1*v2 - v1*y2 - v0*y1 - y0*v2;
- var delta_e = u0*y1 + y0*u2 + u1*y2 - y1*u2 - y0*u1 - u0*y2;
- var delta_f = u0*v1*y2 + v0*y1*u2 + y0*u1*v2 - y0*v1*u2 - v0*u1*y2 - u0*y1*v2;
-
-
-
-
- context.transform(delta_a/delta, delta_d/delta,
- delta_b/delta, delta_e/delta,
- delta_c/delta, delta_f/delta);
-
- context.drawImage(strip.texture.baseTexture.source, 0, 0);
- context.restore();
- };
-
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-PIXI.PixiShader = function()
-{
- // the webGL program..
- this.program;
-
- this.fragmentSrc = [
- "precision lowp float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;",
- "}"
- ];
-
-}
-
-PIXI.PixiShader.prototype.init = function()
-{
- var program = PIXI.compileProgram(this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc)
-
- var gl = PIXI.gl;
-
- gl.useProgram(program);
-
- // get and store the uniforms for the shader
- this.uSampler = gl.getUniformLocation(program, "uSampler");
- this.projectionVector = gl.getUniformLocation(program, "projectionVector");
- this.offsetVector = gl.getUniformLocation(program, "offsetVector");
- //this.dimensions = gl.getUniformLocation(this.program, "dimensions");
-
- // get and store the attributes
- this.aVertexPosition = gl.getAttribLocation(program, "aVertexPosition");
- this.colorAttribute = gl.getAttribLocation(program, "aColor");
- this.aTextureCoord = gl.getAttribLocation(program, "aTextureCoord");
-
- // add those custom shaders!
- for (var key in this.uniforms)
- {
-
- // get the uniform locations..
- // program[key] =
- this.uniforms[key].uniformLocation = gl.getUniformLocation(program, key);
-
-
- }
-
- this.program = program;
-}
-
-PIXI.PixiShader.prototype.syncUniforms = function()
-{
- var gl = PIXI.gl;
-
- for (var key in this.uniforms)
- {
- //var
- var type = this.uniforms[key].type;
-
- // need to grow this!
- if(type == "f")
- {
- gl.uniform1f(this.uniforms[key].uniformLocation, this.uniforms[key].value);
- }
- if(type == "f2")
- {
- // console.log(this.program[key])
- gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y);
- }
- else if(type == "f4")
- {
- // console.log(this.uniforms[key].value)
- gl.uniform4fv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
- }
- else if(type == "mat4")
- {
- gl.uniformMatrix4fv(this.uniforms[key].uniformLocation, false, this.uniforms[key].value);
- }
- else if(type == "sampler2D")
- {
- // first texture...
- var texture = this.uniforms[key].value;
-
- gl.activeTexture(gl.TEXTURE1);
- gl.bindTexture(gl.TEXTURE_2D, texture.baseTexture._glTexture);
-
- gl.uniform1i(this.uniforms[key].uniformLocation, 1);
-
- // activate texture..
- // gl.uniformMatrix4fv(this.program[key], false, this.uniforms[key].value);
- // gl.uniformMatrix4fv(this.program[key], false, this.uniforms[key].value);
- }
- }
-
-}
-
-PIXI.PixiShader.defaultVertexSrc = [
- "attribute vec2 aVertexPosition;",
- "attribute vec2 aTextureCoord;",
- "attribute float aColor;",
-
- "uniform vec2 projectionVector;",
- "uniform vec2 offsetVector;",
- "varying vec2 vTextureCoord;",
-
- "varying float vColor;",
-
- "const vec2 center = vec2(-1.0, 1.0);",
- "void main(void) {",
- "gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);",
- "vTextureCoord = aTextureCoord;",
- "vColor = aColor;",
- "}"
-];
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-PIXI.PrimitiveShader = function()
-{
- // the webGL program..
- this.program;
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec4 vColor;",
- "void main(void) {",
- "gl_FragColor = vColor;",
- "}"
- ];
-
- this.vertexSrc = [
- "attribute vec2 aVertexPosition;",
- "attribute vec4 aColor;",
- "uniform mat3 translationMatrix;",
- "uniform vec2 projectionVector;",
- "uniform vec2 offsetVector;",
- "uniform float alpha;",
- "varying vec4 vColor;",
- "void main(void) {",
- "vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);",
- "v -= offsetVector.xyx;",
- "gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);",
- "vColor = aColor * alpha;",
- "}"
- ];
-
-}
-
-PIXI.PrimitiveShader.prototype.init = function()
-{
- var program = PIXI.compileProgram(this.vertexSrc, this.fragmentSrc);
-
- var gl = PIXI.gl;
-
- gl.useProgram(program);
-
- // get and store the uniforms for the shader
- this.projectionVector = gl.getUniformLocation(program, "projectionVector");
- this.offsetVector = gl.getUniformLocation(program, "offsetVector");
-
- // get and store the attributes
- this.aVertexPosition = gl.getAttribLocation(program, "aVertexPosition");
- this.colorAttribute = gl.getAttribLocation(program, "aColor");
-
- this.translationMatrix = gl.getUniformLocation(program, "translationMatrix");
- this.alpha = gl.getUniformLocation(program, "alpha");
-
- this.program = program;
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-PIXI.StripShader = function()
-{
- // the webGL program..
- this.program;
-
- this.fragmentSrc = [
- "precision mediump float;",
- "varying vec2 vTextureCoord;",
- "varying float vColor;",
- "uniform float alpha;",
- "uniform sampler2D uSampler;",
- "void main(void) {",
- "gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));",
- "gl_FragColor = gl_FragColor * alpha;",
- "}"
- ];
-
- this.vertexSrc = [
- "attribute vec2 aVertexPosition;",
- "attribute vec2 aTextureCoord;",
- "attribute float aColor;",
- "uniform mat3 translationMatrix;",
- "uniform vec2 projectionVector;",
- "varying vec2 vTextureCoord;",
- "varying vec2 offsetVector;",
- "varying float vColor;",
- "void main(void) {",
- "vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);",
- "v -= offsetVector.xyx;",
- "gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / projectionVector.y + 1.0 , 0.0, 1.0);",
- "vTextureCoord = aTextureCoord;",
- "vColor = aColor;",
- "}"
- ];
-}
-
-PIXI.StripShader.prototype.init = function()
-{
- var program = PIXI.compileProgram(this.vertexSrc, this.fragmentSrc)
-
- var gl = PIXI.gl;
-
- gl.useProgram(program);
-
- // get and store the uniforms for the shader
- this.uSampler = gl.getUniformLocation(program, "uSampler");
- this.projectionVector = gl.getUniformLocation(program, "projectionVector");
- this.offsetVector = gl.getUniformLocation(program, "offsetVector");
- this.colorAttribute = gl.getAttribLocation(program, "aColor");
- //this.dimensions = gl.getUniformLocation(this.program, "dimensions");
-
- // get and store the attributes
- this.aVertexPosition = gl.getAttribLocation(program, "aVertexPosition");
- this.aTextureCoord = gl.getAttribLocation(program, "aTextureCoord");
-
- this.translationMatrix = gl.getUniformLocation(program, "translationMatrix");
- this.alpha = gl.getUniformLocation(program, "alpha");
-
- this.program = program;
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-PIXI._batchs = [];
-
-/**
- * @private
- */
-PIXI._getBatch = function(gl)
-{
- if(PIXI._batchs.length == 0)
- {
- return new PIXI.WebGLBatch(gl);
- }
- else
- {
- return PIXI._batchs.pop();
- }
-}
-
-/**
- * @private
- */
-PIXI._returnBatch = function(batch)
-{
- batch.clean();
- PIXI._batchs.push(batch);
-}
-
-/**
- * @private
- */
-PIXI._restoreBatchs = function(gl)
-{
- for (var i=0; i < PIXI._batchs.length; i++)
- {
- PIXI._batchs[i].restoreLostContext(gl);
- };
-}
-
-/**
- * A WebGLBatch Enables a group of sprites to be drawn using the same settings.
- * if a group of sprites all have the same baseTexture and blendMode then they can be grouped into a batch.
- * All the sprites in a batch can then be drawn in one go by the GPU which is hugely efficient. ALL sprites
- * in the webGL renderer are added to a batch even if the batch only contains one sprite. Batching is handled
- * automatically by the webGL renderer. A good tip is: the smaller the number of batchs there are, the faster
- * the webGL renderer will run.
- *
- * @class WebGLBatch
- * @constructor
- * @param gl {WebGLContext} an instance of the webGL context
- */
-PIXI.WebGLBatch = function(gl)
-{
- this.gl = gl;
-
- this.size = 0;
-
- this.vertexBuffer = gl.createBuffer();
- this.indexBuffer = gl.createBuffer();
- this.uvBuffer = gl.createBuffer();
- this.colorBuffer = gl.createBuffer();
- this.blendMode = PIXI.blendModes.NORMAL;
- this.dynamicSize = 1;
-}
-
-// constructor
-PIXI.WebGLBatch.prototype.constructor = PIXI.WebGLBatch;
-
-/**
- * Cleans the batch so that is can be returned to an object pool and reused
- *
- * @method clean
- */
-PIXI.WebGLBatch.prototype.clean = function()
-{
- this.verticies = [];
- this.uvs = [];
- this.indices = [];
- this.colors = [];
- this.dynamicSize = 1;
- this.texture = null;
- this.last = null;
- this.size = 0;
- this.head;
- this.tail;
-}
-
-/**
- * Recreates the buffers in the event of a context loss
- *
- * @method restoreLostContext
- * @param gl {WebGLContext}
- */
-PIXI.WebGLBatch.prototype.restoreLostContext = function(gl)
-{
- this.gl = gl;
- this.vertexBuffer = gl.createBuffer();
- this.indexBuffer = gl.createBuffer();
- this.uvBuffer = gl.createBuffer();
- this.colorBuffer = gl.createBuffer();
-}
-
-/**
- * inits the batch's texture and blend mode based if the supplied sprite
- *
- * @method init
- * @param sprite {Sprite} the first sprite to be added to the batch. Only sprites with
- * the same base texture and blend mode will be allowed to be added to this batch
- */
-PIXI.WebGLBatch.prototype.init = function(sprite)
-{
- sprite.batch = this;
- this.dirty = true;
- this.blendMode = sprite.blendMode;
- this.texture = sprite.texture.baseTexture;
- this.head = sprite;
- this.tail = sprite;
- this.size = 1;
-
- this.growBatch();
-}
-
-/**
- * inserts a sprite before the specified sprite
- *
- * @method insertBefore
- * @param sprite {Sprite} the sprite to be added
- * @param nextSprite {nextSprite} the first sprite will be inserted before this sprite
- */
-PIXI.WebGLBatch.prototype.insertBefore = function(sprite, nextSprite)
-{
- this.size++;
-
- sprite.batch = this;
- this.dirty = true;
- var tempPrev = nextSprite.__prev;
- nextSprite.__prev = sprite;
- sprite.__next = nextSprite;
-
- if(tempPrev)
- {
- sprite.__prev = tempPrev;
- tempPrev.__next = sprite;
- }
- else
- {
- this.head = sprite;
- }
-}
-
-/**
- * inserts a sprite after the specified sprite
- *
- * @method insertAfter
- * @param sprite {Sprite} the sprite to be added
- * @param previousSprite {Sprite} the first sprite will be inserted after this sprite
- */
-PIXI.WebGLBatch.prototype.insertAfter = function(sprite, previousSprite)
-{
- this.size++;
-
- sprite.batch = this;
- this.dirty = true;
-
- var tempNext = previousSprite.__next;
- previousSprite.__next = sprite;
- sprite.__prev = previousSprite;
-
- if(tempNext)
- {
- sprite.__next = tempNext;
- tempNext.__prev = sprite;
- }
- else
- {
- this.tail = sprite
- }
-}
-
-/**
- * removes a sprite from the batch
- *
- * @method remove
- * @param sprite {Sprite} the sprite to be removed
- */
-PIXI.WebGLBatch.prototype.remove = function(sprite)
-{
- this.size--;
-
- if(this.size == 0)
- {
- sprite.batch = null;
- sprite.__prev = null;
- sprite.__next = null;
- return;
- }
-
- if(sprite.__prev)
- {
- sprite.__prev.__next = sprite.__next;
- }
- else
- {
- this.head = sprite.__next;
- this.head.__prev = null;
- }
-
- if(sprite.__next)
- {
- sprite.__next.__prev = sprite.__prev;
- }
- else
- {
- this.tail = sprite.__prev;
- this.tail.__next = null
- }
-
- sprite.batch = null;
- sprite.__next = null;
- sprite.__prev = null;
- this.dirty = true;
-}
-
-/**
- * Splits the batch into two with the specified sprite being the start of the new batch.
- *
- * @method split
- * @param sprite {Sprite} the sprite that indicates where the batch should be split
- * @return {WebGLBatch} the new batch
- */
-PIXI.WebGLBatch.prototype.split = function(sprite)
-{
- this.dirty = true;
-
- var batch = new PIXI.WebGLBatch(this.gl);
- batch.init(sprite);
- batch.texture = this.texture;
- batch.tail = this.tail;
-
- this.tail = sprite.__prev;
- this.tail.__next = null;
-
- sprite.__prev = null;
- // return a splite batch!
-
- // TODO this size is wrong!
- // need to recalculate :/ problem with a linked list!
- // unless it gets calculated in the "clean"?
-
- // need to loop through items as there is no way to know the length on a linked list :/
- var tempSize = 0;
- while(sprite)
- {
- tempSize++;
- sprite.batch = batch;
- sprite = sprite.__next;
- }
-
- batch.size = tempSize;
- this.size -= tempSize;
-
- return batch;
-}
-
-/**
- * Merges two batchs together
- *
- * @method merge
- * @param batch {WebGLBatch} the batch that will be merged
- */
-PIXI.WebGLBatch.prototype.merge = function(batch)
-{
- this.dirty = true;
-
- this.tail.__next = batch.head;
- batch.head.__prev = this.tail;
-
- this.size += batch.size;
-
- this.tail = batch.tail;
-
- var sprite = batch.head;
- while(sprite)
- {
- sprite.batch = this;
- sprite = sprite.__next;
- }
-}
-
-/**
- * Grows the size of the batch. As the elements in the batch cannot have a dynamic size this
- * function is used to increase the size of the batch. It also creates a little extra room so
- * that the batch does not need to be resized every time a sprite is added
- *
- * @method growBatch
- */
-PIXI.WebGLBatch.prototype.growBatch = function()
-{
- var gl = this.gl;
- if( this.size == 1)
- {
- this.dynamicSize = 1;
- }
- else
- {
- this.dynamicSize = this.size * 1.5
- }
- // grow verts
- this.verticies = new Float32Array(this.dynamicSize * 8);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
- gl.bufferData(gl.ARRAY_BUFFER,this.verticies , gl.DYNAMIC_DRAW);
-
- this.uvs = new Float32Array( this.dynamicSize * 8 );
- gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, this.uvs , gl.DYNAMIC_DRAW);
-
- this.dirtyUVS = true;
-
- this.colors = new Float32Array( this.dynamicSize * 4 );
- gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, this.colors , gl.DYNAMIC_DRAW);
-
- this.dirtyColors = true;
-
- this.indices = new Uint16Array(this.dynamicSize * 6);
- var length = this.indices.length/6;
-
- for (var i=0; i < length; i++)
- {
- var index2 = i * 6;
- var index3 = i * 4;
- this.indices[index2 + 0] = index3 + 0;
- this.indices[index2 + 1] = index3 + 1;
- this.indices[index2 + 2] = index3 + 2;
- this.indices[index2 + 3] = index3 + 0;
- this.indices[index2 + 4] = index3 + 2;
- this.indices[index2 + 5] = index3 + 3;
- };
-
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
-}
-
-/**
- * Refresh's all the data in the batch and sync's it with the webGL buffers
- *
- * @method refresh
- */
-PIXI.WebGLBatch.prototype.refresh = function()
-{
- var gl = this.gl;
-
- if (this.dynamicSize < this.size)
- {
- this.growBatch();
- }
-
- var indexRun = 0;
- var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index;
- var a, b, c, d, tx, ty;
-
- var displayObject = this.head;
-
- while(displayObject)
- {
- index = indexRun * 8;
-
- var texture = displayObject.texture;
-
- var frame = texture.frame;
- var tw = texture.baseTexture.width;
- var th = texture.baseTexture.height;
-
- this.uvs[index + 0] = frame.x / tw;
- this.uvs[index +1] = frame.y / th;
-
- this.uvs[index +2] = (frame.x + frame.width) / tw;
- this.uvs[index +3] = frame.y / th;
-
- this.uvs[index +4] = (frame.x + frame.width) / tw;
- this.uvs[index +5] = (frame.y + frame.height) / th;
-
- this.uvs[index +6] = frame.x / tw;
- this.uvs[index +7] = (frame.y + frame.height) / th;
-
- displayObject.updateFrame = false;
-
- colorIndex = indexRun * 4;
- this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha;
-
- displayObject = displayObject.__next;
-
- indexRun ++;
- }
-
- this.dirtyUVS = true;
- this.dirtyColors = true;
-}
-
-/**
- * Updates all the relevant geometry and uploads the data to the GPU
- *
- * @method update
- */
-PIXI.WebGLBatch.prototype.update = function()
-{
- var gl = this.gl;
- var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, index2, index3
-
- var a, b, c, d, tx, ty;
-
- var indexRun = 0;
-
- var displayObject = this.head;
- var verticies = this.verticies;
- var uvs = this.uvs;
- var colors = this.colors;
-
- while(displayObject)
- {
- if(displayObject.vcount === PIXI.visibleCount)
- {
- width = displayObject.texture.frame.width;
- height = displayObject.texture.frame.height;
-
- // TODO trim??
- aX = displayObject.anchor.x;// - displayObject.texture.trim.x
- aY = displayObject.anchor.y; //- displayObject.texture.trim.y
- w0 = width * (1-aX);
- w1 = width * -aX;
-
- h0 = height * (1-aY);
- h1 = height * -aY;
-
- index = indexRun * 8;
-
- worldTransform = displayObject.worldTransform;
-
- a = worldTransform[0];
- b = worldTransform[3];
- c = worldTransform[1];
- d = worldTransform[4];
- tx = worldTransform[2];
- ty = worldTransform[5];
-
- verticies[index + 0 ] = a * w1 + c * h1 + tx;
- verticies[index + 1 ] = d * h1 + b * w1 + ty;
-
- verticies[index + 2 ] = a * w0 + c * h1 + tx;
- verticies[index + 3 ] = d * h1 + b * w0 + ty;
-
- verticies[index + 4 ] = a * w0 + c * h0 + tx;
- verticies[index + 5 ] = d * h0 + b * w0 + ty;
-
- verticies[index + 6] = a * w1 + c * h0 + tx;
- verticies[index + 7] = d * h0 + b * w1 + ty;
-
- if(displayObject.updateFrame || displayObject.texture.updateFrame)
- {
- this.dirtyUVS = true;
-
- var texture = displayObject.texture;
-
- var frame = texture.frame;
- var tw = texture.baseTexture.width;
- var th = texture.baseTexture.height;
-
- uvs[index + 0] = frame.x / tw;
- uvs[index +1] = frame.y / th;
-
- uvs[index +2] = (frame.x + frame.width) / tw;
- uvs[index +3] = frame.y / th;
-
- uvs[index +4] = (frame.x + frame.width) / tw;
- uvs[index +5] = (frame.y + frame.height) / th;
-
- uvs[index +6] = frame.x / tw;
- uvs[index +7] = (frame.y + frame.height) / th;
-
- displayObject.updateFrame = false;
- }
-
- // TODO this probably could do with some optimisation....
- if(displayObject.cacheAlpha != displayObject.worldAlpha)
- {
- displayObject.cacheAlpha = displayObject.worldAlpha;
-
- var colorIndex = indexRun * 4;
- colors[colorIndex] = colors[colorIndex + 1] = colors[colorIndex + 2] = colors[colorIndex + 3] = displayObject.worldAlpha;
- this.dirtyColors = true;
- }
- }
- else
- {
- index = indexRun * 8;
-
- verticies[index + 0 ] = verticies[index + 1 ] = verticies[index + 2 ] = verticies[index + 3 ] = verticies[index + 4 ] = verticies[index + 5 ] = verticies[index + 6] = verticies[index + 7] = 0;
- }
-
- indexRun++;
- displayObject = displayObject.__next;
- }
-}
-
-/**
- * Draws the batch to the frame buffer
- *
- * @method render
- */
-PIXI.WebGLBatch.prototype.render = function(start, end)
-{
- start = start || 0;
-
- if(end == undefined)end = this.size;
-
- if(this.dirty)
- {
- this.refresh();
- this.dirty = false;
- }
-
- if (this.size == 0)return;
-
- this.update();
- var gl = this.gl;
-
- //TODO optimize this!
-
- var shaderProgram = PIXI.defaultShader;
-
- //gl.useProgram(shaderProgram);
-
- // update the verts..
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
- // ok..
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.verticies)
- gl.vertexAttribPointer(shaderProgram.aVertexPosition, 2, gl.FLOAT, false, 0, 0);
- // update the uvs
- //var isDefault = (shaderProgram == PIXI.shaderProgram)
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
-
- if(this.dirtyUVS)
- {
- this.dirtyUVS = false;
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvs);
- }
-
- gl.vertexAttribPointer(shaderProgram.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
-
- gl.activeTexture(gl.TEXTURE0);
- gl.bindTexture(gl.TEXTURE_2D, this.texture._glTexture);
-
- // update color!
- gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
-
- if(this.dirtyColors)
- {
- this.dirtyColors = false;
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.colors);
- }
-
- gl.vertexAttribPointer(shaderProgram.colorAttribute, 1, gl.FLOAT, false, 0, 0);
- // dont need to upload!
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
-
- var len = end - start;
-
- // DRAW THAT this!
- gl.drawElements(gl.TRIANGLES, len * 6, gl.UNSIGNED_SHORT, start * 2 * 6 );
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-PIXI.WebGLFilterManager = function(transparent)
-{
- this.transparent = transparent;
-
- this.filterStack = [];
- this.texturePool = [];
-
- this.offsetX = 0;
- this.offsetY = 0;
-
- this.initShaderBuffers();
-}
-
-// API
-
-PIXI.WebGLFilterManager.prototype.begin = function(projection, buffer)
-{
- this.width = projection.x * 2;
- this.height = -projection.y * 2;
- this.buffer = buffer;
-}
-
-PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
-{
- var gl = PIXI.gl;
-
- // filter program
- // OPTIMISATION - the first filter is free if its a simple color change?
- this.filterStack.push(filterBlock);
-
- var filter = filterBlock.filterPasses[0];
-
-
-
- this.offsetX += filterBlock.target.filterArea.x;
- this.offsetY += filterBlock.target.filterArea.y;
-
-
-
-
-
- var texture = this.texturePool.pop();
- if(!texture)texture = new PIXI.FilterTexture(this.width, this.height);
-
- gl.bindTexture(gl.TEXTURE_2D, texture.texture);
-
- this.getBounds(filterBlock.target);
-
- // addpadding?
- //displayObject.filterArea.x
-
- var filterArea = filterBlock.target.filterArea;
-
- var padidng = filter.padding;
- filterArea.x -= padidng;
- filterArea.y -= padidng;
- filterArea.width += padidng * 2;
- filterArea.height += padidng * 2;
-
- // cap filter to screen size..
- if(filterArea.x < 0)filterArea.x = 0;
- if(filterArea.width > this.width)filterArea.width = this.width;
- if(filterArea.y < 0)filterArea.y = 0;
- if(filterArea.height > this.height)filterArea.height = this.height;
-
-
- //gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, filterArea.width, filterArea.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
- gl.bindFramebuffer(gl.FRAMEBUFFER, texture.frameBuffer);
-
- // console.log(filterArea)
- // set view port
- gl.viewport(0, 0, filterArea.width, filterArea.height);
-
- PIXI.projection.x = filterArea.width/2;
- PIXI.projection.y = -filterArea.height/2;
-
- PIXI.offset.x = -filterArea.x;
- PIXI.offset.y = -filterArea.y;
-
- //console.log(PIXI.defaultShader.projectionVector)
- // update projection
- gl.uniform2f(PIXI.defaultShader.projectionVector, filterArea.width/2, -filterArea.height/2);
- gl.uniform2f(PIXI.defaultShader.offsetVector, -filterArea.x, -filterArea.y);
- //PIXI.primitiveProgram
-
- gl.colorMask(true, true, true, true);
- gl.clearColor(0,0,0, 0);
- gl.clear(gl.COLOR_BUFFER_BIT);
-
- //filter.texture = texture;
- filterBlock._glFilterTexture = texture;
-
- //console.log("PUSH")
-}
-
-
-PIXI.WebGLFilterManager.prototype.popFilter = function()
-{
-
- var gl = PIXI.gl;
-
- var filterBlock = this.filterStack.pop();
-
-
-
- var filterArea = filterBlock.target.filterArea;
-
- var texture = filterBlock._glFilterTexture;
-
- if(filterBlock.filterPasses.length > 1)
- {
- gl.viewport(0, 0, filterArea.width, filterArea.height);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
-
- this.vertexArray[0] = 0;
- this.vertexArray[1] = filterArea.height;
-
- this.vertexArray[2] = filterArea.width;
- this.vertexArray[3] = filterArea.height;
-
- this.vertexArray[4] = 0;
- this.vertexArray[5] = 0;
-
- this.vertexArray[6] = filterArea.width;
- this.vertexArray[7] = 0;
-
-
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertexArray);
-
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
- // nnow set the uvs..
- this.uvArray[2] = filterArea.width/this.width;
- this.uvArray[5] = filterArea.height/this.height;
- this.uvArray[6] = filterArea.width/this.width;
- this.uvArray[7] = filterArea.height/this.height;
-
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvArray);
-
- var inputTexture = texture;
- var outputTexture = this.texturePool.pop();
- if(!outputTexture)outputTexture = new PIXI.FilterTexture(this.width, this.height);
-
- // need to clear this FBO as it may have some left over elements from a prvious filter.
- gl.bindFramebuffer(gl.FRAMEBUFFER, outputTexture.frameBuffer );
- gl.clear(gl.COLOR_BUFFER_BIT);
-
- gl.disable(gl.BLEND);
-
- for (var i = 0; i < filterBlock.filterPasses.length-1; i++)
- {
- var filterPass = filterBlock.filterPasses[i];
-
- gl.bindFramebuffer(gl.FRAMEBUFFER, outputTexture.frameBuffer );
-
- // set texture
- gl.activeTexture(gl.TEXTURE0);
- gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture);
-
- // draw texture..
- //filterPass.applyFilterPass(filterArea.width, filterArea.height);
- this.applyFilterPass(filterPass, filterArea, filterArea.width, filterArea.height);
-
- // swap the textures..
- var temp = inputTexture;
- inputTexture = outputTexture;
- outputTexture = temp;
-
- };
-
- gl.enable(gl.BLEND);
-
- texture = inputTexture;
- this.texturePool.push(outputTexture);
- }
-
- var filter = filterBlock.filterPasses[filterBlock.filterPasses.length-1];
-
- this.offsetX -= filterArea.x;
- this.offsetY -= filterArea.y;
-
-
- var sizeX = this.width;
- var sizeY = this.height;
-
- var offsetX = 0;
- var offsetY = 0;
-
- var buffer = this.buffer;
-
- // time to render the filters texture to the previous scene
- if(this.filterStack.length === 0)
- {
- gl.colorMask(true, true, true, this.transparent);
- }
- else
- {
- var currentFilter = this.filterStack[this.filterStack.length-1];
- var filterArea = currentFilter.target.filterArea;
-
- sizeX = filterArea.width;
- sizeY = filterArea.height;
-
- offsetX = filterArea.x;
- offsetY = filterArea.y;
-
- buffer = currentFilter._glFilterTexture.frameBuffer;
- }
-
-
-
- // TODO need toremove thease global elements..
- PIXI.projection.x = sizeX/2;
- PIXI.projection.y = -sizeY/2;
-
- PIXI.offset.x = offsetX;
- PIXI.offset.y = offsetY;
-
-
- var filterArea = filterBlock.target.filterArea;
- var x = filterArea.x-offsetX;
- var y = filterArea.y-offsetY;
-
- // update the buffers..
- // make sure to flip the y!
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
-
- this.vertexArray[0] = x;
- this.vertexArray[1] = y + filterArea.height;
-
- this.vertexArray[2] = x + filterArea.width;
- this.vertexArray[3] = y + filterArea.height;
-
- this.vertexArray[4] = x;
- this.vertexArray[5] = y;
-
- this.vertexArray[6] = x + filterArea.width;
- this.vertexArray[7] = y;
-
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertexArray);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
-
- this.uvArray[2] = filterArea.width/this.width;
- this.uvArray[5] = filterArea.height/this.height;
- this.uvArray[6] = filterArea.width/this.width;
- this.uvArray[7] = filterArea.height/this.height;
-
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvArray);
-
- gl.viewport(0, 0, sizeX, sizeY);
- // bind the buffer
- gl.bindFramebuffer(gl.FRAMEBUFFER, buffer );
-
- // set texture
- gl.activeTexture(gl.TEXTURE0);
- gl.bindTexture(gl.TEXTURE_2D, texture.texture);
-
- // apply!
- //filter.applyFilterPass(sizeX, sizeY);
- this.applyFilterPass(filter, filterArea, sizeX, sizeY);
-
- // now restore the regular shader..
- gl.useProgram(PIXI.defaultShader.program);
- gl.uniform2f(PIXI.defaultShader.projectionVector, sizeX/2, -sizeY/2);
- gl.uniform2f(PIXI.defaultShader.offsetVector, -offsetX, -offsetY);
-
- // return the texture to the pool
- this.texturePool.push(texture);
- filterBlock._glFilterTexture = null;
-}
-
-PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height)
-{
- // use program
- var gl = PIXI.gl;
-
- if(!filter.shader)
- {
- var shader = new PIXI.PixiShader();
-
- shader.fragmentSrc = filter.fragmentSrc;
- shader.uniforms = filter.uniforms;
- shader.init();
-
- filter.shader = shader;
- }
-
- var shader = filter.shader;
-
- // set the shader
- gl.useProgram(shader.program);
-
- gl.uniform2f(shader.projectionVector, width/2, -height/2);
- gl.uniform2f(shader.offsetVector, 0,0)
-
- if(filter.uniforms.dimensions)
- {
- //console.log(filter.uniforms.dimensions)
- filter.uniforms.dimensions.value[0] = this.width;//width;
- filter.uniforms.dimensions.value[1] = this.height;//height;
- filter.uniforms.dimensions.value[2] = this.vertexArray[0];
- filter.uniforms.dimensions.value[3] = this.vertexArray[5];//filterArea.height;
- // console.log(this.vertexArray[5])
- }
-
- shader.syncUniforms();
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
- gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
- gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
-
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
-
- // draw the filter...
- gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 );
-}
-
-PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
-{
- var gl = PIXI.gl;
-
- // create some buffers
- this.vertexBuffer = gl.createBuffer();
- this.uvBuffer = gl.createBuffer();
- this.indexBuffer = gl.createBuffer();
-
- // bind and upload the vertexs..
- // keep a refferance to the vertexFloatData..
- this.vertexArray = new Float32Array([0.0, 0.0,
- 1.0, 0.0,
- 0.0, 1.0,
- 1.0, 1.0]);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
- gl.bufferData(
- gl.ARRAY_BUFFER,
- this.vertexArray,
- gl.STATIC_DRAW);
-
-
- // bind and upload the uv buffer
- this.uvArray = new Float32Array([0.0, 0.0,
- 1.0, 0.0,
- 0.0, 1.0,
- 1.0, 1.0]);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
- gl.bufferData(
- gl.ARRAY_BUFFER,
- this.uvArray,
- gl.STATIC_DRAW);
-
- // bind and upload the index
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
- gl.bufferData(
- gl.ELEMENT_ARRAY_BUFFER,
- new Uint16Array([0, 1, 2, 1, 3, 2]),
- gl.STATIC_DRAW);
-}
-
-PIXI.WebGLFilterManager.prototype.getBounds = function(displayObject)
-{
- // time to get the width and height of the object!
- var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, doTest;
- var a, b, c, d, tx, ty, x1, x2, x3, x4, y1, y2, y3, y4;
-
- var tempObject = displayObject.first;
- var testObject = displayObject.last._iNext;
-
- var maxX = -Infinity;
- var maxY = -Infinity;
-
- var minX = Infinity;
- var minY = Infinity;
-
- do
- {
- // TODO can be optimized! - what if there is no scale / rotation?
-
- if(tempObject.visible)
- {
- if(tempObject instanceof PIXI.Sprite)
- {
- width = tempObject.texture.frame.width;
- height = tempObject.texture.frame.height;
-
- // TODO trim??
- aX = tempObject.anchor.x;
- aY = tempObject.anchor.y;
- w0 = width * (1-aX);
- w1 = width * -aX;
-
- h0 = height * (1-aY);
- h1 = height * -aY;
-
- doTest = true;
- }
- else if(tempObject instanceof PIXI.Graphics)
- {
- tempObject.updateFilterBounds();
-
- var bounds = tempObject.bounds;
-
- width = bounds.width;
- height = bounds.height;
-
- w0 = bounds.x
- w1 = bounds.x + bounds.width;
-
- h0 = bounds.y
- h1 = bounds.y + bounds.height;
-
- doTest = true;
- }
- }
-
- if(doTest)
- {
- worldTransform = tempObject.worldTransform;
-
- a = worldTransform[0];
- b = worldTransform[3];
- c = worldTransform[1];
- d = worldTransform[4];
- tx = worldTransform[2];
- ty = worldTransform[5];
-
- x1 = a * w1 + c * h1 + tx;
- y1 = d * h1 + b * w1 + ty;
-
- x2 = a * w0 + c * h1 + tx;
- y2 = d * h1 + b * w0 + ty;
-
- x3 = a * w0 + c * h0 + tx;
- y3 = d * h0 + b * w0 + ty;
-
- x4 = a * w1 + c * h0 + tx;
- y4 = d * h0 + b * w1 + ty;
-
- minX = x1 < minX ? x1 : minX;
- minX = x2 < minX ? x2 : minX;
- minX = x3 < minX ? x3 : minX;
- minX = x4 < minX ? x4 : minX;
-
- minY = y1 < minY ? y1 : minY;
- minY = y2 < minY ? y2 : minY;
- minY = y3 < minY ? y3 : minY;
- minY = y4 < minY ? y4 : minY;
-
- maxX = x1 > maxX ? x1 : maxX;
- maxX = x2 > maxX ? x2 : maxX;
- maxX = x3 > maxX ? x3 : maxX;
- maxX = x4 > maxX ? x4 : maxX;
-
- maxY = y1 > maxY ? y1 : maxY;
- maxY = y2 > maxY ? y2 : maxY;
- maxY = y3 > maxY ? y3 : maxY;
- maxY = y4 > maxY ? y4 : maxY;
- }
-
- doTest = false;
- tempObject = tempObject._iNext;
-
- }
- while(tempObject != testObject)
-
- // maximum bounds is the size of the screen..
- //minX = minX > 0 ? minX : 0;
- //minY = minY > 0 ? minY : 0;
-
- displayObject.filterArea.x = minX;
- displayObject.filterArea.y = minY;
-
-// console.log(maxX+ " : " + minX)
- displayObject.filterArea.width = maxX - minX;
- displayObject.filterArea.height = maxY - minY;
-}
-
-PIXI.FilterTexture = function(width, height)
-{
- var gl = PIXI.gl;
-
- // next time to create a frame buffer and texture
- this.frameBuffer = gl.createFramebuffer();
- this.texture = gl.createTexture();
-
- gl.bindTexture(gl.TEXTURE_2D, this.texture);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
- gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer );
-
- gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer );
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);
-
- this.resize(width, height);
-}
-
-PIXI.FilterTexture.prototype.resize = function(width, height)
-{
- this.width = width;
- this.height = height;
-
- var gl = PIXI.gl;
-
- gl.bindTexture(gl.TEXTURE_2D, this.texture);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-
-}
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- * A set of functions used by the webGL renderer to draw the primitive graphics data
- *
- * @class CanvasGraphics
- */
-PIXI.WebGLGraphics = function()
-{
-
-}
-
-/**
- * Renders the graphics object
- *
- * @static
- * @private
- * @method renderGraphics
- * @param graphics {Graphics}
- * @param projection {Object}
- */
-PIXI.WebGLGraphics.renderGraphics = function(graphics, projection)
-{
- var gl = PIXI.gl;
-
- if(!graphics._webGL)graphics._webGL = {points:[], indices:[], lastIndex:0,
- buffer:gl.createBuffer(),
- indexBuffer:gl.createBuffer()};
-
- if(graphics.dirty)
- {
- graphics.dirty = false;
-
- if(graphics.clearDirty)
- {
- graphics.clearDirty = false;
-
- graphics._webGL.lastIndex = 0;
- graphics._webGL.points = [];
- graphics._webGL.indices = [];
-
- }
-
- PIXI.WebGLGraphics.updateGraphics(graphics);
- }
-
- PIXI.activatePrimitiveShader();
-
- // This could be speeded up fo sure!
- var m = PIXI.mat3.clone(graphics.worldTransform);
-
- PIXI.mat3.transpose(m);
-
- // set the matrix transform for the
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
-
- gl.uniformMatrix3fv(PIXI.primitiveShader.translationMatrix, false, m);
-
- gl.uniform2f(PIXI.primitiveShader.projectionVector, projection.x, -projection.y);
- gl.uniform2f(PIXI.primitiveShader.offsetVector, -PIXI.offset.x, -PIXI.offset.y);
-
- gl.uniform1f(PIXI.primitiveShader.alpha, graphics.worldAlpha);
- gl.bindBuffer(gl.ARRAY_BUFFER, graphics._webGL.buffer);
-
- gl.vertexAttribPointer(PIXI.primitiveShader.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0);
- gl.vertexAttribPointer(PIXI.primitiveShader.colorAttribute, 4, gl.FLOAT, false,4 * 6, 2 * 4);
-
- // set the index buffer!
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, graphics._webGL.indexBuffer);
-
-
- gl.drawElements(gl.TRIANGLE_STRIP, graphics._webGL.indices.length, gl.UNSIGNED_SHORT, 0 );
-
- PIXI.deactivatePrimitiveShader();
-
-
- // return to default shader...
-// PIXI.activateShader(PIXI.defaultShader);
-}
-
-/**
- * Updates the graphics object
- *
- * @static
- * @private
- * @method updateGraphics
- * @param graphics {Graphics}
- */
-PIXI.WebGLGraphics.updateGraphics = function(graphics)
-{
- for (var i=graphics._webGL.lastIndex; i < graphics.graphicsData.length; i++)
- {
- var data = graphics.graphicsData[i];
-
- if(data.type == PIXI.Graphics.POLY)
- {
- if(data.fill)
- {
- if(data.points.length>3)
- PIXI.WebGLGraphics.buildPoly(data, graphics._webGL);
- }
-
- if(data.lineWidth > 0)
- {
- PIXI.WebGLGraphics.buildLine(data, graphics._webGL);
- }
- }
- else if(data.type == PIXI.Graphics.RECT)
- {
- PIXI.WebGLGraphics.buildRectangle(data, graphics._webGL);
- }
- else if(data.type == PIXI.Graphics.CIRC || data.type == PIXI.Graphics.ELIP)
- {
- PIXI.WebGLGraphics.buildCircle(data, graphics._webGL);
- }
- };
-
- graphics._webGL.lastIndex = graphics.graphicsData.length;
-
- var gl = PIXI.gl;
-
- graphics._webGL.glPoints = new Float32Array(graphics._webGL.points);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, graphics._webGL.buffer);
- gl.bufferData(gl.ARRAY_BUFFER, graphics._webGL.glPoints, gl.STATIC_DRAW);
-
- graphics._webGL.glIndicies = new Uint16Array(graphics._webGL.indices);
-
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, graphics._webGL.indexBuffer);
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, graphics._webGL.glIndicies, gl.STATIC_DRAW);
-}
-
-/**
- * Builds a rectangle to draw
- *
- * @static
- * @private
- * @method buildRectangle
- * @param graphics {Graphics}
- * @param webGLData {Object}
- */
-PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData)
-{
- // --- //
- // need to convert points to a nice regular data
- //
- var rectData = graphicsData.points;
- var x = rectData[0];
- var y = rectData[1];
- var width = rectData[2];
- var height = rectData[3];
-
-
- if(graphicsData.fill)
- {
- var color = HEXtoRGB(graphicsData.fillColor);
- var alpha = graphicsData.fillAlpha;
-
- var r = color[0] * alpha;
- var g = color[1] * alpha;
- var b = color[2] * alpha;
-
- var verts = webGLData.points;
- var indices = webGLData.indices;
-
- var vertPos = verts.length/6;
-
- // start
- verts.push(x, y);
- verts.push(r, g, b, alpha);
-
- verts.push(x + width, y);
- verts.push(r, g, b, alpha);
-
- verts.push(x , y + height);
- verts.push(r, g, b, alpha);
-
- verts.push(x + width, y + height);
- verts.push(r, g, b, alpha);
-
- // insert 2 dead triangles..
- indices.push(vertPos, vertPos, vertPos+1, vertPos+2, vertPos+3, vertPos+3)
- }
-
- if(graphicsData.lineWidth)
- {
- graphicsData.points = [x, y,
- x + width, y,
- x + width, y + height,
- x, y + height,
- x, y];
-
- PIXI.WebGLGraphics.buildLine(graphicsData, webGLData);
- }
-
-}
-
-/**
- * Builds a circle to draw
- *
- * @static
- * @private
- * @method buildCircle
- * @param graphics {Graphics}
- * @param webGLData {Object}
- */
-PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData)
-{
- // --- //
- // need to convert points to a nice regular data
- //
- var rectData = graphicsData.points;
- var x = rectData[0];
- var y = rectData[1];
- var width = rectData[2];
- var height = rectData[3];
-
- var totalSegs = 40;
- var seg = (Math.PI * 2) / totalSegs ;
-
- if(graphicsData.fill)
- {
- var color = HEXtoRGB(graphicsData.fillColor);
- var alpha = graphicsData.fillAlpha;
-
- var r = color[0] * alpha;
- var g = color[1] * alpha;
- var b = color[2] * alpha;
-
- var verts = webGLData.points;
- var indices = webGLData.indices;
-
- var vecPos = verts.length/6;
-
- indices.push(vecPos);
-
- for (var i=0; i < totalSegs + 1 ; i++)
- {
- verts.push(x,y, r, g, b, alpha);
-
- verts.push(x + Math.sin(seg * i) * width,
- y + Math.cos(seg * i) * height,
- r, g, b, alpha);
-
- indices.push(vecPos++, vecPos++);
- };
-
- indices.push(vecPos-1);
- }
-
- if(graphicsData.lineWidth)
- {
- graphicsData.points = [];
-
- for (var i=0; i < totalSegs + 1; i++)
- {
- graphicsData.points.push(x + Math.sin(seg * i) * width,
- y + Math.cos(seg * i) * height)
- };
-
- PIXI.WebGLGraphics.buildLine(graphicsData, webGLData);
- }
-
-}
-
-/**
- * Builds a line to draw
- *
- * @static
- * @private
- * @method buildLine
- * @param graphics {Graphics}
- * @param webGLData {Object}
- */
-PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
-{
- // TODO OPTIMISE!
-
- var wrap = true;
- var points = graphicsData.points;
- if(points.length == 0)return;
-
- // if the line width is an odd number add 0.5 to align to a whole pixel
- if(graphicsData.lineWidth%2)
- {
- for (var i = 0; i < points.length; i++) {
- points[i] += 0.5;
- };
- }
-
- // get first and last point.. figure out the middle!
- var firstPoint = new PIXI.Point( points[0], points[1] );
- var lastPoint = new PIXI.Point( points[points.length - 2], points[points.length - 1] );
-
- // if the first point is the last point - goona have issues :)
- if(firstPoint.x == lastPoint.x && firstPoint.y == lastPoint.y)
- {
- points.pop();
- points.pop();
-
- lastPoint = new PIXI.Point( points[points.length - 2], points[points.length - 1] );
-
- var midPointX = lastPoint.x + (firstPoint.x - lastPoint.x) *0.5;
- var midPointY = lastPoint.y + (firstPoint.y - lastPoint.y) *0.5;
-
- points.unshift(midPointX, midPointY);
- points.push(midPointX, midPointY)
- }
-
- var verts = webGLData.points;
- var indices = webGLData.indices;
- var length = points.length / 2;
- var indexCount = points.length;
- var indexStart = verts.length/6;
-
- // DRAW the Line
- var width = graphicsData.lineWidth / 2;
-
- // sort color
- var color = HEXtoRGB(graphicsData.lineColor);
- var alpha = graphicsData.lineAlpha;
- var r = color[0] * alpha;
- var g = color[1] * alpha;
- var b = color[2] * alpha;
-
- var p1x, p1y, p2x, p2y, p3x, p3y;
- var perpx, perpy, perp2x, perp2y, perp3x, perp3y;
- var ipx, ipy;
- var a1, b1, c1, a2, b2, c2;
- var denom, pdist, dist;
-
- p1x = points[0];
- p1y = points[1];
-
- p2x = points[2];
- p2y = points[3];
-
- perpx = -(p1y - p2y);
- perpy = p1x - p2x;
-
- dist = Math.sqrt(perpx*perpx + perpy*perpy);
-
- perpx /= dist;
- perpy /= dist;
- perpx *= width;
- perpy *= width;
-
- // start
- verts.push(p1x - perpx , p1y - perpy,
- r, g, b, alpha);
-
- verts.push(p1x + perpx , p1y + perpy,
- r, g, b, alpha);
-
- for (var i = 1; i < length-1; i++)
- {
- p1x = points[(i-1)*2];
- p1y = points[(i-1)*2 + 1];
-
- p2x = points[(i)*2]
- p2y = points[(i)*2 + 1]
-
- p3x = points[(i+1)*2];
- p3y = points[(i+1)*2 + 1];
-
- perpx = -(p1y - p2y);
- perpy = p1x - p2x;
-
- dist = Math.sqrt(perpx*perpx + perpy*perpy);
- perpx /= dist;
- perpy /= dist;
- perpx *= width;
- perpy *= width;
-
- perp2x = -(p2y - p3y);
- perp2y = p2x - p3x;
-
- dist = Math.sqrt(perp2x*perp2x + perp2y*perp2y);
- perp2x /= dist;
- perp2y /= dist;
- perp2x *= width;
- perp2y *= width;
-
- a1 = (-perpy + p1y) - (-perpy + p2y);
- b1 = (-perpx + p2x) - (-perpx + p1x);
- c1 = (-perpx + p1x) * (-perpy + p2y) - (-perpx + p2x) * (-perpy + p1y);
- a2 = (-perp2y + p3y) - (-perp2y + p2y);
- b2 = (-perp2x + p2x) - (-perp2x + p3x);
- c2 = (-perp2x + p3x) * (-perp2y + p2y) - (-perp2x + p2x) * (-perp2y + p3y);
-
- denom = a1*b2 - a2*b1;
-
- if(Math.abs(denom) < 0.1 )
- {
-
- denom+=10.1;
- verts.push(p2x - perpx , p2y - perpy,
- r, g, b, alpha);
-
- verts.push(p2x + perpx , p2y + perpy,
- r, g, b, alpha);
-
- continue;
- }
-
- px = (b1*c2 - b2*c1)/denom;
- py = (a2*c1 - a1*c2)/denom;
-
-
- pdist = (px -p2x) * (px -p2x) + (py -p2y) + (py -p2y);
-
-
- if(pdist > 140 * 140)
- {
- perp3x = perpx - perp2x;
- perp3y = perpy - perp2y;
-
- dist = Math.sqrt(perp3x*perp3x + perp3y*perp3y);
- perp3x /= dist;
- perp3y /= dist;
- perp3x *= width;
- perp3y *= width;
-
- verts.push(p2x - perp3x, p2y -perp3y);
- verts.push(r, g, b, alpha);
-
- verts.push(p2x + perp3x, p2y +perp3y);
- verts.push(r, g, b, alpha);
-
- verts.push(p2x - perp3x, p2y -perp3y);
- verts.push(r, g, b, alpha);
-
- indexCount++;
- }
- else
- {
-
- verts.push(px , py);
- verts.push(r, g, b, alpha);
-
- verts.push(p2x - (px-p2x), p2y - (py - p2y));
- verts.push(r, g, b, alpha);
- }
- }
-
- p1x = points[(length-2)*2]
- p1y = points[(length-2)*2 + 1]
-
- p2x = points[(length-1)*2]
- p2y = points[(length-1)*2 + 1]
-
- perpx = -(p1y - p2y)
- perpy = p1x - p2x;
-
- dist = Math.sqrt(perpx*perpx + perpy*perpy);
- perpx /= dist;
- perpy /= dist;
- perpx *= width;
- perpy *= width;
-
- verts.push(p2x - perpx , p2y - perpy)
- verts.push(r, g, b, alpha);
-
- verts.push(p2x + perpx , p2y + perpy)
- verts.push(r, g, b, alpha);
-
- indices.push(indexStart);
-
- for (var i=0; i < indexCount; i++)
- {
- indices.push(indexStart++);
- };
-
- indices.push(indexStart-1);
-}
-
-/**
- * Builds a polygon to draw
- *
- * @static
- * @private
- * @method buildPoly
- * @param graphics {Graphics}
- * @param webGLData {Object}
- */
-PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData)
-{
- var points = graphicsData.points;
- if(points.length < 6)return;
-
- // get first and last point.. figure out the middle!
- var verts = webGLData.points;
- var indices = webGLData.indices;
-
- var length = points.length / 2;
-
- // sort color
- var color = HEXtoRGB(graphicsData.fillColor);
- var alpha = graphicsData.fillAlpha;
- var r = color[0] * alpha;
- var g = color[1] * alpha;
- var b = color[2] * alpha;
-
- var triangles = PIXI.PolyK.Triangulate(points);
-
- var vertPos = verts.length / 6;
-
- for (var i=0; i < triangles.length; i+=3)
- {
- indices.push(triangles[i] + vertPos);
- indices.push(triangles[i] + vertPos);
- indices.push(triangles[i+1] + vertPos);
- indices.push(triangles[i+2] +vertPos);
- indices.push(triangles[i+2] + vertPos);
- };
-
- for (var i = 0; i < length; i++)
- {
- verts.push(points[i * 2], points[i * 2 + 1],
- r, g, b, alpha);
- };
-}
-
-function HEXtoRGB(hex) {
- return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
-}
-
-
-
-
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-PIXI._defaultFrame = new PIXI.Rectangle(0,0,1,1);
-
-// an instance of the gl context..
-// only one at the moment :/
-PIXI.gl;
-
-/**
- * the WebGLRenderer is draws the stage and all its content onto a webGL enabled canvas. This renderer
- * should be used for browsers support webGL. This Render works by automatically managing webGLBatchs.
- * So no need for Sprite Batch's or Sprite Cloud's
- * Dont forget to add the view to your DOM or you will not see anything :)
- *
- * @class WebGLRenderer
- * @constructor
- * @param width=0 {Number} the width of the canvas view
- * @param height=0 {Number} the height of the canvas view
- * @param view {Canvas} the canvas to use as a view, optional
- * @param transparent=false {Boolean} the transparency of the render view, default false
- * @param antialias=false {Boolean} sets antialias (only applicable in chrome at the moment)
- *
- */
-PIXI.WebGLRenderer = function(width, height, view, transparent, antialias)
-{
- // do a catch.. only 1 webGL renderer..
-
- this.transparent = !!transparent;
-
- this.width = width || 800;
- this.height = height || 600;
-
- this.view = view || document.createElement( 'canvas' );
- this.view.width = this.width;
- this.view.height = this.height;
-
- // deal with losing context..
- var scope = this;
- this.view.addEventListener('webglcontextlost', function(event) { scope.handleContextLost(event); }, false)
- this.view.addEventListener('webglcontextrestored', function(event) { scope.handleContextRestored(event); }, false)
-
- this.batchs = [];
-
- var options = {
- alpha: this.transparent,
- antialias:!!antialias, // SPEED UP??
- premultipliedAlpha:false,
- stencil:true
- }
-
- //try 'experimental-webgl'
- try {
- PIXI.gl = this.gl = this.view.getContext("experimental-webgl", options);
- } catch (e) {
- //try 'webgl'
- try {
- PIXI.gl = this.gl = this.view.getContext("webgl", options);
- } catch (e) {
- // fail, not able to get a context
- throw new Error(" This browser does not support webGL. Try using the canvas renderer" + this);
- }
- }
-
- PIXI.initDefaultShaders();
-
-
-
-
- // PIXI.activateDefaultShader();
-
- var gl = this.gl;
-
- gl.useProgram(PIXI.defaultShader.program);
-
-
- PIXI.WebGLRenderer.gl = gl;
-
- this.batch = new PIXI.WebGLBatch(gl);
- gl.disable(gl.DEPTH_TEST);
- gl.disable(gl.CULL_FACE);
-
- gl.enable(gl.BLEND);
- gl.colorMask(true, true, true, this.transparent);
-
- PIXI.projection = new PIXI.Point(400, 300);
- PIXI.offset = new PIXI.Point(0, 0);
-
- // TODO remove thease globals..
-
- this.resize(this.width, this.height);
- this.contextLost = false;
-
- //PIXI.pushShader(PIXI.defaultShader);
-
- this.stageRenderGroup = new PIXI.WebGLRenderGroup(this.gl, this.transparent);
- // this.stageRenderGroup. = this.transparent
-}
-
-// constructor
-PIXI.WebGLRenderer.prototype.constructor = PIXI.WebGLRenderer;
-
-/**
- * Gets a new WebGLBatch from the pool
- *
- * @static
- * @method getBatch
- * @return {WebGLBatch}
- * @private
- */
-PIXI.WebGLRenderer.getBatch = function()
-{
- if(PIXI._batchs.length == 0)
- {
- return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl);
- }
- else
- {
- return PIXI._batchs.pop();
- }
-}
-
-/**
- * Puts a batch back into the pool
- *
- * @static
- * @method returnBatch
- * @param batch {WebGLBatch} The batch to return
- * @private
- */
-PIXI.WebGLRenderer.returnBatch = function(batch)
-{
- batch.clean();
- PIXI._batchs.push(batch);
-}
-
-/**
- * Renders the stage to its webGL view
- *
- * @method render
- * @param stage {Stage} the Stage element to be rendered
- */
-PIXI.WebGLRenderer.prototype.render = function(stage)
-{
- if(this.contextLost)return;
-
-
- // if rendering a new stage clear the batchs..
- if(this.__stage !== stage)
- {
- // TODO make this work
- // dont think this is needed any more?
- this.__stage = stage;
- this.stageRenderGroup.setRenderable(stage);
- }
-
- // update any textures
- PIXI.WebGLRenderer.updateTextures();
-
- // update the scene graph
- PIXI.visibleCount++;
- stage.updateTransform();
-
- var gl = this.gl;
-
- // -- Does this need to be set every frame? -- //
- gl.colorMask(true, true, true, this.transparent);
- gl.viewport(0, 0, this.width, this.height);
-
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-
- gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], !this.transparent);
- gl.clear(gl.COLOR_BUFFER_BIT);
-
- // HACK TO TEST
-
- this.stageRenderGroup.backgroundColor = stage.backgroundColorSplit;
-
- PIXI.projection.x = this.width/2;
- PIXI.projection.y = -this.height/2;
-
- this.stageRenderGroup.render(PIXI.projection);
-
- // interaction
- // run interaction!
- if(stage.interactive)
- {
- //need to add some events!
- if(!stage._interactiveEventsAdded)
- {
- stage._interactiveEventsAdded = true;
- stage.interactionManager.setTarget(this);
- }
- }
-
- // after rendering lets confirm all frames that have been uodated..
- if(PIXI.Texture.frameUpdates.length > 0)
- {
- for (var i=0; i < PIXI.Texture.frameUpdates.length; i++)
- {
- PIXI.Texture.frameUpdates[i].updateFrame = false;
- };
-
- PIXI.Texture.frameUpdates = [];
- }
-}
-
-/**
- * Updates the textures loaded into this webgl renderer
- *
- * @static
- * @method updateTextures
- * @private
- */
-PIXI.WebGLRenderer.updateTextures = function()
-{
- //TODO break this out into a texture manager...
- for (var i=0; i < PIXI.texturesToUpdate.length; i++) PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
- for (var i=0; i < PIXI.texturesToDestroy.length; i++) PIXI.WebGLRenderer.destroyTexture(PIXI.texturesToDestroy[i]);
- PIXI.texturesToUpdate = [];
- PIXI.texturesToDestroy = [];
-}
-
-/**
- * Updates a loaded webgl texture
- *
- * @static
- * @method updateTexture
- * @param texture {Texture} The texture to update
- * @private
- */
-PIXI.WebGLRenderer.updateTexture = function(texture)
-{
- //TODO break this out into a texture manager...
- var gl = PIXI.gl;
-
- if(!texture._glTexture)
- {
- texture._glTexture = gl.createTexture();
- }
-
- if(texture.hasLoaded)
- {
- gl.bindTexture(gl.TEXTURE_2D, texture._glTexture);
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
-
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
-
- // reguler...
-
- if(!texture._powerOf2)
- {
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
- }
- else
- {
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
- }
-
- gl.bindTexture(gl.TEXTURE_2D, null);
- }
-}
-
-/**
- * Destroys a loaded webgl texture
- *
- * @method destroyTexture
- * @param texture {Texture} The texture to update
- * @private
- */
-PIXI.WebGLRenderer.destroyTexture = function(texture)
-{
- //TODO break this out into a texture manager...
- var gl = PIXI.gl;
-
- if(texture._glTexture)
- {
- texture._glTexture = gl.createTexture();
- gl.deleteTexture(gl.TEXTURE_2D, texture._glTexture);
- }
-}
-
-/**
- * resizes the webGL view to the specified width and height
- *
- * @method resize
- * @param width {Number} the new width of the webGL view
- * @param height {Number} the new height of the webGL view
- */
-PIXI.WebGLRenderer.prototype.resize = function(width, height)
-{
- this.width = width;
- this.height = height;
-
- this.view.width = width;
- this.view.height = height;
-
- this.gl.viewport(0, 0, this.width, this.height);
-
- //var projectionMatrix = this.projectionMatrix;
-
- PIXI.projection.x = this.width/2;
- PIXI.projection.y = -this.height/2;
-
- //PIXI.size.x = this.width/2;
- //PIXI.size.y = -this.height/2;
-
-// projectionMatrix[0] = 2/this.width;
-// projectionMatrix[5] = -2/this.height;
-// projectionMatrix[12] = -1;
-// projectionMatrix[13] = 1;
-}
-
-/**
- * Handles a lost webgl context
- *
- * @method handleContextLost
- * @param event {Event}
- * @private
- */
-PIXI.WebGLRenderer.prototype.handleContextLost = function(event)
-{
- event.preventDefault();
- this.contextLost = true;
-}
-
-/**
- * Handles a restored webgl context
- *
- * @method handleContextRestored
- * @param event {Event}
- * @private
- */
-PIXI.WebGLRenderer.prototype.handleContextRestored = function(event)
-{
- this.gl = this.view.getContext("experimental-webgl", {
- alpha: true
- });
-
- this.initShaders();
-
- for(var key in PIXI.TextureCache)
- {
- var texture = PIXI.TextureCache[key].baseTexture;
- texture._glTexture = null;
- PIXI.WebGLRenderer.updateTexture(texture);
- };
-
- for (var i=0; i < this.batchs.length; i++)
- {
- this.batchs[i].restoreLostContext(this.gl)//
- this.batchs[i].dirty = true;
- };
-
- PIXI._restoreBatchs(this.gl);
-
- this.contextLost = false;
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- * A WebGLBatch Enables a group of sprites to be drawn using the same settings.
- * if a group of sprites all have the same baseTexture and blendMode then they can be
- * grouped into a batch. All the sprites in a batch can then be drawn in one go by the
- * GPU which is hugely efficient. ALL sprites in the webGL renderer are added to a batch
- * even if the batch only contains one sprite. Batching is handled automatically by the
- * webGL renderer. A good tip is: the smaller the number of batchs there are, the faster
- * the webGL renderer will run.
- *
- * @class WebGLBatch
- * @contructor
- * @param gl {WebGLContext} An instance of the webGL context
- */
-PIXI.WebGLRenderGroup = function(gl, transparent)
-{
- this.gl = gl;
- this.root;
-
- this.backgroundColor;
- this.transparent = transparent == undefined ? true : transparent;
-
- this.batchs = [];
- this.toRemove = [];
- console.log(this.transparent)
- this.filterManager = new PIXI.WebGLFilterManager(this.transparent);
-}
-
-// constructor
-PIXI.WebGLRenderGroup.prototype.constructor = PIXI.WebGLRenderGroup;
-
-/**
- * Add a display object to the webgl renderer
- *
- * @method setRenderable
- * @param displayObject {DisplayObject}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.setRenderable = function(displayObject)
-{
- // has this changed??
- if(this.root)this.removeDisplayObjectAndChildren(this.root);
-
- displayObject.worldVisible = displayObject.visible;
-
- // soooooo //
- // to check if any batchs exist already??
-
- // TODO what if its already has an object? should remove it
- this.root = displayObject;
- this.addDisplayObjectAndChildren(displayObject);
-}
-
-/**
- * Renders the stage to its webgl view
- *
- * @method render
- * @param projection {Object}
- */
-PIXI.WebGLRenderGroup.prototype.render = function(projection, buffer)
-{
- PIXI.WebGLRenderer.updateTextures();
-
- var gl = this.gl;
- gl.uniform2f(PIXI.defaultShader.projectionVector, projection.x, projection.y);
-
- this.filterManager.begin(projection, buffer);
-
-
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
- // will render all the elements in the group
- var renderable;
-
- for (var i=0; i < this.batchs.length; i++)
- {
-
- renderable = this.batchs[i];
- if(renderable instanceof PIXI.WebGLBatch)
- {
- this.batchs[i].render();
- continue;
- }
-
- // render special
- this.renderSpecial(renderable, projection);
- }
-
-}
-
-/**
- * Renders a specific displayObject
- *
- * @method renderSpecific
- * @param displayObject {DisplayObject}
- * @param projection {Object}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, projection, buffer)
-{
- PIXI.WebGLRenderer.updateTextures();
- var gl = this.gl;
-
- gl.uniform2f(PIXI.defaultShader.projectionVector, projection.x, projection.y);
-
- this.filterManager.begin(projection, buffer);
-
- // to do!
- // render part of the scene...
-
- var startIndex;
- var startBatchIndex;
-
- var endIndex;
- var endBatchIndex;
-
- /*
- * LOOK FOR THE NEXT SPRITE
- * This part looks for the closest next sprite that can go into a batch
- * it keeps looking until it finds a sprite or gets to the end of the display
- * scene graph
- */
- var nextRenderable = displayObject.first;
- while(nextRenderable._iNext)
- {
- if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
- nextRenderable = nextRenderable._iNext;
- }
- var startBatch = nextRenderable.batch;
- //console.log(nextRenderable);
-
- //console.log(renderable)
- if(nextRenderable instanceof PIXI.Sprite)
- {
- startBatch = nextRenderable.batch;
-
- var head = startBatch.head;
- var next = head;
-
- // ok now we have the batch.. need to find the start index!
- if(head == nextRenderable)
- {
- startIndex = 0;
- }
- else
- {
- startIndex = 1;
-
- while(head.__next != nextRenderable)
- {
- startIndex++;
- head = head.__next;
- }
- }
- }
- else
- {
- startBatch = nextRenderable;
- }
-
- // Get the LAST renderable object
- var lastRenderable = displayObject.last;
- while(lastRenderable._iPrev)
- {
- if(lastRenderable.renderable && lastRenderable.__renderGroup)break;
- lastRenderable = lastRenderable._iNext;
- }
-
- if(lastRenderable instanceof PIXI.Sprite)
- {
- endBatch = lastRenderable.batch;
-
- var head = endBatch.head;
-
- if(head == lastRenderable)
- {
- endIndex = 0;
- }
- else
- {
- endIndex = 1;
-
- while(head.__next != lastRenderable)
- {
- endIndex++;
- head = head.__next;
- }
- }
- }
- else
- {
- endBatch = lastRenderable;
- }
-
- //console.log(endBatch);
- // TODO - need to fold this up a bit!
-
- if(startBatch == endBatch)
- {
- if(startBatch instanceof PIXI.WebGLBatch)
- {
- startBatch.render(startIndex, endIndex+1);
- }
- else
- {
- this.renderSpecial(startBatch, projection);
- }
- return;
- }
-
- // now we have first and last!
- startBatchIndex = this.batchs.indexOf(startBatch);
- endBatchIndex = this.batchs.indexOf(endBatch);
-
- // DO the first batch
- if(startBatch instanceof PIXI.WebGLBatch)
- {
- startBatch.render(startIndex);
- }
- else
- {
- this.renderSpecial(startBatch, projection);
- }
-
- // DO the middle batchs..
- for (var i=startBatchIndex+1; i < endBatchIndex; i++)
- {
- renderable = this.batchs[i];
-
- if(renderable instanceof PIXI.WebGLBatch)
- {
- this.batchs[i].render();
- }
- else
- {
- this.renderSpecial(renderable, projection);
- }
- }
-
- // DO the last batch..
- if(endBatch instanceof PIXI.WebGLBatch)
- {
- endBatch.render(0, endIndex+1);
- }
- else
- {
- this.renderSpecial(endBatch, projection);
- }
-}
-
-/**
- * Renders a specific renderable
- *
- * @method renderSpecial
- * @param renderable {DisplayObject}
- * @param projection {Object}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.renderSpecial = function(renderable, projection)
-{
-
- var worldVisible = renderable.vcount === PIXI.visibleCount
-
-
- if(renderable instanceof PIXI.TilingSprite)
- {
- if(worldVisible)this.renderTilingSprite(renderable, projection);
- }
- else if(renderable instanceof PIXI.Strip)
- {
- if(worldVisible)this.renderStrip(renderable, projection);
- }
- else if(renderable instanceof PIXI.CustomRenderable)
- {
- if(worldVisible) renderable.renderWebGL(this, projection);
- }
- else if(renderable instanceof PIXI.Graphics)
- {
- if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);
- }
- else if(renderable instanceof PIXI.FilterBlock)
- {
- this.handleFilterBlock(renderable, projection);
- }
-}
-
-flip = false;
-var maskStack = [];
-var maskPosition = 0;
-
-//var usedMaskStack = [];
-
-PIXI.WebGLRenderGroup.prototype.handleFilterBlock = function(filterBlock, projection)
-{
- /*
- * for now only masks are supported..
- */
- var gl = PIXI.gl;
-
- if(filterBlock.open)
- {
- if(filterBlock.data instanceof Array)
- {
- this.filterManager.pushFilter(filterBlock);
- // ok so..
-
- }
- else
- {
- maskPosition++;
-
- maskStack.push(filterBlock)
-
- gl.enable(gl.STENCIL_TEST);
-
- gl.colorMask(false, false, false, false);
-
- gl.stencilFunc(gl.ALWAYS,1,1);
- gl.stencilOp(gl.KEEP,gl.KEEP,gl.INCR);
-
- PIXI.WebGLGraphics.renderGraphics(filterBlock.data, projection);
-
- gl.colorMask(true, true, true, true);
- gl.stencilFunc(gl.NOTEQUAL,0,maskStack.length);
- gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);
- }
- }
- else
- {
- if(filterBlock.data instanceof Array)
- {
- this.filterManager.popFilter();
- }
- else
- {
- var maskData = maskStack.pop(filterBlock)
-
-
- if(maskData)
- {
- gl.colorMask(false, false, false, false);
-
- gl.stencilFunc(gl.ALWAYS,1,1);
- gl.stencilOp(gl.KEEP,gl.KEEP,gl.DECR);
-
- PIXI.WebGLGraphics.renderGraphics(maskData.data, projection);
-
- gl.colorMask(true, true, true, true);
- gl.stencilFunc(gl.NOTEQUAL,0,maskStack.length);
- gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);
- };
-
- gl.disable(gl.STENCIL_TEST);
- }
- }
-}
-
-/**
- * Updates a webgl texture
- *
- * @method updateTexture
- * @param displayObject {DisplayObject}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.updateTexture = function(displayObject)
-{
-
- // TODO definitely can optimse this function..
-
- this.removeObject(displayObject);
-
- /*
- * LOOK FOR THE PREVIOUS RENDERABLE
- * This part looks for the closest previous sprite that can go into a batch
- * It keeps going back until it finds a sprite or the stage
- */
- var previousRenderable = displayObject.first;
- while(previousRenderable != this.root)
- {
- previousRenderable = previousRenderable._iPrev;
- if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
- }
-
- /*
- * LOOK FOR THE NEXT SPRITE
- * This part looks for the closest next sprite that can go into a batch
- * it keeps looking until it finds a sprite or gets to the end of the display
- * scene graph
- */
- var nextRenderable = displayObject.last;
- while(nextRenderable._iNext)
- {
- nextRenderable = nextRenderable._iNext;
- if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
- }
-
- this.insertObject(displayObject, previousRenderable, nextRenderable);
-}
-
-/**
- * Adds filter blocks
- *
- * @method addFilterBlocks
- * @param start {FilterBlock}
- * @param end {FilterBlock}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.addFilterBlocks = function(start, end)
-{
- start.__renderGroup = this;
- end.__renderGroup = this;
- /*
- * LOOK FOR THE PREVIOUS RENDERABLE
- * This part looks for the closest previous sprite that can go into a batch
- * It keeps going back until it finds a sprite or the stage
- */
- var previousRenderable = start;
- while(previousRenderable != this.root.first)
- {
- previousRenderable = previousRenderable._iPrev;
- if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
- }
- this.insertAfter(start, previousRenderable);
-
- /*
- * LOOK FOR THE NEXT SPRITE
- * This part looks for the closest next sprite that can go into a batch
- * it keeps looking until it finds a sprite or gets to the end of the display
- * scene graph
- */
- var previousRenderable2 = end;
- while(previousRenderable2 != this.root.first)
- {
- previousRenderable2 = previousRenderable2._iPrev;
- if(previousRenderable2.renderable && previousRenderable2.__renderGroup)break;
- }
- this.insertAfter(end, previousRenderable2);
-}
-
-/**
- * Remove filter blocks
- *
- * @method removeFilterBlocks
- * @param start {FilterBlock}
- * @param end {FilterBlock}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.removeFilterBlocks = function(start, end)
-{
- this.removeObject(start);
- this.removeObject(end);
-}
-
-/**
- * Adds a display object and children to the webgl context
- *
- * @method addDisplayObjectAndChildren
- * @param displayObject {DisplayObject}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayObject)
-{
- if(displayObject.__renderGroup)displayObject.__renderGroup.removeDisplayObjectAndChildren(displayObject);
-
- /*
- * LOOK FOR THE PREVIOUS RENDERABLE
- * This part looks for the closest previous sprite that can go into a batch
- * It keeps going back until it finds a sprite or the stage
- */
-
- var previousRenderable = displayObject.first;
- while(previousRenderable != this.root.first)
- {
- previousRenderable = previousRenderable._iPrev;
- if(previousRenderable.renderable && previousRenderable.__renderGroup)break;
- }
-
- /*
- * LOOK FOR THE NEXT SPRITE
- * This part looks for the closest next sprite that can go into a batch
- * it keeps looking until it finds a sprite or gets to the end of the display
- * scene graph
- */
- var nextRenderable = displayObject.last;
- while(nextRenderable._iNext)
- {
- nextRenderable = nextRenderable._iNext;
- if(nextRenderable.renderable && nextRenderable.__renderGroup)break;
- }
-
- // one the display object hits this. we can break the loop
-
- var tempObject = displayObject.first;
- var testObject = displayObject.last._iNext;
- do
- {
- tempObject.__renderGroup = this;
-
- if(tempObject.renderable)
- {
-
- this.insertObject(tempObject, previousRenderable, nextRenderable);
- previousRenderable = tempObject;
- }
-
- tempObject = tempObject._iNext;
- }
- while(tempObject != testObject)
-}
-
-/**
- * Removes a display object and children to the webgl context
- *
- * @method removeDisplayObjectAndChildren
- * @param displayObject {DisplayObject}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displayObject)
-{
- if(displayObject.__renderGroup != this)return;
-
-// var displayObject = displayObject.first;
- var lastObject = displayObject.last;
- do
- {
- displayObject.__renderGroup = null;
- if(displayObject.renderable)this.removeObject(displayObject);
- displayObject = displayObject._iNext;
- }
- while(displayObject)
-}
-
-/**
- * Inserts a displayObject into the linked list
- *
- * @method insertObject
- * @param displayObject {DisplayObject}
- * @param previousObject {DisplayObject}
- * @param nextObject {DisplayObject}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
-{
- // while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
- var previousSprite = previousObject;
- var nextSprite = nextObject;
-
- /*
- * so now we have the next renderable and the previous renderable
- *
- */
- if(displayObject instanceof PIXI.Sprite)
- {
- var previousBatch
- var nextBatch
-
- if(previousSprite instanceof PIXI.Sprite)
- {
- previousBatch = previousSprite.batch;
- if(previousBatch)
- {
- if(previousBatch.texture == displayObject.texture.baseTexture && previousBatch.blendMode == displayObject.blendMode)
- {
- previousBatch.insertAfter(displayObject, previousSprite);
- return;
- }
- }
- }
- else
- {
- // TODO reword!
- previousBatch = previousSprite;
- }
-
- if(nextSprite)
- {
- if(nextSprite instanceof PIXI.Sprite)
- {
- nextBatch = nextSprite.batch;
-
- //batch may not exist if item was added to the display list but not to the webGL
- if(nextBatch)
- {
- if(nextBatch.texture == displayObject.texture.baseTexture && nextBatch.blendMode == displayObject.blendMode)
- {
- nextBatch.insertBefore(displayObject, nextSprite);
- return;
- }
- else
- {
- if(nextBatch == previousBatch)
- {
- // THERE IS A SPLIT IN THIS BATCH! //
- var splitBatch = previousBatch.split(nextSprite);
- // COOL!
- // add it back into the array
- /*
- * OOPS!
- * seems the new sprite is in the middle of a batch
- * lets split it..
- */
- var batch = PIXI.WebGLRenderer.getBatch();
-
- var index = this.batchs.indexOf( previousBatch );
- batch.init(displayObject);
- this.batchs.splice(index+1, 0, batch, splitBatch);
-
- return;
- }
- }
- }
- }
- else
- {
- // TODO re-word!
-
- nextBatch = nextSprite;
- }
- }
-
- /*
- * looks like it does not belong to any batch!
- * but is also not intersecting one..
- * time to create anew one!
- */
-
- var batch = PIXI.WebGLRenderer.getBatch();
- batch.init(displayObject);
-
- if(previousBatch) // if this is invalid it means
- {
- var index = this.batchs.indexOf( previousBatch );
- this.batchs.splice(index+1, 0, batch);
- }
- else
- {
- this.batchs.push(batch);
- }
-
- return;
- }
- else if(displayObject instanceof PIXI.TilingSprite)
- {
-
- // add to a batch!!
- this.initTilingSprite(displayObject);
- // this.batchs.push(displayObject);
-
- }
- else if(displayObject instanceof PIXI.Strip)
- {
- // add to a batch!!
- this.initStrip(displayObject);
- // this.batchs.push(displayObject);
- }
- else if(displayObject)// instanceof PIXI.Graphics)
- {
- //displayObject.initWebGL(this);
-
- // add to a batch!!
- //this.initStrip(displayObject);
- //this.batchs.push(displayObject);
- }
-
- this.insertAfter(displayObject, previousSprite);
-
- // insert and SPLIT!
-
-}
-
-/**
- * Inserts a displayObject into the linked list
- *
- * @method insertAfter
- * @param item {DisplayObject}
- * @param displayObject {DisplayObject} The object to insert
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.insertAfter = function(item, displayObject)
-{
- if(displayObject instanceof PIXI.Sprite)
- {
- var previousBatch = displayObject.batch;
-
- if(previousBatch)
- {
- // so this object is in a batch!
-
- // is it not? need to split the batch
- if(previousBatch.tail == displayObject)
- {
- // is it tail? insert in to batchs
- var index = this.batchs.indexOf( previousBatch );
- this.batchs.splice(index+1, 0, item);
- }
- else
- {
- // TODO MODIFY ADD / REMOVE CHILD TO ACCOUNT FOR FILTERS (also get prev and next) //
-
- // THERE IS A SPLIT IN THIS BATCH! //
- var splitBatch = previousBatch.split(displayObject.__next);
-
- // COOL!
- // add it back into the array
- /*
- * OOPS!
- * seems the new sprite is in the middle of a batch
- * lets split it..
- */
- var index = this.batchs.indexOf( previousBatch );
- this.batchs.splice(index+1, 0, item, splitBatch);
- }
- }
- else
- {
- this.batchs.push(item);
- }
- }
- else
- {
- var index = this.batchs.indexOf( displayObject );
- this.batchs.splice(index+1, 0, item);
- }
-}
-
-/**
- * Removes a displayObject from the linked list
- *
- * @method removeObject
- * @param displayObject {DisplayObject} The object to remove
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.removeObject = function(displayObject)
-{
- // loop through children..
- // display object //
-
- // add a child from the render group..
- // remove it and all its children!
- //displayObject.cacheVisible = false;//displayObject.visible;
-
- /*
- * removing is a lot quicker..
- *
- */
- var batchToRemove;
-
- if(displayObject instanceof PIXI.Sprite)
- {
- // should always have a batch!
- var batch = displayObject.batch;
- if(!batch)return; // this means the display list has been altered befre rendering
-
- batch.remove(displayObject);
-
- if(batch.size==0)
- {
- batchToRemove = batch;
- }
- }
- else
- {
- batchToRemove = displayObject;
- }
-
- /*
- * Looks like there is somthing that needs removing!
- */
- if(batchToRemove)
- {
- var index = this.batchs.indexOf( batchToRemove );
- if(index == -1)return;// this means it was added then removed before rendered
-
- // ok so.. check to see if you adjacent batchs should be joined.
- // TODO may optimise?
- if(index == 0 || index == this.batchs.length-1)
- {
- // wha - eva! just get of the empty batch!
- this.batchs.splice(index, 1);
- if(batchToRemove instanceof PIXI.WebGLBatch)PIXI.WebGLRenderer.returnBatch(batchToRemove);
-
- return;
- }
-
- if(this.batchs[index-1] instanceof PIXI.WebGLBatch && this.batchs[index+1] instanceof PIXI.WebGLBatch)
- {
- if(this.batchs[index-1].texture == this.batchs[index+1].texture && this.batchs[index-1].blendMode == this.batchs[index+1].blendMode)
- {
- //console.log("MERGE")
- this.batchs[index-1].merge(this.batchs[index+1]);
-
- if(batchToRemove instanceof PIXI.WebGLBatch)PIXI.WebGLRenderer.returnBatch(batchToRemove);
- PIXI.WebGLRenderer.returnBatch(this.batchs[index+1]);
- this.batchs.splice(index, 2);
- return;
- }
- }
-
- this.batchs.splice(index, 1);
- if(batchToRemove instanceof PIXI.WebGLBatch)PIXI.WebGLRenderer.returnBatch(batchToRemove);
- }
-}
-
-
-/**
- * Initializes a tiling sprite
- *
- * @method initTilingSprite
- * @param sprite {TilingSprite} The tiling sprite to initialize
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.initTilingSprite = function(sprite)
-{
- var gl = this.gl;
-
- // make the texture tilable..
-
- sprite.verticies = new Float32Array([0, 0,
- sprite.width, 0,
- sprite.width, sprite.height,
- 0, sprite.height]);
-
- sprite.uvs = new Float32Array([0, 0,
- 1, 0,
- 1, 1,
- 0, 1]);
-
- sprite.colors = new Float32Array([1,1,1,1]);
-
- sprite.indices = new Uint16Array([0, 1, 3,2])//, 2]);
-
- sprite._vertexBuffer = gl.createBuffer();
- sprite._indexBuffer = gl.createBuffer();
- sprite._uvBuffer = gl.createBuffer();
- sprite._colorBuffer = gl.createBuffer();
-
- gl.bindBuffer(gl.ARRAY_BUFFER, sprite._vertexBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, sprite.verticies, gl.STATIC_DRAW);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, sprite._uvBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, sprite.uvs, gl.DYNAMIC_DRAW);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, sprite._colorBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, sprite.colors, gl.STATIC_DRAW);
-
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, sprite._indexBuffer);
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, sprite.indices, gl.STATIC_DRAW);
-
-// return ( (x > 0) && ((x & (x - 1)) == 0) );
-
- if(sprite.texture.baseTexture._glTexture)
- {
- gl.bindTexture(gl.TEXTURE_2D, sprite.texture.baseTexture._glTexture);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
- sprite.texture.baseTexture._powerOf2 = true;
- }
- else
- {
- sprite.texture.baseTexture._powerOf2 = true;
- }
-}
-
-/**
- * Renders a Strip
- *
- * @method renderStrip
- * @param strip {Strip} The strip to render
- * @param projection {Object}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.renderStrip = function(strip, projection)
-{
- var gl = this.gl;
-
- PIXI.activateStripShader();
-
- var shader = PIXI.stripShader;
-
- var program = shader.program;
-
- var m = PIXI.mat3.clone(strip.worldTransform);
-
- PIXI.mat3.transpose(m);
-
-// console.log(projection)
- // set the matrix transform for the
- gl.uniformMatrix3fv(shader.translationMatrix, false, m);
- gl.uniform2f(shader.projectionVector, projection.x, projection.y);
- gl.uniform2f(shader.offsetVector, -PIXI.offset.x, -PIXI.offset.y);
-
- gl.uniform1f(shader.alpha, strip.worldAlpha);
-
- /*
- if(strip.blendMode == PIXI.blendModes.NORMAL)
- {
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
- }
- else
- {
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_COLOR);
- }
- */
-
- //console.log("!!")
- if(!strip.dirty)
- {
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._vertexBuffer);
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, strip.verticies)
- gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0);
-
- // update the uvs
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._uvBuffer);
- gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
-
- gl.activeTexture(gl.TEXTURE0);
- gl.bindTexture(gl.TEXTURE_2D, strip.texture.baseTexture._glTexture);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._colorBuffer);
- gl.vertexAttribPointer(shader.colorAttribute, 1, gl.FLOAT, false, 0, 0);
-
- // dont need to upload!
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, strip._indexBuffer);
- }
- else
- {
- strip.dirty = false;
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._vertexBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, strip.verticies, gl.STATIC_DRAW)
- gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0);
-
- // update the uvs
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._uvBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, strip.uvs, gl.STATIC_DRAW)
- gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0);
-
- gl.activeTexture(gl.TEXTURE0);
- gl.bindTexture(gl.TEXTURE_2D, strip.texture.baseTexture._glTexture);
- // console.log(strip.texture.baseTexture._glTexture)
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._colorBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, strip.colors, gl.STATIC_DRAW)
- gl.vertexAttribPointer(shader.colorAttribute, 1, gl.FLOAT, false, 0, 0);
-
- // dont need to upload!
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, strip._indexBuffer);
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, strip.indices, gl.STATIC_DRAW);
-
- }
-
- gl.drawElements(gl.TRIANGLE_STRIP, strip.indices.length, gl.UNSIGNED_SHORT, 0);
-
- PIXI.deactivateStripShader();
- //gl.useProgram(PIXI.currentProgram);
-}
-
-/**
- * Renders a TilingSprite
- *
- * @method renderTilingSprite
- * @param sprite {TilingSprite} The tiling sprite to render
- * @param projectionMatrix {Object}
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.renderTilingSprite = function(sprite, projectionMatrix)
-{
- var gl = this.gl;
-
-
- var shaderProgram = PIXI.shaderProgram;
-
- var tilePosition = sprite.tilePosition;
- var tileScale = sprite.tileScale;
-
- var offsetX = tilePosition.x/sprite.texture.baseTexture.width;
- var offsetY = tilePosition.y/sprite.texture.baseTexture.height;
-
- var scaleX = (sprite.width / sprite.texture.baseTexture.width) / tileScale.x;
- var scaleY = (sprite.height / sprite.texture.baseTexture.height) / tileScale.y;
-
- sprite.uvs[0] = 0 - offsetX;
- sprite.uvs[1] = 0 - offsetY;
-
- sprite.uvs[2] = (1 * scaleX) -offsetX;
- sprite.uvs[3] = 0 - offsetY;
-
- sprite.uvs[4] = (1 *scaleX) - offsetX;
- sprite.uvs[5] = (1 *scaleY) - offsetY;
-
- sprite.uvs[6] = 0 - offsetX;
- sprite.uvs[7] = (1 *scaleY) - offsetY;
-
- gl.bindBuffer(gl.ARRAY_BUFFER, sprite._uvBuffer);
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, sprite.uvs)
-
- this.renderStrip(sprite, projectionMatrix);
-}
-
-/**
- * Initializes a strip to be rendered
- *
- * @method initStrip
- * @param strip {Strip} The strip to initialize
- * @private
- */
-PIXI.WebGLRenderGroup.prototype.initStrip = function(strip)
-{
- // build the strip!
- var gl = this.gl;
- var shaderProgram = this.shaderProgram;
-
- strip._vertexBuffer = gl.createBuffer();
- strip._indexBuffer = gl.createBuffer();
- strip._uvBuffer = gl.createBuffer();
- strip._colorBuffer = gl.createBuffer();
-
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._vertexBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, strip.verticies, gl.DYNAMIC_DRAW);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._uvBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, strip.uvs, gl.STATIC_DRAW);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, strip._colorBuffer);
- gl.bufferData(gl.ARRAY_BUFFER, strip.colors, gl.STATIC_DRAW);
-
-
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, strip._indexBuffer);
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, strip.indices, gl.STATIC_DRAW);
-}
-
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-
-PIXI.initDefaultShaders = function()
-{
- PIXI.primitiveShader = new PIXI.PrimitiveShader();
- PIXI.primitiveShader.init();
-
- PIXI.stripShader = new PIXI.StripShader();
- PIXI.stripShader.init();
-
- PIXI.defaultShader = new PIXI.PixiShader();
- PIXI.defaultShader.init();
-
- var gl = PIXI.gl;
- var shaderProgram = PIXI.defaultShader.program;
-
-
- gl.useProgram(shaderProgram);
-
- gl.enableVertexAttribArray(PIXI.defaultShader.aVertexPosition);
- gl.enableVertexAttribArray(PIXI.defaultShader.colorAttribute);
- gl.enableVertexAttribArray(PIXI.defaultShader.aTextureCoord);
-}
-
-PIXI.activatePrimitiveShader = function()
-{
- var gl = PIXI.gl;
-
- gl.useProgram(PIXI.primitiveShader.program);
-
- gl.disableVertexAttribArray(PIXI.defaultShader.aVertexPosition);
- gl.disableVertexAttribArray(PIXI.defaultShader.colorAttribute);
- gl.disableVertexAttribArray(PIXI.defaultShader.aTextureCoord);
-
- gl.enableVertexAttribArray(PIXI.primitiveShader.aVertexPosition);
- gl.enableVertexAttribArray(PIXI.primitiveShader.colorAttribute);
-}
-
-PIXI.deactivatePrimitiveShader = function()
-{
- var gl = PIXI.gl;
-
- gl.useProgram(PIXI.defaultShader.program);
-
- gl.disableVertexAttribArray(PIXI.primitiveShader.aVertexPosition);
- gl.disableVertexAttribArray(PIXI.primitiveShader.colorAttribute);
-
- gl.enableVertexAttribArray(PIXI.defaultShader.aVertexPosition);
- gl.enableVertexAttribArray(PIXI.defaultShader.colorAttribute);
- gl.enableVertexAttribArray(PIXI.defaultShader.aTextureCoord);
-
-}
-
-PIXI.activateStripShader = function()
-{
- var gl = PIXI.gl;
-
- gl.useProgram(PIXI.stripShader.program);
- // gl.disableVertexAttribArray(PIXI.defaultShader.aTextureCoord);
-}
-
-PIXI.deactivateStripShader = function()
-{
- var gl = PIXI.gl;
-
- gl.useProgram(PIXI.defaultShader.program);
- //gl.enableVertexAttribArray(PIXI.defaultShader.aTextureCoord);
-}
-
-/*
-
-SHADER COMPILER HELPERS
-*/
-
-PIXI.CompileVertexShader = function(gl, shaderSrc)
-{
- return PIXI._CompileShader(gl, shaderSrc, gl.VERTEX_SHADER);
-}
-
-PIXI.CompileFragmentShader = function(gl, shaderSrc)
-{
- return PIXI._CompileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
-}
-
-PIXI._CompileShader = function(gl, shaderSrc, shaderType)
-{
- var src = shaderSrc.join("\n");
- var shader = gl.createShader(shaderType);
- gl.shaderSource(shader, src);
- gl.compileShader(shader);
-
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
- console.log(gl.getShaderInfoLog(shader));
- return null;
- }
-
- return shader;
-}
-
-
-PIXI.compileProgram = function(vertexSrc, fragmentSrc)
-{
- var gl = PIXI.gl;
- var fragmentShader = PIXI.CompileFragmentShader(gl, fragmentSrc);
- var vertexShader = PIXI.CompileVertexShader(gl, vertexSrc);
-
- var shaderProgram = gl.createProgram();
-
- gl.attachShader(shaderProgram, vertexShader);
- gl.attachShader(shaderProgram, fragmentShader);
- gl.linkProgram(shaderProgram);
-
- if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
- console.log("Could not initialise shaders");
- }
-
- return shaderProgram;
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- * A Text Object will create a line(s) of text using bitmap font. To split a line you can use "\n", "\r" or "\r\n"
- * You can generate the fnt files using
- * http://www.angelcode.com/products/bmfont/ for windows or
- * http://www.bmglyph.com/ for mac.
- *
- * @class BitmapText
- * @extends DisplayObjectContainer
- * @constructor
- * @param text {String} The copy that you would like the text to display
- * @param style {Object} The style parameters
- * @param style.font {String} The size (optional) and bitmap font id (required) eq "Arial" or "20px Arial" (must have loaded previously)
- * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right")
- */
-PIXI.BitmapText = function(text, style)
-{
- PIXI.DisplayObjectContainer.call(this);
-
- this.setText(text);
- this.setStyle(style);
- this.updateText();
- this.dirty = false
-
-};
-
-// constructor
-PIXI.BitmapText.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
-PIXI.BitmapText.prototype.constructor = PIXI.BitmapText;
-
-/**
- * Set the copy for the text object
- *
- * @method setText
- * @param text {String} The copy that you would like the text to display
- */
-PIXI.BitmapText.prototype.setText = function(text)
-{
- this.text = text || " ";
- this.dirty = true;
-};
-
-/**
- * Set the style of the text
- *
- * @method setStyle
- * @param style {Object} The style parameters
- * @param style.font {String} The size (optional) and bitmap font id (required) eq "Arial" or "20px Arial" (must have loaded previously)
- * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right")
- */
-PIXI.BitmapText.prototype.setStyle = function(style)
-{
- style = style || {};
- style.align = style.align || "left";
- this.style = style;
-
- var font = style.font.split(" ");
- this.fontName = font[font.length - 1];
- this.fontSize = font.length >= 2 ? parseInt(font[font.length - 2], 10) : PIXI.BitmapText.fonts[this.fontName].size;
-
- this.dirty = true;
-};
-
-/**
- * Renders text
- *
- * @method updateText
- * @private
- */
-PIXI.BitmapText.prototype.updateText = function()
-{
- var data = PIXI.BitmapText.fonts[this.fontName];
- var pos = new PIXI.Point();
- var prevCharCode = null;
- var chars = [];
- var maxLineWidth = 0;
- var lineWidths = [];
- var line = 0;
- var scale = this.fontSize / data.size;
- for(var i = 0; i < this.text.length; i++)
- {
- var charCode = this.text.charCodeAt(i);
- if(/(?:\r\n|\r|\n)/.test(this.text.charAt(i)))
- {
- lineWidths.push(pos.x);
- maxLineWidth = Math.max(maxLineWidth, pos.x);
- line++;
-
- pos.x = 0;
- pos.y += data.lineHeight;
- prevCharCode = null;
- continue;
- }
-
- var charData = data.chars[charCode];
- if(!charData) continue;
-
- if(prevCharCode && charData[prevCharCode])
- {
- pos.x += charData.kerning[prevCharCode];
- }
- chars.push({texture:charData.texture, line: line, charCode: charCode, position: new PIXI.Point(pos.x + charData.xOffset, pos.y + charData.yOffset)});
- pos.x += charData.xAdvance;
-
- prevCharCode = charCode;
- }
-
- lineWidths.push(pos.x);
- maxLineWidth = Math.max(maxLineWidth, pos.x);
-
- var lineAlignOffsets = [];
- for(i = 0; i <= line; i++)
- {
- var alignOffset = 0;
- if(this.style.align == "right")
- {
- alignOffset = maxLineWidth - lineWidths[i];
- }
- else if(this.style.align == "center")
- {
- alignOffset = (maxLineWidth - lineWidths[i]) / 2;
- }
- lineAlignOffsets.push(alignOffset);
- }
-
- for(i = 0; i < chars.length; i++)
- {
- var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
- c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
- c.position.y = chars[i].position.y * scale;
- c.scale.x = c.scale.y = scale;
- this.addChild(c);
- }
-
- this.width = pos.x * scale;
- this.height = (pos.y + data.lineHeight) * scale;
-};
-
-/**
- * Updates the transfor of this object
- *
- * @method updateTransform
- * @private
- */
-PIXI.BitmapText.prototype.updateTransform = function()
-{
- if(this.dirty)
- {
- while(this.children.length > 0)
- {
- this.removeChild(this.getChildAt(0));
- }
- this.updateText();
-
- this.dirty = false;
- }
-
- PIXI.DisplayObjectContainer.prototype.updateTransform.call(this);
-};
-
-PIXI.BitmapText.fonts = {};
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- * A Text Object will create a line(s) of text to split a line you can use "\n"
- *
- * @class Text
- * @extends Sprite
- * @constructor
- * @param text {String} The copy that you would like the text to display
- * @param [style] {Object} The style parameters
- * @param [style.font] {String} default "bold 20pt Arial" The style and size of the font
- * @param [style.fill="black"] {Object} A canvas fillstyle that will be used on the text eg "red", "#00FF00"
- * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right")
- * @param [style.stroke] {String} A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
- * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke)
- * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used
- * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap
- */
-PIXI.Text = function(text, style)
-{
- this.canvas = document.createElement("canvas");
- this.context = this.canvas.getContext("2d");
- PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas));
-
- this.setText(text);
- this.setStyle(style);
-
- this.updateText();
- this.dirty = false;
-};
-
-// constructor
-PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
-PIXI.Text.prototype.constructor = PIXI.Text;
-
-/**
- * Set the style of the text
- *
- * @method setStyle
- * @param [style] {Object} The style parameters
- * @param [style.font="bold 20pt Arial"] {String} The style and size of the font
- * @param [style.fill="black"] {Object} A canvas fillstyle that will be used on the text eg "red", "#00FF00"
- * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right")
- * @param [style.stroke="black"] {String} A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
- * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke)
- * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used
- * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap
- */
-PIXI.Text.prototype.setStyle = function(style)
-{
- style = style || {};
- style.font = style.font || "bold 20pt Arial";
- style.fill = style.fill || "black";
- style.align = style.align || "left";
- style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
- style.strokeThickness = style.strokeThickness || 0;
- style.wordWrap = style.wordWrap || false;
- style.wordWrapWidth = style.wordWrapWidth || 100;
- this.style = style;
- this.dirty = true;
-};
-
-/**
- * Set the copy for the text object. To split a line you can use "\n"
- *
- * @methos setText
- * @param {String} text The copy that you would like the text to display
- */
-PIXI.Text.prototype.setText = function(text)
-{
- this.text = text.toString() || " ";
- this.dirty = true;
-};
-
-/**
- * Renders text
- *
- * @method updateText
- * @private
- */
-PIXI.Text.prototype.updateText = function()
-{
- this.context.font = this.style.font;
-
- var outputText = this.text;
-
- // word wrap
- // preserve original text
- if(this.style.wordWrap)outputText = this.wordWrap(this.text);
-
- //split text into lines
- var lines = outputText.split(/(?:\r\n|\r|\n)/);
-
- //calculate text width
- var lineWidths = [];
- var maxLineWidth = 0;
- for (var i = 0; i < lines.length; i++)
- {
- var lineWidth = this.context.measureText(lines[i]).width;
- lineWidths[i] = lineWidth;
- maxLineWidth = Math.max(maxLineWidth, lineWidth);
- }
- this.canvas.width = maxLineWidth + this.style.strokeThickness;
-
- //calculate text height
- var lineHeight = this.determineFontHeight("font: " + this.style.font + ";") + this.style.strokeThickness;
- this.canvas.height = lineHeight * lines.length;
-
- //set canvas text styles
- this.context.fillStyle = this.style.fill;
- this.context.font = this.style.font;
-
- this.context.strokeStyle = this.style.stroke;
- this.context.lineWidth = this.style.strokeThickness;
-
- this.context.textBaseline = "top";
-
- //draw lines line by line
- for (i = 0; i < lines.length; i++)
- {
- var linePosition = new PIXI.Point(this.style.strokeThickness / 2, this.style.strokeThickness / 2 + i * lineHeight);
-
- if(this.style.align == "right")
- {
- linePosition.x += maxLineWidth - lineWidths[i];
- }
- else if(this.style.align == "center")
- {
- linePosition.x += (maxLineWidth - lineWidths[i]) / 2;
- }
-
- if(this.style.stroke && this.style.strokeThickness)
- {
- this.context.strokeText(lines[i], linePosition.x, linePosition.y);
- }
-
- if(this.style.fill)
- {
- this.context.fillText(lines[i], linePosition.x, linePosition.y);
- }
- }
-
- this.updateTexture();
-};
-
-/**
- * Updates texture size based on canvas size
- *
- * @method updateTexture
- * @private
- */
-PIXI.Text.prototype.updateTexture = function()
-{
- this.texture.baseTexture.width = this.canvas.width;
- this.texture.baseTexture.height = this.canvas.height;
- this.texture.frame.width = this.canvas.width;
- this.texture.frame.height = this.canvas.height;
-
- this._width = this.canvas.width;
- this._height = this.canvas.height;
-
- PIXI.texturesToUpdate.push(this.texture.baseTexture);
-};
-
-/**
- * Updates the transfor of this object
- *
- * @method updateTransform
- * @private
- */
-PIXI.Text.prototype.updateTransform = function()
-{
- if(this.dirty)
- {
- this.updateText();
- this.dirty = false;
- }
-
- PIXI.Sprite.prototype.updateTransform.call(this);
-};
-
-/*
- * http://stackoverflow.com/users/34441/ellisbben
- * great solution to the problem!
- *
- * @method determineFontHeight
- * @param fontStyle {Object}
- * @private
- */
-PIXI.Text.prototype.determineFontHeight = function(fontStyle)
-{
- // build a little reference dictionary so if the font style has been used return a
- // cached version...
- var result = PIXI.Text.heightCache[fontStyle];
-
- if(!result)
- {
- var body = document.getElementsByTagName("body")[0];
- var dummy = document.createElement("div");
- var dummyText = document.createTextNode("M");
- dummy.appendChild(dummyText);
- dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
- body.appendChild(dummy);
-
- result = dummy.offsetHeight;
- PIXI.Text.heightCache[fontStyle] = result;
-
- body.removeChild(dummy);
- }
-
- return result;
-};
-
-/**
- * Applies newlines to a string to have it optimally fit into the horizontal
- * bounds set by the Text object's wordWrapWidth property.
- *
- * @method wordWrap
- * @param text {String}
- * @private
- */
-PIXI.Text.prototype.wordWrap = function(text)
-{
- // Greedy wrapping algorithm that will wrap words as the line grows longer
- // than its horizontal bounds.
- var result = "";
- var lines = text.split("\n");
- for (var i = 0; i < lines.length; i++)
- {
- var spaceLeft = this.style.wordWrapWidth;
- var words = lines[i].split(" ");
- for (var j = 0; j < words.length; j++)
- {
- var wordWidth = this.context.measureText(words[j]).width;
- var wordWidthWithSpace = wordWidth + this.context.measureText(" ").width;
- if(wordWidthWithSpace > spaceLeft)
- {
- // Skip printing the newline if it's the first word of the line that is
- // greater than the word wrap width.
- if(j > 0)
- {
- result += "\n";
- }
- result += words[j] + " ";
- spaceLeft = this.style.wordWrapWidth - wordWidth;
- }
- else
- {
- spaceLeft -= wordWidthWithSpace;
- result += words[j] + " ";
- }
- }
- result += "\n";
- }
- return result;
-};
-
-/**
- * Destroys this text object
- *
- * @method destroy
- * @param destroyTexture {Boolean}
- */
-PIXI.Text.prototype.destroy = function(destroyTexture)
-{
- if(destroyTexture)
- {
- this.texture.destroy();
- }
-
-};
-
-PIXI.Text.heightCache = {};
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-PIXI.BaseTextureCache = {};
-PIXI.texturesToUpdate = [];
-PIXI.texturesToDestroy = [];
-
-/**
- * A texture stores the information that represents an image. All textures have a base texture
- *
- * @class BaseTexture
- * @uses EventTarget
- * @constructor
- * @param source {String} the source object (image or canvas)
- */
-PIXI.BaseTexture = function(source)
-{
- PIXI.EventTarget.call( this );
-
- /**
- * [read-only] The width of the base texture set when the image has loaded
- *
- * @property width
- * @type Number
- * @readOnly
- */
- this.width = 100;
-
- /**
- * [read-only] The height of the base texture set when the image has loaded
- *
- * @property height
- * @type Number
- * @readOnly
- */
- this.height = 100;
-
- /**
- * [read-only] Describes if the base texture has loaded or not
- *
- * @property hasLoaded
- * @type Boolean
- * @readOnly
- */
- this.hasLoaded = false;
-
- /**
- * The source that is loaded to create the texture
- *
- * @property source
- * @type Image
- */
- this.source = source;
-
- if(!source)return;
-
- if(this.source instanceof Image || this.source instanceof HTMLImageElement)
- {
- if(this.source.complete)
- {
- this.hasLoaded = true;
- this.width = this.source.width;
- this.height = this.source.height;
-
- PIXI.texturesToUpdate.push(this);
- }
- else
- {
-
- var scope = this;
- this.source.onload = function(){
-
- scope.hasLoaded = true;
- scope.width = scope.source.width;
- scope.height = scope.source.height;
-
- // add it to somewhere...
- PIXI.texturesToUpdate.push(scope);
- scope.dispatchEvent( { type: 'loaded', content: scope } );
- }
- // this.image.src = imageUrl;
- }
- }
- else
- {
- this.hasLoaded = true;
- this.width = this.source.width;
- this.height = this.source.height;
-
- PIXI.texturesToUpdate.push(this);
- }
-
- this._powerOf2 = false;
-}
-
-PIXI.BaseTexture.prototype.constructor = PIXI.BaseTexture;
-
-/**
- * Destroys this base texture
- *
- * @method destroy
- */
-PIXI.BaseTexture.prototype.destroy = function()
-{
- if(this.source instanceof Image)
- {
- this.source.src = null;
- }
- this.source = null;
- PIXI.texturesToDestroy.push(this);
-}
-
-/**
- * Helper function that returns a base texture based on an image url
- * If the image is not in the base texture cache it will be created and loaded
- *
- * @static
- * @method fromImage
- * @param imageUrl {String} The image url of the texture
- * @return BaseTexture
- */
-PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin)
-{
- var baseTexture = PIXI.BaseTextureCache[imageUrl];
- if(!baseTexture)
- {
- // new Image() breaks tex loading in some versions of Chrome.
- // See https://code.google.com/p/chromium/issues/detail?id=238071
- var image = new Image();//document.createElement('img');
- if (crossorigin)
- {
- image.crossOrigin = '';
- }
- image.src = imageUrl;
- baseTexture = new PIXI.BaseTexture(image);
- PIXI.BaseTextureCache[imageUrl] = baseTexture;
- }
-
- return baseTexture;
-}
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-PIXI.TextureCache = {};
-PIXI.FrameCache = {};
-
-/**
- * A texture stores the information that represents an image or part of an image. It cannot be added
- * to the display list directly. To do this use PIXI.Sprite. If no frame is provided then the whole image is used
- *
- * @class Texture
- * @uses EventTarget
- * @constructor
- * @param baseTexture {BaseTexture} The base texture source to create the texture from
- * @param frame {Rectangle} The rectangle frame of the texture to show
- */
-PIXI.Texture = function(baseTexture, frame)
-{
- PIXI.EventTarget.call( this );
-
- if(!frame)
- {
- this.noFrame = true;
- frame = new PIXI.Rectangle(0,0,1,1);
- }
-
- if(baseTexture instanceof PIXI.Texture)
- baseTexture = baseTexture.baseTexture;
-
- /**
- * The base texture of this texture
- *
- * @property baseTexture
- * @type BaseTexture
- */
- this.baseTexture = baseTexture;
-
- /**
- * The frame specifies the region of the base texture that this texture uses
- *
- * @property frame
- * @type Rectangle
- */
- this.frame = frame;
-
- /**
- * The trim point
- *
- * @property trim
- * @type Point
- */
- this.trim = new PIXI.Point();
-
- this.scope = this;
-
- if(baseTexture.hasLoaded)
- {
- if(this.noFrame)frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height);
- //console.log(frame)
-
- this.setFrame(frame);
- }
- else
- {
- var scope = this;
- baseTexture.addEventListener( 'loaded', function(){ scope.onBaseTextureLoaded()} );
- }
-}
-
-PIXI.Texture.prototype.constructor = PIXI.Texture;
-
-/**
- * Called when the base texture is loaded
- *
- * @method onBaseTextureLoaded
- * @param event
- * @private
- */
-PIXI.Texture.prototype.onBaseTextureLoaded = function(event)
-{
- var baseTexture = this.baseTexture;
- baseTexture.removeEventListener( 'loaded', this.onLoaded );
-
- if(this.noFrame)this.frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height);
- this.noFrame = false;
- this.width = this.frame.width;
- this.height = this.frame.height;
-
- this.scope.dispatchEvent( { type: 'update', content: this } );
-}
-
-/**
- * Destroys this texture
- *
- * @method destroy
- * @param destroyBase {Boolean} Whether to destroy the base texture as well
- */
-PIXI.Texture.prototype.destroy = function(destroyBase)
-{
- if(destroyBase)this.baseTexture.destroy();
-}
-
-/**
- * Specifies the rectangle region of the baseTexture
- *
- * @method setFrame
- * @param frame {Rectangle} The frame of the texture to set it to
- */
-PIXI.Texture.prototype.setFrame = function(frame)
-{
- this.frame = frame;
- this.width = frame.width;
- this.height = frame.height;
-
- if(frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height)
- {
- throw new Error("Texture Error: frame does not fit inside the base Texture dimensions " + this);
- }
-
- this.updateFrame = true;
-
- PIXI.Texture.frameUpdates.push(this);
- //this.dispatchEvent( { type: 'update', content: this } );
-}
-
-/**
- * Helper function that returns a texture based on an image url
- * If the image is not in the texture cache it will be created and loaded
- *
- * @static
- * @method fromImage
- * @param imageUrl {String} The image url of the texture
- * @param crossorigin {Boolean} Whether requests should be treated as crossorigin
- * @return Texture
- */
-PIXI.Texture.fromImage = function(imageUrl, crossorigin)
-{
- var texture = PIXI.TextureCache[imageUrl];
-
- if(!texture)
- {
- texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin));
- PIXI.TextureCache[imageUrl] = texture;
- }
-
- return texture;
-}
-
-/**
- * Helper function that returns a texture based on a frame id
- * If the frame id is not in the texture cache an error will be thrown
- *
- * @static
- * @method fromFrame
- * @param frameId {String} The frame id of the texture
- * @return Texture
- */
-PIXI.Texture.fromFrame = function(frameId)
-{
- var texture = PIXI.TextureCache[frameId];
- if(!texture)throw new Error("The frameId '"+ frameId +"' does not exist in the texture cache " + this);
- return texture;
-}
-
-/**
- * Helper function that returns a texture based on a canvas element
- * If the canvas is not in the texture cache it will be created and loaded
- *
- * @static
- * @method fromCanvas
- * @param canvas {Canvas} The canvas element source of the texture
- * @return Texture
- */
-PIXI.Texture.fromCanvas = function(canvas)
-{
- var baseTexture = new PIXI.BaseTexture(canvas);
- return new PIXI.Texture(baseTexture);
-}
-
-
-/**
- * Adds a texture to the textureCache.
- *
- * @static
- * @method addTextureToCache
- * @param texture {Texture}
- * @param id {String} the id that the texture will be stored against.
- */
-PIXI.Texture.addTextureToCache = function(texture, id)
-{
- PIXI.TextureCache[id] = texture;
-}
-
-/**
- * Remove a texture from the textureCache.
- *
- * @static
- * @method removeTextureFromCache
- * @param id {String} the id of the texture to be removed
- * @return {Texture} the texture that was removed
- */
-PIXI.Texture.removeTextureFromCache = function(id)
-{
- var texture = PIXI.TextureCache[id]
- PIXI.TextureCache[id] = null;
- return texture;
-}
-
-// this is more for webGL.. it contains updated frames..
-PIXI.Texture.frameUpdates = [];
-
-
-/**
- * @author Mat Groves http://matgroves.com/ @Doormat23
- */
-
-/**
- A RenderTexture is a special texture that allows any pixi displayObject to be rendered to it.
-
- __Hint__: All DisplayObjects (exmpl. Sprites) that renders on RenderTexture should be preloaded.
- Otherwise black rectangles will be drawn instead.
-
- RenderTexture takes snapshot of DisplayObject passed to render method. If DisplayObject is passed to render method, position and rotation of it will be ignored. For example:
-
- var renderTexture = new PIXI.RenderTexture(800, 600);
- var sprite = PIXI.Sprite.fromImage("spinObj_01.png");
- sprite.position.x = 800/2;
- sprite.position.y = 600/2;
- sprite.anchor.x = 0.5;
- sprite.anchor.y = 0.5;
- renderTexture.render(sprite);
-
- Sprite in this case will be rendered to 0,0 position. To render this sprite at center DisplayObjectContainer should be used:
-
- var doc = new PIXI.DisplayObjectContainer();
- doc.addChild(sprite);
- renderTexture.render(doc); // Renders to center of renderTexture
-
- @class RenderTexture
- @extends Texture
- @constructor
- @param width {Number} The width of the render texture
- @param height {Number} The height of the render texture
- */
-PIXI.RenderTexture = function(width, height)
-{
- PIXI.EventTarget.call( this );
-
- this.width = width || 100;
- this.height = height || 100;
-
- this.indetityMatrix = PIXI.mat3.create();
-
- this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
-
- if(PIXI.gl)
- {
- this.initWebGL();
- }
- else
- {
- this.initCanvas();
- }
-}
-
-PIXI.RenderTexture.prototype = Object.create( PIXI.Texture.prototype );
-PIXI.RenderTexture.prototype.constructor = PIXI.RenderTexture;
-
-/**
- * Initializes the webgl data for this texture
- *
- * @method initWebGL
- * @private
- */
-PIXI.RenderTexture.prototype.initWebGL = function()
-{
- var gl = PIXI.gl;
- this.glFramebuffer = gl.createFramebuffer();
-
- gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
-
- this.glFramebuffer.width = this.width;
- this.glFramebuffer.height = this.height;
-
- this.baseTexture = new PIXI.BaseTexture();
-
- this.baseTexture.width = this.width;
- this.baseTexture.height = this.height;
-
- this.baseTexture._glTexture = gl.createTexture();
- gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture);
-
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-
- this.baseTexture.isRender = true;
-
- gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.baseTexture._glTexture, 0);
-
- // create a projection matrix..
- this.projection = new PIXI.Point(this.width/2 , -this.height/2);
-
- // set the correct render function..
- this.render = this.renderWebGL;
-}
-
-
-PIXI.RenderTexture.prototype.resize = function(width, height)
-{
-
- this.width = width;
- this.height = height;
-
- if(PIXI.gl)
- {
- this.projection.x = this.width/2
- this.projection.y = -this.height/2;
-
- var gl = PIXI.gl;
- gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
- }
- else
- {
-
- this.frame.width = this.width
- this.frame.height = this.height;
- this.renderer.resize(this.width, this.height);
- }
-}
-
-/**
- * Initializes the canvas data for this texture
- *
- * @method initCanvas
- * @private
- */
-PIXI.RenderTexture.prototype.initCanvas = function()
-{
- this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0);
-
- this.baseTexture = new PIXI.BaseTexture(this.renderer.view);
- this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
-
- this.render = this.renderCanvas;
-}
-
-/**
- * This function will draw the display object to the texture.
- *
- * @method renderWebGL
- * @param displayObject {DisplayObject} The display object to render this texture on
- * @param clear {Boolean} If true the texture will be cleared before the displayObject is drawn
- * @private
- */
-PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear)
-{
- var gl = PIXI.gl;
-
- // enable the alpha color mask..
- gl.colorMask(true, true, true, true);
-
- gl.viewport(0, 0, this.width, this.height);
-
- gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
-
- if(clear)
- {
- gl.clearColor(0,0,0, 0);
- gl.clear(gl.COLOR_BUFFER_BIT);
- }
-
- // THIS WILL MESS WITH HIT TESTING!
- var children = displayObject.children;
-
- //TODO -? create a new one??? dont think so!
- var originalWorldTransform = displayObject.worldTransform;
- displayObject.worldTransform = PIXI.mat3.create();//sthis.indetityMatrix;
- // modify to flip...
- displayObject.worldTransform[4] = -1;
- displayObject.worldTransform[5] = this.projection.y * -2;
-
- if(position)
- {
- displayObject.worldTransform[2] = position.x;
- displayObject.worldTransform[5] -= position.y;
- }
-
- PIXI.visibleCount++;
- displayObject.vcount = PIXI.visibleCount;
-
- for(var i=0,j=children.length; i>1;
- if(n<3) return [];
- var tgs = [];
- var avl = [];
- for(var i=0; i 3)
- {
- var i0 = avl[(i+0)%al];
- var i1 = avl[(i+1)%al];
- var i2 = avl[(i+2)%al];
-
- var ax = p[2*i0], ay = p[2*i0+1];
- var bx = p[2*i1], by = p[2*i1+1];
- var cx = p[2*i2], cy = p[2*i2+1];
-
- var earFound = false;
- if(PIXI.PolyK._convex(ax, ay, bx, by, cx, cy, sign))
- {
- earFound = true;
- for(var j=0; j 3*al)
- {
- // need to flip flip reverse it!
- // reset!
- if(sign)
- {
- var tgs = [];
- avl = [];
- for(var i=0; i= 0) && (v >= 0) && (u + v < 1);
-}
-
-/**
- * Checks if a shape is convex
- *
- * @class _convex
- * @namespace PolyK
- * @private
- */
-PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign)
-{
- return ((ay-by)*(cx-bx) + (bx-ax)*(cy-by) >= 0) == sign;
-}
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view.
-* The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y
-*
-* @class Phaser.Camera
-* @constructor
-* @param {Phaser.Game} game - Game reference to the currently running game.
-* @param {number} id - Not being used at the moment, will be when Phaser supports multiple camera
-* @param {number} x - Position of the camera on the X axis
-* @param {number} y - Position of the camera on the Y axis
-* @param {number} width - The width of the view rectangle
-* @param {number} height - The height of the view rectangle
-*/
-Phaser.Camera = function (game, id, x, y, width, height) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = game;
-
- /**
- * @property {Phaser.World} world - A reference to the game world.
- */
- this.world = game.world;
-
- /**
- * @property {number} id - Reserved for future multiple camera set-ups.
- * @default
- */
- this.id = 0;
-
- /**
- * Camera view.
- * The view into the world we wish to render (by default the game dimensions).
- * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render.
- * Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?).
- * @property {Phaser.Rectangle} view
- */
- this.view = new Phaser.Rectangle(x, y, width, height);
-
- /**
- * @property {Phaser.Rectangle} screenView - Used by Sprites to work out Camera culling.
- */
- this.screenView = new Phaser.Rectangle(x, y, width, height);
-
- /**
- * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World.
- * The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound
- * at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the center of the world.
- * @property {Phaser.Rectangle} bounds - The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere.
- */
- this.bounds = new Phaser.Rectangle(x, y, width, height);
-
- /**
- * @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving.
- */
- this.deadzone = null;
-
- /**
- * @property {boolean} visible - Whether this camera is visible or not.
- * @default
- */
- this.visible = true;
-
- /**
- * @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not.
- */
- this.atLimit = { x: false, y: false };
-
- /**
- * @property {Phaser.Sprite} target - If the camera is tracking a Sprite, this is a reference to it, otherwise null.
- * @default
- */
- this.target = null;
-
- /**
- * @property {number} edge - Edge property.
- * @private
- * @default
- */
- this._edge = 0;
-
- this.displayObject = null;
-
-};
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Camera.FOLLOW_LOCKON = 0;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Camera.FOLLOW_PLATFORMER = 1;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Camera.FOLLOW_TOPDOWN = 2;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3;
-
-Phaser.Camera.prototype = {
-
- /**
- * Tells this camera which sprite to follow.
- * @method Phaser.Camera#follow
- * @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything.
- * @param {number} [style] Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
- */
- follow: function (target, style) {
-
- if (typeof style === "undefined") { style = Phaser.Camera.FOLLOW_LOCKON; }
-
- this.target = target;
-
- var helper;
-
- switch (style) {
-
- case Phaser.Camera.FOLLOW_PLATFORMER:
- var w = this.width / 8;
- var h = this.height / 3;
- this.deadzone = new Phaser.Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h);
- break;
-
- case Phaser.Camera.FOLLOW_TOPDOWN:
- helper = Math.max(this.width, this.height) / 4;
- this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
- break;
-
- case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT:
- helper = Math.max(this.width, this.height) / 8;
- this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
- break;
-
- case Phaser.Camera.FOLLOW_LOCKON:
- default:
- this.deadzone = null;
- break;
- }
-
- },
-
- /**
- * Move the camera focus on a display object instantly.
- * @method Phaser.Camera#focusOn
- * @param {any} displayObject - The display object to focus the camera on. Must have visible x/y properties.
- */
- focusOn: function (displayObject) {
-
- this.setPosition(Math.round(displayObject.x - this.view.halfWidth), Math.round(displayObject.y - this.view.halfHeight));
-
- },
-
- /**
- * Move the camera focus on a location instantly.
- * @method Phaser.Camera#focusOnXY
- * @param {number} x - X position.
- * @param {number} y - Y position.
- */
- focusOnXY: function (x, y) {
-
- this.setPosition(Math.round(x - this.view.halfWidth), Math.round(y - this.view.halfHeight));
-
- },
-
- /**
- * Update focusing and scrolling.
- * @method Phaser.Camera#update
- */
- update: function () {
-
- if (this.target)
- {
- this.updateTarget();
- }
-
- if (this.bounds)
- {
- this.checkBounds();
- }
-
- this.displayObject.position.x = -this.view.x;
- this.displayObject.position.y = -this.view.y;
-
- },
-
- updateTarget: function () {
-
- if (this.deadzone)
- {
- this._edge = this.target.x - this.deadzone.x;
-
- if (this.view.x > this._edge)
- {
- this.view.x = this._edge;
- }
-
- this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width;
-
- if (this.view.x < this._edge)
- {
- this.view.x = this._edge;
- }
-
- this._edge = this.target.y - this.deadzone.y;
-
- if (this.view.y > this._edge)
- {
- this.view.y = this._edge;
- }
-
- this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height;
-
- if (this.view.y < this._edge)
- {
- this.view.y = this._edge;
- }
- }
- else
- {
- this.focusOnXY(this.target.x, this.target.y);
- }
-
- },
-
- setBoundsToWorld: function () {
-
- this.bounds.setTo(this.game.world.x, this.game.world.y, this.game.world.width, this.game.world.height);
-
- },
-
- /**
- * Method called to ensure the camera doesn't venture outside of the game world.
- * @method Phaser.Camera#checkWorldBounds
- */
- checkBounds: function () {
-
- this.atLimit.x = false;
- this.atLimit.y = false;
-
- // Make sure we didn't go outside the cameras bounds
- if (this.view.x < this.bounds.x)
- {
- this.atLimit.x = true;
- this.view.x = this.bounds.x;
- }
-
- if (this.view.x > this.bounds.right - this.width)
- {
- this.atLimit.x = true;
- this.view.x = (this.bounds.right - this.width) + 1;
- }
-
- if (this.view.y < this.bounds.top)
- {
- this.atLimit.y = true;
- this.view.y = this.bounds.top;
- }
-
- if (this.view.y > this.bounds.bottom - this.height)
- {
- this.atLimit.y = true;
- this.view.y = (this.bounds.bottom - this.height) + 1;
- }
-
- this.view.floor();
-
- },
-
- /**
- * A helper function to set both the X and Y properties of the camera at once
- * without having to use game.camera.x and game.camera.y.
- *
- * @method Phaser.Camera#setPosition
- * @param {number} x - X position.
- * @param {number} y - Y position.
- */
- setPosition: function (x, y) {
-
- this.view.x = x;
- this.view.y = y;
-
- if (this.bounds)
- {
- this.checkBounds();
- }
-
- },
-
- /**
- * Sets the size of the view rectangle given the width and height in parameters.
- *
- * @method Phaser.Camera#setSize
- * @param {number} width - The desired width.
- * @param {number} height - The desired height.
- */
- setSize: function (width, height) {
-
- this.view.width = width;
- this.view.height = height;
-
- }
-
-};
-
-/**
-* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds.
-* @name Phaser.Camera#x
-* @property {number} x - Gets or sets the cameras x position.
-*/
-Object.defineProperty(Phaser.Camera.prototype, "x", {
-
- get: function () {
- return this.view.x;
- },
-
- set: function (value) {
-
- this.view.x = value;
-
- if (this.bounds)
- {
- this.checkBounds();
- }
- }
-
-});
-
-/**
-* The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds.
-* @name Phaser.Camera#y
-* @property {number} y - Gets or sets the cameras y position.
-*/
-Object.defineProperty(Phaser.Camera.prototype, "y", {
-
- get: function () {
- return this.view.y;
- },
-
- set: function (value) {
-
- this.view.y = value;
-
- if (this.bounds)
- {
- this.checkBounds();
- }
- }
-
-});
-
-/**
-* The Cameras width. By default this is the same as the Game size and should not be adjusted for now.
-* @name Phaser.Camera#width
-* @property {number} width - Gets or sets the cameras width.
-*/
-Object.defineProperty(Phaser.Camera.prototype, "width", {
-
- get: function () {
- return this.view.width;
- },
-
- set: function (value) {
- this.view.width = value;
- }
-
-});
-
-/**
-* The Cameras height. By default this is the same as the Game size and should not be adjusted for now.
-* @name Phaser.Camera#height
-* @property {number} height - Gets or sets the cameras height.
-*/
-Object.defineProperty(Phaser.Camera.prototype, "height", {
-
- get: function () {
- return this.view.height;
- },
-
- set: function (value) {
- this.view.height = value;
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* This is a base State class which can be extended if you are creating your own game.
-* It provides quick access to common functions such as the camera, cache, input, match, sound and more.
-*
-* @class Phaser.State
-* @constructor
-*/
-
-Phaser.State = function () {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = null;
-
- /**
- * @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory.
- * @default
- */
- this.add = null;
-
- /**
- * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera.
- * @default
- */
- this.camera = null;
-
- /**
- * @property {Phaser.Cache} cache - Reference to the assets cache.
- * @default
- */
- this.cache = null;
-
- /**
- * @property {Phaser.Input} input - Reference to the input manager
- * @default
- */
- this.input = null;
-
- /**
- * @property {Phaser.Loader} load - Reference to the assets loader.
- * @default
- */
- this.load = null;
-
- /**
- * @property {Phaser.GameMath} math - Reference to the math helper.
- * @default
- */
- this.math = null;
-
- /**
- * @property {Phaser.SoundManager} sound - Reference to the sound manager.
- * @default
- */
- this.sound = null;
-
- /**
- * @property {Phaser.Stage} stage - Reference to the stage.
- * @default
- */
- this.stage = null;
-
- /**
- * @property {Phaser.TimeManager} time - Reference to game clock.
- * @default
- */
- this.time = null;
-
- /**
- * @property {Phaser.TweenManager} tweens - Reference to the tween manager.
- * @default
- */
- this.tweens = null;
-
- /**
- * @property {Phaser.World} world - Reference to the world.
- * @default
- */
- this.world = null;
-
- /**
- * @property {Description} add - Description.
- * @default
- */
- this.particles = null;
-
- /**
- * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager.
- * @default
- */
- this.physics = null;
-
-};
-
-Phaser.State.prototype = {
-
- /**
- * Override this method to add some load operations.
- * If you need to use the loader, you may need to use them here.
- *
- * @method Phaser.State#preload
- */
- preload: function () {
- },
-
- /**
- * Put update logic here.
- *
- * @method Phaser.State#loadUpdate
- */
- loadUpdate: function () {
- },
-
- /**
- * Put render operations here.
- *
- * @method Phaser.State#loadRender
- */
- loadRender: function () {
- },
-
- /**
- * This method is called after the game engine successfully switches states.
- * Feel free to add any setup code here (do not load anything here, override preload() instead).
- *
- * @method Phaser.State#create
- */
- create: function () {
- },
-
- /**
- * Put update logic here.
- *
- * @method Phaser.State#update
- */
- update: function () {
- },
-
- /**
- * Put render operations here.
- *
- * @method Phaser.State#render
- */
- render: function () {
- },
-
- /**
- * This method will be called when game paused.
- *
- * @method Phaser.State#paused
- */
- paused: function () {
- },
-
- /**
- * This method will be called when the state is destroyed.
- * @method Phaser.State#destroy
- */
- destroy: function () {
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* The State Manager is responsible for loading, setting up and switching game states.
-*
-* @class Phaser.StateManager
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {Phaser.State|Object} [pendingState=null] - A State object to seed the manager with.
-*/
-Phaser.StateManager = function (game, pendingState) {
-
- /**
- * A reference to the currently running game.
- * @property {Phaser.Game} game.
- */
- this.game = game;
-
- /**
- * Description.
- * @property {Description} states.
- */
- this.states = {};
-
- if (pendingState !== null)
- {
- this._pendingState = pendingState;
- }
-
-};
-
-Phaser.StateManager.prototype = {
-
- /**
- * A reference to the currently running game.
- * @property {Phaser.Game} game.
- */
- game: null,
-
- /**
- * The state to be switched to in the next frame.
- * @property {State} _pendingState
- * @private
- */
- _pendingState: null,
-
- /**
- * Flag that sets if the State has been created or not.
- * @property {boolean}_created
- * @private
- */
- _created: false,
-
- /**
- * The state to be switched to in the next frame.
- * @property {Description} states
- */
- states: {},
-
- /**
- * The current active State object (defaults to null).
- * @property {string} current
- */
- current: '',
-
- /**
- * This will be called when the state is started (i.e. set as the current active state).
- * @property {function} onInitCallback
- */
- onInitCallback: null,
-
- /**
- * This will be called when init states (loading assets...).
- * @property {function} onPreloadCallback
- */
- onPreloadCallback: null,
-
- /**
- * This will be called when create states (setup states...).
- * @property {function} onCreateCallback
- */
- onCreateCallback: null,
-
- /**
- * This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback).
- * @property {function} onUpdateCallback
- */
- onUpdateCallback: null,
-
- /**
- * This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback).
- * @property {function} onRenderCallback
- */
- onRenderCallback: null,
-
- /**
- * This will be called before the State is rendered and before the stage is cleared.
- * @property {function} onPreRenderCallback
- */
- onPreRenderCallback: null,
-
- /**
- * This will be called when the State is updated but only during the load process.
- * @property {function} onLoadUpdateCallback
- */
- onLoadUpdateCallback: null,
-
- /**
- * This will be called when the State is rendered but only during the load process.
- * @property {function} onLoadRenderCallback
- */
- onLoadRenderCallback: null,
-
- /**
- * This will be called when states paused.
- * @property {function} onPausedCallback
- */
- onPausedCallback: null,
-
- /**
- * This will be called when the state is shut down (i.e. swapped to another state).
- * @property {function} onShutDownCallback
- */
- onShutDownCallback: null,
-
- /**
- * Description.
- * @method Phaser.StateManager#boot
- * @private
- */
- boot: function () {
-
- // console.log('Phaser.StateManager.boot');
-
- if (this._pendingState !== null)
- {
- // console.log('_pendingState found');
- // console.log(typeof this._pendingState);
-
- if (typeof this._pendingState === 'string')
- {
- // State was already added, so just start it
- this.start(this._pendingState, false, false);
- }
- else
- {
- this.add('default', this._pendingState, true);
- }
-
- }
-
- },
-
- /**
- * Add a new State.
- * @method Phaser.StateManager#add
- * @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
- * @param state {State} - The state you want to switch to.
- * @param autoStart {boolean} - Start the state immediately after creating it? (default true)
- */
- add: function (key, state, autoStart) {
-
- if (typeof autoStart === "undefined") { autoStart = false; }
-
- // console.log('Phaser.StateManager.addState', key);
- // console.log(typeof state);
- // console.log('autoStart?', autoStart);
-
- var newState;
-
- if (state instanceof Phaser.State)
- {
- // console.log('Phaser.StateManager.addState: Phaser.State given');
- newState = state;
- }
- else if (typeof state === 'object')
- {
- // console.log('Phaser.StateManager.addState: Object given');
- newState = state;
- newState.game = this.game;
- }
- else if (typeof state === 'function')
- {
- // console.log('Phaser.StateManager.addState: Function given');
- newState = new state(this.game);
- }
-
- this.states[key] = newState;
-
- if (autoStart)
- {
- if (this.game.isBooted)
- {
- // console.log('Game is booted, so we can start the state now');
- this.start(key);
- }
- else
- {
- // console.log('Game is NOT booted, so set the current state as pending');
- this._pendingState = key;
- }
- }
-
- return newState;
-
- },
-
- /**
- * Delete the given state.
- * @method Phaser.StateManager#remove
- * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
- */
- remove: function (key) {
-
- if (this.current == key)
- {
- this.callbackContext = null;
-
- this.onInitCallback = null;
- this.onShutDownCallback = null;
-
- this.onPreloadCallback = null;
- this.onLoadRenderCallback = null;
- this.onLoadUpdateCallback = null;
- this.onCreateCallback = null;
- this.onUpdateCallback = null;
- this.onRenderCallback = null;
- this.onPausedCallback = null;
- this.onDestroyCallback = null;
- }
-
- delete this.states[key];
-
- },
-
- /**
- * Start the given state
- * @method Phaser.StateManager#start
- * @param {string} key - The key of the state you want to start.
- * @param {boolean} [clearWorld] - clear everything in the world? (Default to true)
- * @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true)
- */
- start: function (key, clearWorld, clearCache) {
-
- // console.log('Phaser.StateManager.start', key);
- // console.log(this);
- // console.log(this.callbackContext);
-
- if (typeof clearWorld === "undefined") { clearWorld = true; }
- if (typeof clearCache === "undefined") { clearCache = false; }
-
- if (this.game.isBooted == false)
- {
- // console.log('Game is NOT booted, so set the requested state as pending');
- this._pendingState = key;
- return;
- }
-
- if (this.checkState(key) == false)
- {
- return;
- }
- else
- {
- // Already got a state running?
- if (this.current)
- {
- this.onShutDownCallback.call(this.callbackContext, this.game);
- }
-
- if (clearWorld)
- {
- this.game.tweens.removeAll();
-
- this.game.world.destroy();
-
- if (clearCache == true)
- {
- this.game.cache.destroy();
- }
- }
-
- this.setCurrentState(key);
- }
-
- if (this.onPreloadCallback)
- {
- // console.log('Preload Callback found');
- this.game.load.reset();
- this.onPreloadCallback.call(this.callbackContext, this.game);
-
- // Is the loader empty?
- if (this.game.load.queueSize == 0)
- {
- // console.log('Loader queue empty');
- this.game.loadComplete();
- }
- else
- {
- // console.log('Loader started');
- // Start the loader going as we have something in the queue
- this.game.load.start();
- }
- }
- else
- {
- // console.log('Preload callback not found');
- // No init? Then there was nothing to load either
- this.game.loadComplete();
- }
-
- },
-
- /**
- * Used by onInit and onShutdown when those functions don't exist on the state
- * @method Phaser.StateManager#dummy
- * @private
- */
- dummy: function () {
- },
-
- /**
- * Description.
- * @method Phaser.StateManager#checkState
- * @param {string} key - The key of the state you want to check.
- * @return {boolean} Description.
- */
- checkState: function (key) {
-
- if (this.states[key])
- {
- var valid = false;
-
- if (this.states[key]['preload']) { valid = true; }
-
- if (valid == false && this.states[key]['loadRender']) { valid = true; }
- if (valid == false && this.states[key]['loadUpdate']) { valid = true; }
- if (valid == false && this.states[key]['create']) { valid = true; }
- if (valid == false && this.states[key]['update']) { valid = true; }
- if (valid == false && this.states[key]['preRender']) { valid = true; }
- if (valid == false && this.states[key]['render']) { valid = true; }
- if (valid == false && this.states[key]['paused']) { valid = true; }
-
- if (valid == false)
- {
- console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions.");
- return false;
- }
-
- return true;
- }
- else
- {
- console.warn("Phaser.StateManager - No state found with the key: " + key);
- return false;
- }
-
- },
-
- /**
- * Links game properties to the State given by the key.
- * @method Phaser.StateManager#link
- * @param {string} key - State key.
- * @protected
- */
- link: function (key) {
-
- // console.log('linked');
- this.states[key].game = this.game;
- this.states[key].add = this.game.add;
- this.states[key].camera = this.game.camera;
- this.states[key].cache = this.game.cache;
- this.states[key].input = this.game.input;
- this.states[key].load = this.game.load;
- this.states[key].math = this.game.math;
- this.states[key].sound = this.game.sound;
- this.states[key].stage = this.game.stage;
- this.states[key].time = this.game.time;
- this.states[key].tweens = this.game.tweens;
- this.states[key].world = this.game.world;
- this.states[key].particles = this.game.particles;
- this.states[key].physics = this.game.physics;
- this.states[key].rnd = this.game.rnd;
-
- },
-
- /**
- * Sets the current State. Should not be called directly (use StateManager.start)
- * @method Phaser.StateManager#setCurrentState
- * @param {string} key - State key.
- * @protected
- */
- setCurrentState: function (key) {
-
- this.callbackContext = this.states[key];
-
- this.link(key);
-
- // Used when the state is set as being the current active state
- this.onInitCallback = this.states[key]['init'] || this.dummy;
-
- this.onPreloadCallback = this.states[key]['preload'] || null;
- this.onLoadRenderCallback = this.states[key]['loadRender'] || null;
- this.onLoadUpdateCallback = this.states[key]['loadUpdate'] || null;
- this.onCreateCallback = this.states[key]['create'] || null;
- this.onUpdateCallback = this.states[key]['update'] || null;
- this.onPreRenderCallback = this.states[key]['preRender'] || null;
- this.onRenderCallback = this.states[key]['render'] || null;
- this.onPausedCallback = this.states[key]['paused'] || null;
-
- // Used when the state is no longer the current active state
- this.onShutDownCallback = this.states[key]['shutdown'] || this.dummy;
-
- this.current = key;
- this._created = false;
-
- this.onInitCallback.call(this.callbackContext, this.game);
-
- },
-
- /**
- * @method Phaser.StateManager#loadComplete
- * @protected
- */
- loadComplete: function () {
-
- // console.log('Phaser.StateManager.loadComplete');
-
- if (this._created == false && this.onCreateCallback)
- {
- // console.log('Create callback found');
- this._created = true;
- this.onCreateCallback.call(this.callbackContext, this.game);
- }
- else
- {
- this._created = true;
- }
-
- },
-
- /**
- * @method Phaser.StateManager#update
- * @protected
- */
- update: function () {
-
- if (this._created && this.onUpdateCallback)
- {
- this.onUpdateCallback.call(this.callbackContext, this.game);
- }
- else
- {
- if (this.onLoadUpdateCallback)
- {
- this.onLoadUpdateCallback.call(this.callbackContext, this.game);
- }
- }
-
- },
-
- /**
- * @method Phaser.StateManager#preRender
- * @protected
- */
- preRender: function () {
-
- if (this.onPreRenderCallback)
- {
- this.onPreRenderCallback.call(this.callbackContext, this.game);
- }
-
- },
-
- /**
- * @method Phaser.StateManager#render
- * @protected
- */
- render: function () {
-
- if (this._created && this.onRenderCallback)
- {
- this.onRenderCallback.call(this.callbackContext, this.game);
- }
- else
- {
- if (this.onLoadRenderCallback)
- {
- this.onLoadRenderCallback.call(this.callbackContext, this.game);
- }
- }
-
- },
-
- /**
- * Nuke the entire game from orbit
- * @method Phaser.StateManager#destroy
- */
- destroy: function () {
-
- this.callbackContext = null;
-
- this.onInitCallback = null;
- this.onShutDownCallback = null;
-
- this.onPreloadCallback = null;
- this.onLoadRenderCallback = null;
- this.onLoadUpdateCallback = null;
- this.onCreateCallback = null;
- this.onUpdateCallback = null;
- this.onRenderCallback = null;
- this.onPausedCallback = null;
- this.onDestroyCallback = null;
-
- this.game = null;
- this.states = {};
- this._pendingState = null;
-
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* A basic linked list data structure.
-*
-* @class Phaser.LinkedList
-* @constructor
-*/
-Phaser.LinkedList = function () {
-
- /**
- * @property {object} next - Next element in the list.
- * @default
- */
- this.next = null;
-
- /**
- * @property {object} prev - Previous element in the list.
- * @default
- */
- this.prev = null;
-
- /**
- * @property {object} first - First element in the list.
- * @default
- */
- this.first = null;
-
- /**
- * @property {object} last - Last element in the list.
- * @default
- */
- this.last = null;
-
- /**
- * @property {object} game - Number of elements in the list.
- * @default
- */
- this.total = 0;
-
-};
-
-Phaser.LinkedList.prototype = {
-
- /**
- * Adds a new element to this linked list.
- *
- * @method Phaser.LinkedList#add
- * @param {object} child - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through.
- * @return {object} The child that was added.
- */
- add: function (child) {
-
- // If the list is empty
- if (this.total == 0 && this.first == null && this.last == null)
- {
- this.first = child;
- this.last = child;
- this.next = child;
- child.prev = this;
- this.total++;
- return child;
- }
-
- // Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list)
- this.last.next = child;
-
- child.prev = this.last;
-
- this.last = child;
-
- this.total++;
-
- return child;
-
- },
-
- /**
- * Removes the given element from this linked list if it exists.
- *
- * @method Phaser.LinkedList#remove
- * @param {object} child - The child to be removed from the list.
- */
- remove: function (child) {
-
- if (child == this.first)
- {
- // It was 'first', make 'first' point to first.next
- this.first = this.first.next;
- }
- else if (child == this.last)
- {
- // It was 'last', make 'last' point to last.prev
- this.last = this.last.prev;
- }
-
- if (child.prev)
- {
- // make child.prev.next point to childs.next instead of child
- child.prev.next = child.next;
- }
-
- if (child.next)
- {
- // make child.next.prev point to child.prev instead of child
- child.next.prev = child.prev;
- }
-
- child.next = child.prev = null;
-
- if (this.first == null )
- {
- this.last = null;
- }
-
- this.total--;
-
- },
-
- /**
- * Calls a function on all members of this list, using the member as the context for the callback.
- * The function must exist on the member.
- *
- * @method Phaser.LinkedList#callAll
- * @param {function} callback - The function to call.
- */
- callAll: function (callback) {
-
- if (!this.first || !this.last)
- {
- return;
- }
-
- var entity = this.first;
-
- do
- {
- if (entity && entity[callback])
- {
- entity[callback].call(entity);
- }
-
- entity = entity.next;
-
- }
- while(entity != this.last.next)
-
- }
-
-};
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* @class Phaser.Signal
-* @classdesc A Signal is used for object communication via a custom broadcaster instead of Events.
-* @author Miller Medeiros http://millermedeiros.github.com/js-signals/
-* @constructor
-*/
-Phaser.Signal = function () {
-
- /**
- * @property {Array.} _bindings - Description.
- * @private
- */
- this._bindings = [];
-
- /**
- * @property {Description} _prevParams - Description.
- * @private
- */
- this._prevParams = null;
-
- // enforce dispatch to aways work on same context (#47)
- var self = this;
-
- /**
- * @property {Description} dispatch - Description.
- */
- this.dispatch = function(){
- Phaser.Signal.prototype.dispatch.apply(self, arguments);
- };
-
-};
-
-Phaser.Signal.prototype = {
-
- /**
- * If Signal should keep record of previously dispatched parameters and
- * automatically execute listener during `add()`/`addOnce()` if Signal was
- * already dispatched before.
- * @property {boolean} memorize
- */
- memorize: false,
-
- /**
- * @property {boolean} _shouldPropagate
- * @private
- */
- _shouldPropagate: true,
-
- /**
- * If Signal is active and should broadcast events.
- *
IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.
- * @property {boolean} active
- * @default
- */
- active: true,
-
- /**
- * @method Phaser.Signal#validateListener
- * @param {function} listener - Signal handler function.
- * @param {Description} fnName - Description.
- * @private
- */
- validateListener: function (listener, fnName) {
- if (typeof listener !== 'function') {
- throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );
- }
- },
-
- /**
- * @method Phaser.Signal#_registerListener
- * @param {function} listener - Signal handler function.
- * @param {boolean} isOnce - Description.
- * @param {object} [listenerContext] - Description.
- * @param {number} [priority] - The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0).
- * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener.
- * @private
- */
- _registerListener: function (listener, isOnce, listenerContext, priority) {
-
- var prevIndex = this._indexOfListener(listener, listenerContext),
- binding;
-
- if (prevIndex !== -1) {
- binding = this._bindings[prevIndex];
- if (binding.isOnce() !== isOnce) {
- throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.');
- }
- } else {
- binding = new Phaser.SignalBinding(this, listener, isOnce, listenerContext, priority);
- this._addBinding(binding);
- }
-
- if (this.memorize && this._prevParams){
- binding.execute(this._prevParams);
- }
-
- return binding;
- },
-
- /**
- * @method Phaser.Signal#_addBinding
- * @param {Phaser.SignalBinding} binding - An Object representing the binding between the Signal and listener.
- * @private
- */
- _addBinding: function (binding) {
- //simplified insertion sort
- var n = this._bindings.length;
- do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);
- this._bindings.splice(n + 1, 0, binding);
- },
-
- /**
- * @method Phaser.Signal#_indexOfListener
- * @param {function} listener - Signal handler function.
- * @return {number} Description.
- * @private
- */
- _indexOfListener: function (listener, context) {
- var n = this._bindings.length,
- cur;
- while (n--) {
- cur = this._bindings[n];
- if (cur._listener === listener && cur.context === context) {
- return n;
- }
- }
- return -1;
- },
-
- /**
- * Check if listener was attached to Signal.
- *
- * @method Phaser.Signal#has
- * @param {Function} listener - Signal handler function.
- * @param {Object} [context] - Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @return {boolean} If Signal has the specified listener.
- */
- has: function (listener, context) {
- return this._indexOfListener(listener, context) !== -1;
- },
-
- /**
- * Add a listener to the signal.
- *
- * @method Phaser.Signal#add
- * @param {function} listener - Signal handler function.
- * @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0).
- * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener.
- */
- add: function (listener, listenerContext, priority) {
- this.validateListener(listener, 'add');
- return this._registerListener(listener, false, listenerContext, priority);
- },
-
- /**
- * Add listener to the signal that should be removed after first execution (will be executed only once).
- *
- * @method Phaser.Signal#addOnce
- * @param {function} listener Signal handler function.
- * @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
- * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener.
- */
- addOnce: function (listener, listenerContext, priority) {
- this.validateListener(listener, 'addOnce');
- return this._registerListener(listener, true, listenerContext, priority);
- },
-
- /**
- * Remove a single listener from the dispatch queue.
- *
- * @method Phaser.Signal#remove
- * @param {function} listener Handler function that should be removed.
- * @param {object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
- * @return {function} Listener handler function.
- */
- remove: function (listener, context) {
-
- this.validateListener(listener, 'remove');
-
- var i = this._indexOfListener(listener, context);
-
- if (i !== -1)
- {
- this._bindings[i]._destroy(); //no reason to a Phaser.SignalBinding exist if it isn't attached to a signal
- this._bindings.splice(i, 1);
- }
-
- return listener;
-
- },
-
- /**
- * Remove all listeners from the Signal.
- *
- * @method Phaser.Signal#removeAll
- */
- removeAll: function () {
- var n = this._bindings.length;
- while (n--) {
- this._bindings[n]._destroy();
- }
- this._bindings.length = 0;
- },
-
- /**
- * Gets the total number of listeneres attached to ths Signal.
- *
- * @method Phaser.Signal#getNumListeners
- * @return {number} Number of listeners attached to the Signal.
- */
- getNumListeners: function () {
- return this._bindings.length;
- },
-
- /**
- * Stop propagation of the event, blocking the dispatch to next listeners on the queue.
- *
IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.
- * @see Signal.prototype.disable
- *
- * @method Phaser.Signal#halt
- */
- halt: function () {
- this._shouldPropagate = false;
- },
-
- /**
- * Dispatch/Broadcast Signal to all listeners added to the queue.
- *
- * @method Phaser.Signal#dispatch
- * @param {any} [params] - Parameters that should be passed to each handler.
- */
- dispatch: function (params) {
- if (! this.active) {
- return;
- }
-
- var paramsArr = Array.prototype.slice.call(arguments),
- n = this._bindings.length,
- bindings;
-
- if (this.memorize) {
- this._prevParams = paramsArr;
- }
-
- if (! n) {
- //should come after memorize
- return;
- }
-
- bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch
- this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch.
-
- //execute all callbacks until end of the list or until a callback returns `false` or stops propagation
- //reverse loop since listeners with higher priority will be added at the end of the list
- do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
- },
-
- /**
- * Forget memorized arguments.
- * @see Signal.memorize
- *
- * @method Phaser.Signal#forget
- */
- forget: function(){
- this._prevParams = null;
- },
-
- /**
- * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).
- *
IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.
- *
- * @method Phaser.Signal#dispose
- */
- dispose: function () {
- this.removeAll();
- delete this._bindings;
- delete this._prevParams;
- },
-
- /**
- *
- * @method Phaser.Signal#toString
- * @return {string} String representation of the object.
- */
- toString: function () {
- return '[Phaser.Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']';
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser.SignalBinding
-*
-* Object that represents a binding between a Signal and a listener function.
-* - This is an internal constructor and shouldn't be called by regular users.
-* - inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.
-*
-* @class Phaser.SignalBinding
-* @name SignalBinding
-* @author Miller Medeiros http://millermedeiros.github.com/js-signals/
-* @constructor
-* @inner
-* @param {Signal} signal - Reference to Signal object that listener is currently bound to.
-* @param {function} listener - Handler function bound to the signal.
-* @param {boolean} isOnce - If binding should be executed just once.
-* @param {object} [listenerContext] - Context on which listener will be executed (object that should represent the `this` variable inside listener function).
-* @param {number} [priority] - The priority level of the event listener. (default = 0).
-*/
-Phaser.SignalBinding = function (signal, listener, isOnce, listenerContext, priority) {
-
- /**
- * @property {Phaser.Game} _listener - Handler function bound to the signal.
- * @private
- */
- this._listener = listener;
-
- /**
- * @property {boolean} _isOnce - If binding should be executed just once.
- * @private
- */
- this._isOnce = isOnce;
-
- /**
- * @property {object|undefined|null} context - Context on which listener will be executed (object that should represent the `this` variable inside listener function).
- * @memberof SignalBinding.prototype
- */
- this.context = listenerContext;
-
- /**
- * @property {Signal} _signal - Reference to Signal object that listener is currently bound to.
- * @private
- */
- this._signal = signal;
-
- /**
- * @property {number} _priority - Listener priority.
- * @private
- */
- this._priority = priority || 0;
-
-};
-
-Phaser.SignalBinding.prototype = {
-
- /**
- * If binding is active and should be executed.
- * @property {boolean} active
- * @default
- */
- active: true,
-
- /**
- * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute` (curried parameters).
- * @property {array|null} params
- * @default
- */
- params: null,
-
- /**
- * Call listener passing arbitrary parameters.
- *
If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.
- * @method Phaser.SignalBinding#execute
- * @param {array} [paramsArr] - Array of parameters that should be passed to the listener.
- * @return {Description} Value returned by the listener.
- */
- execute: function (paramsArr) {
-
- var handlerReturn, params;
-
- if (this.active && !!this._listener)
- {
- params = this.params? this.params.concat(paramsArr) : paramsArr;
- handlerReturn = this._listener.apply(this.context, params);
-
- if (this._isOnce)
- {
- this.detach();
- }
- }
-
- return handlerReturn;
-
- },
-
- /**
- * Detach binding from signal.
- *
alias to: @see mySignal.remove(myBinding.getListener());
- * @method Phaser.SignalBinding#detach
- * @return {function|null} Handler function bound to the signal or `null` if binding was previously detached.
- */
- detach: function () {
- return this.isBound() ? this._signal.remove(this._listener, this.context) : null;
- },
-
- /**
- * @method Phaser.SignalBinding#isBound
- * @return {boolean} True if binding is still bound to the signal and has a listener.
- */
- isBound: function () {
- return (!!this._signal && !!this._listener);
- },
-
- /**
- * @method Phaser.SignalBinding#isOnce
- * @return {boolean} If SignalBinding will only be executed once.
- */
- isOnce: function () {
- return this._isOnce;
- },
-
- /**
- * @method Phaser.SignalBinding#getListener
- * @return {Function} Handler function bound to the signal.
- */
- getListener: function () {
- return this._listener;
- },
-
- /**
- * @method Phaser.SignalBinding#getSignal
- * @return {Signal} Signal that listener is currently bound to.
- */
- getSignal: function () {
- return this._signal;
- },
-
- /**
- * @method Phaser.SignalBinding#_destroy
- * Delete instance properties
- * @private
- */
- _destroy: function () {
- delete this._signal;
- delete this._listener;
- delete this.context;
- },
-
- /**
- * @method Phaser.SignalBinding#toString
- * @return {string} String representation of the object.
- */
- toString: function () {
- return '[Phaser.SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']';
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* This is a base Plugin template to use for any Phaser plugin development.
-*
-* @class Phaser.Plugin
-* @classdesc Phaser - Plugin
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {Any} parent - The object that owns this plugin, usually Phaser.PluginManager.
-*/
-Phaser.Plugin = function (game, parent) {
-
- if (typeof parent === 'undefined') { parent = null; }
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = game;
-
- /**
- * @property {Any} parent - The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null.
- */
- this.parent = parent;
-
- /**
- * @property {boolean} active - A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped.
- * @default
- */
- this.active = false;
-
- /**
- * @property {boolean} visible - A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped.
- * @default
- */
- this.visible = false;
-
- /**
- * @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method.
- * @default
- */
- this.hasPreUpdate = false;
-
- /**
- * @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method.
- * @default
- */
- this.hasUpdate = false;
-
- /**
- * @property {boolean} hasPostUpdate - A flag to indicate if this plugin has a postUpdate method.
- * @default
- */
- this.hasPostUpdate = false;
-
- /**
- * @property {boolean} hasRender - A flag to indicate if this plugin has a render method.
- * @default
- */
- this.hasRender = false;
-
- /**
- * @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method.
- * @default
- */
- this.hasPostRender = false;
-
-};
-
-Phaser.Plugin.prototype = {
-
- /**
- * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics).
- * It is only called if active is set to true.
- * @method Phaser.Plugin#preUpdate
- */
- preUpdate: function () {
- },
-
- /**
- * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render.
- * It is only called if active is set to true.
- * @method Phaser.Plugin#update
- */
- update: function () {
- },
-
- /**
- * Render is called right after the Game Renderer completes, but before the State.render.
- * It is only called if visible is set to true.
- * @method Phaser.Plugin#render
- */
- render: function () {
- },
-
- /**
- * Post-render is called after the Game Renderer and State.render have run.
- * It is only called if visible is set to true.
- * @method Phaser.Plugin#postRender
- */
- postRender: function () {
- },
-
- /**
- * Clear down this Plugin and null out references
- * @method Phaser.Plugin#destroy
- */
- destroy: function () {
-
- this.game = null;
- this.parent = null;
- this.active = false;
- this.visible = false;
-
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Description.
-*
-* @class Phaser.PluginManager
-* @classdesc Phaser - PluginManager
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {Description} parent - Description.
-*/
-Phaser.PluginManager = function(game, parent) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = game;
-
- /**
- * @property {Description} _parent - Description.
- * @private
- */
- this._parent = parent;
-
- /**
- * @property {array} plugins - Description.
- */
- this.plugins = [];
-
- /**
- * @property {array} _pluginsLength - Description.
- * @private
- * @default
- */
- this._pluginsLength = 0;
-
-};
-
-Phaser.PluginManager.prototype = {
-
- /**
- * Add a new Plugin to the PluginManager.
- * The plugin's game and parent reference are set to this game and pluginmanager parent.
- * @method Phaser.PluginManager#add
- * @param {Phaser.Plugin} plugin - Description.
- * @return {Phaser.Plugin} Description.
- */
- add: function (plugin) {
-
- var result = false;
-
- // Prototype?
- if (typeof plugin === 'function')
- {
- plugin = new plugin(this.game, this._parent);
- }
- else
- {
- plugin.game = this.game;
- plugin.parent = this._parent;
- }
-
- // Check for methods now to avoid having to do this every loop
- if (typeof plugin['preUpdate'] === 'function')
- {
- plugin.hasPreUpdate = true;
- result = true;
- }
-
- if (typeof plugin['update'] === 'function')
- {
- plugin.hasUpdate = true;
- result = true;
- }
-
- if (typeof plugin['postUpdate'] === 'function')
- {
- plugin.hasPostUpdate = true;
- result = true;
- }
-
- if (typeof plugin['render'] === 'function')
- {
- plugin.hasRender = true;
- result = true;
- }
-
- if (typeof plugin['postRender'] === 'function')
- {
- plugin.hasPostRender = true;
- result = true;
- }
-
- // The plugin must have at least one of the above functions to be added to the PluginManager.
- if (result)
- {
- if (plugin.hasPreUpdate || plugin.hasUpdate)
- {
- plugin.active = true;
- }
-
- if (plugin.hasRender || plugin.hasPostRender)
- {
- plugin.visible = true;
- }
-
- this._pluginsLength = this.plugins.push(plugin);
-
- // Allows plugins to run potentially destructive code outside of the constructor, and only if being added to the PluginManager
- if (typeof plugin['init'] === 'function')
- {
- plugin.init();
- }
-
- return plugin;
- }
- else
- {
- return null;
- }
- },
-
- /**
- * Remove a Plugin from the PluginManager.
- * @method Phaser.PluginManager#remove
- * @param {Phaser.Plugin} plugin - The plugin to be removed.
- */
- remove: function (plugin) {
-
- // TODO
- this._pluginsLength--;
-
- },
-
- /**
- * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics).
- * It only calls plugins who have active=true.
- *
- * @method Phaser.PluginManager#preUpdate
- */
- preUpdate: function () {
-
- if (this._pluginsLength == 0)
- {
- return;
- }
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].active && this.plugins[this._p].hasPreUpdate)
- {
- this.plugins[this._p].preUpdate();
- }
- }
-
- },
-
- /**
- * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render.
- * It only calls plugins who have active=true.
- *
- * @method Phaser.PluginManager#update
- */
- update: function () {
-
- if (this._pluginsLength == 0)
- {
- return;
- }
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].active && this.plugins[this._p].hasUpdate)
- {
- this.plugins[this._p].update();
- }
- }
-
- },
-
- /**
- * PostUpdate is the last thing to be called before the world render.
- * In particular, it is called after the world postUpdate, which means the camera has been adjusted.
- * It only calls plugins who have active=true.
- *
- * @method Phaser.PluginManager#postUpdate
- */
- postUpdate: function () {
-
- if (this._pluginsLength == 0)
- {
- return;
- }
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].active && this.plugins[this._p].hasPostUpdate)
- {
- this.plugins[this._p].postUpdate();
- }
- }
-
- },
-
- /**
- * Render is called right after the Game Renderer completes, but before the State.render.
- * It only calls plugins who have visible=true.
- *
- * @method Phaser.PluginManager#render
- */
- render: function () {
-
- if (this._pluginsLength == 0)
- {
- return;
- }
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].visible && this.plugins[this._p].hasRender)
- {
- this.plugins[this._p].render();
- }
- }
-
- },
-
- /**
- * Post-render is called after the Game Renderer and State.render have run.
- * It only calls plugins who have visible=true.
- *
- * @method Phaser.PluginManager#postRender
- */
- postRender: function () {
-
- if (this._pluginsLength == 0)
- {
- return;
- }
-
- for (this._p = 0; this._p < this._pluginsLength; this._p++)
- {
- if (this.plugins[this._p].visible && this.plugins[this._p].hasPostRender)
- {
- this.plugins[this._p].postRender();
- }
- }
-
- },
-
- /**
- * Clear down this PluginManager and null out references
- *
- * @method Phaser.PluginManager#destroy
- */
- destroy: function () {
-
- this.plugins.length = 0;
- this._pluginsLength = 0;
- this.game = null;
- this._parent = null;
-
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* The Stage controls the canvas on which everything is displayed. It handles display within the browser,
-* focus handling, game resizing, scaling and the pause, boot and orientation screens.
-*
-* @class Phaser.Stage
-* @constructor
-* @param {Phaser.Game} game - Game reference to the currently running game.
-* @param {number} width - Width of the canvas element.
-* @param {number} height - Height of the canvas element.
- */
-Phaser.Stage = function (game, width, height) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = game;
-
- /**
- * @property {string} game - Background color of the stage (defaults to black). Set via the public backgroundColor property.
- * @private
- * @default 'rgb(0,0,0)'
- */
- this._backgroundColor = 'rgb(0,0,0)';
-
- /**
- * @property {Phaser.Point} offset - Get the offset values (for input and other things).
- */
- this.offset = new Phaser.Point;
-
- /**
- * @property {HTMLCanvasElement} canvas - Reference to the newly created <canvas> element.
- */
- this.canvas = Phaser.Canvas.create(width, height);
- this.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%';
-
- /**
- * @property {PIXI.Stage} _stage - The Pixi Stage which is hooked to the renderer.
- * @private
- */
- this._stage = new PIXI.Stage(0x000000, false);
- this._stage.name = '_stage_root';
- this._stage.interactive = false;
-
- /**
- * @property {number} scaleMode - The current scaleMode.
- */
- this.scaleMode = Phaser.StageScaleMode.NO_SCALE;
-
- /**
- * @property {Phaser.StageScaleMode} scale - The scale of the current running game.
- */
- this.scale = new Phaser.StageScaleMode(this.game, width, height);
-
- /**
- * @property {number} aspectRatio - Aspect ratio.
- */
- this.aspectRatio = width / height;
-
- /**
- * @property {number} _nextOffsetCheck - The time to run the next offset check.
- * @private
- */
- this._nextOffsetCheck = 0;
-
- /**
- * @property {number|false} checkOffsetInterval - The time (in ms) between which the stage should check to see if it has moved.
- * @default
- */
- this.checkOffsetInterval = 2500;
-
-};
-
-Phaser.Stage.prototype = {
-
- /**
- * Initialises the stage and adds the event listeners.
- * @method Phaser.Stage#boot
- * @private
- */
- boot: function () {
-
- Phaser.Canvas.getOffset(this.canvas, this.offset);
-
- this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, this.game.width, this.game.height);
-
- var _this = this;
-
- this._onChange = function (event) {
- return _this.visibilityChange(event);
- }
-
- Phaser.Canvas.setUserSelect(this.canvas, 'none');
- Phaser.Canvas.setTouchAction(this.canvas, 'none');
-
- document.addEventListener('visibilitychange', this._onChange, false);
- document.addEventListener('webkitvisibilitychange', this._onChange, false);
- document.addEventListener('pagehide', this._onChange, false);
- document.addEventListener('pageshow', this._onChange, false);
-
- window.onblur = this._onChange;
- window.onfocus = this._onChange;
-
- },
-
- /**
- * Runs Stage processes that need periodic updates, such as the offset checks.
- * @method Phaser.Stage#update
- */
- update: function () {
-
- if (this.checkOffsetInterval !== false)
- {
- if (this.game.time.now > this._nextOffsetCheck)
- {
- Phaser.Canvas.getOffset(this.canvas, this.offset);
- this._nextOffsetCheck = this.game.time.now + this.checkOffsetInterval;
- }
-
- }
-
- },
-
- /**
- * This method is called when the document visibility is changed.
- * @method Phaser.Stage#visibilityChange
- * @param {Event} event - Its type will be used to decide whether the game should be paused or not.
- */
- visibilityChange: function (event) {
-
- if (this.disableVisibilityChange)
- {
- return;
- }
-
- if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true)
- {
- this.game.paused = true;
- }
- else
- {
- this.game.paused = false;
- }
-
- },
-
-};
-
-/**
-* @name Phaser.Stage#backgroundColor
-* @property {number|string} backgroundColor - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000'
-*/
-Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
-
- get: function () {
- return this._backgroundColor;
- },
-
- set: function (color) {
-
- this._backgroundColor = color;
-
- if (this.game.renderType == Phaser.CANVAS)
- {
- // Set it directly, this allows us to use rgb alpha values in Canvas mode.
- this._stage.backgroundColorString = color;
- }
- else
- {
- if (typeof color === 'string')
- {
- color = Phaser.Color.hexToRGB(color);
- }
-
- this._stage.setBackgroundColor(color);
- }
-
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser Group constructor.
-* @class Phaser.Group
-* @classdesc A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any.
-* @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging.
-* @param {boolean} [useStage=false] - Should the DisplayObjectContainer this Group creates be added to the World (default, false) or direct to the Stage (true).
-*/
-Phaser.Group = function (game, parent, name, useStage) {
-
- if (typeof parent === 'undefined')
- {
- parent = game.world;
- }
-
- if (typeof useStage === 'undefined')
- {
- useStage = false;
- }
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = game;
-
- /**
- * @property {string} name - A name for this Group. Not used internally but useful for debugging.
- */
- this.name = name || 'group';
-
- if (useStage)
- {
- this._container = this.game.stage._stage;
- }
- else
- {
- this._container = new PIXI.DisplayObjectContainer();
- this._container.name = this.name;
-
- if (parent)
- {
- if (parent instanceof Phaser.Group)
- {
- parent._container.addChild(this._container);
- parent._container.updateTransform();
- }
- else
- {
- parent.addChild(this._container);
- parent.updateTransform();
- }
- }
- else
- {
- this.game.stage._stage.addChild(this._container);
- this.game.stage._stage.updateTransform();
- }
- }
-
- /**
- * @property {number} type - Internal Phaser Type value.
- * @protected
- */
- this.type = Phaser.GROUP;
-
- /**
- * @property {boolean} exists - If exists is true the the Group is updated, otherwise it is skipped.
- * @default
- */
- this.exists = true;
-
- /**
- * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one.
- */
- this.scale = new Phaser.Point(1, 1);
-
- /**
- * The cursor is a simple way to iterate through the objects in a Group using the Group.next and Group.previous functions.
- * The cursor is set to the first child added to the Group and doesn't change unless you call next, previous or set it directly with Group.cursor.
- * @property {any} cursor - The current display object that the Group cursor is pointing to.
- */
- this.cursor = null;
-
-};
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Group.RETURN_NONE = 0;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Group.RETURN_TOTAL = 1;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Group.RETURN_CHILD = 2;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Group.SORT_ASCENDING = -1;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Group.SORT_DESCENDING = 1;
-
-Phaser.Group.prototype = {
-
- /**
- * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object.
- * The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control
- * that then see the addAt method.
- *
- * @see Phaser.Group#create
- * @see Phaser.Group#addAt
- * @method Phaser.Group#add
- * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
- * @return {*} The child that was added to the Group.
- */
- add: function (child) {
-
- if (child.group !== this)
- {
- child.group = this;
-
- if (child.events)
- {
- child.events.onAddedToGroup.dispatch(child, this);
- }
-
- this._container.addChild(child);
-
- child.updateTransform();
-
- if (this.cursor === null)
- {
- this.cursor = child;
- }
- }
-
- return child;
-
- },
-
- /**
- * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object.
- * The child is added to the Group at the location specified by the index value, this allows you to control child ordering.
- *
- * @method Phaser.Group#addAt
- * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
- * @param {number} index - The index within the Group to insert the child to.
- * @return {*} The child that was added to the Group.
- */
- addAt: function (child, index) {
-
- if (child.group !== this)
- {
- child.group = this;
-
- if (child.events)
- {
- child.events.onAddedToGroup.dispatch(child, this);
- }
-
- this._container.addChildAt(child, index);
-
- child.updateTransform();
-
- if (this.cursor === null)
- {
- this.cursor = child;
- }
- }
-
- return child;
-
- },
-
- /**
- * Returns the child found at the given index within this Group.
- *
- * @method Phaser.Group#getAt
- * @memberof Phaser.Group
- * @param {number} index - The index to return the child from.
- * @return {*} The child that was found at the given index.
- */
- getAt: function (index) {
-
- return this._container.getChildAt(index);
-
- },
-
- /**
- * Automatically creates a new Phaser.Sprite object and adds it to the top of this Group.
- * Useful if you don't need to create the Sprite instances before-hand.
- *
- * @method Phaser.Group#create
- * @param {number} x - The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point.
- * @param {number} y - The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point.
- * @param {string} key - The Game.cache key of the image that this Sprite will use.
- * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here.
- * @param {boolean} [exists=true] - The default exists state of the Sprite.
- * @return {Phaser.Sprite} The child that was created.
- */
- create: function (x, y, key, frame, exists) {
-
- if (typeof exists == 'undefined') { exists = true; }
-
- var child = new Phaser.Sprite(this.game, x, y, key, frame);
-
- child.group = this;
- child.exists = exists;
- child.visible = exists;
- child.alive = exists;
-
- if (child.events)
- {
- child.events.onAddedToGroup.dispatch(child, this);
- }
-
- this._container.addChild(child);
-
- child.updateTransform();
-
- if (this.cursor === null)
- {
- this.cursor = child;
- }
-
- return child;
-
- },
-
- /**
- * Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group.
- * Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist
- * and will be positioned at 0, 0 (relative to the Group.x/y)
- *
- * @method Phaser.Group#createMultiple
- * @param {number} quantity - The number of Sprites to create.
- * @param {string} key - The Game.cache key of the image that this Sprite will use.
- * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here.
- * @param {boolean} [exists=false] - The default exists state of the Sprite.
- */
- createMultiple: function (quantity, key, frame, exists) {
-
- if (typeof exists == 'undefined') { exists = false; }
-
- for (var i = 0; i < quantity; i++)
- {
- var child = new Phaser.Sprite(this.game, 0, 0, key, frame);
-
- child.group = this;
- child.exists = exists;
- child.visible = exists;
- child.alive = exists;
-
- if (child.events)
- {
- child.events.onAddedToGroup.dispatch(child, this);
- }
-
- this._container.addChild(child);
- child.updateTransform();
-
- if (this.cursor === null)
- {
- this.cursor = child;
- }
-
- }
-
- },
-
- /**
- * Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object.
- *
- * @method Phaser.Group#next
- */
- next: function () {
-
- if (this.cursor)
- {
- // Wrap the cursor?
- if (this.cursor == this._container.last)
- {
- this.cursor = this._container._iNext;
- }
- else
- {
- this.cursor = this.cursor._iNext;
- }
- }
-
- },
-
- /**
- * Moves the Group cursor to the previous object in the Group. If it's at the start of the Group it wraps around to the last object.
- *
- * @method Phaser.Group#previous
- */
- previous: function () {
-
- if (this.cursor)
- {
- // Wrap the cursor?
- if (this.cursor == this._container._iNext)
- {
- this.cursor = this._container.last;
- }
- else
- {
- this.cursor = this.cursor._iPrev;
- }
- }
-
- },
-
- childTest: function (prefix, child) {
-
- var s = prefix + ' next: ';
-
- if (child._iNext)
- {
- s = s + child._iNext.name;
- }
- else
- {
- s = s + '-null-';
- }
-
- s = s + ' ' + prefix + ' prev: ';
-
- if (child._iPrev)
- {
- s = s + child._iPrev.name;
- }
- else
- {
- s = s + '-null-';
- }
-
- console.log(s);
-
- },
-
- swapIndex: function (index1, index2) {
-
- var child1 = this.getAt(index1);
- var child2 = this.getAt(index2);
-
- console.log('swapIndex ', index1, ' with ', index2);
-
- this.swap(child1, child2);
-
- },
-
- /**
- * Swaps the position of two children in this Group. Both children must be in this Group.
- * You cannot swap a child with itself, or swap un-parented children, doing so will return false.
- *
- * @method Phaser.Group#swap
- * @param {*} child1 - The first child to swap.
- * @param {*} child2 - The second child to swap.
- * @return {boolean} True if the swap was successful, otherwise false.
- */
- swap: function (child1, child2) {
-
- if (child1 === child2 || !child1.parent || !child2.parent || child1.group !== this || child2.group !== this)
- {
- return false;
- }
-
- // Cache the values
- var child1Prev = child1._iPrev;
- var child1Next = child1._iNext;
- var child2Prev = child2._iPrev;
- var child2Next = child2._iNext;
-
- var endNode = this._container.last._iNext;
- var currentNode = this.game.stage._stage;
-
- do
- {
- if (currentNode !== child1 && currentNode !== child2)
- {
- if (currentNode.first === child1)
- {
- currentNode.first = child2;
- }
- else if (currentNode.first === child2)
- {
- currentNode.first = child1;
- }
-
- if (currentNode.last === child1)
- {
- currentNode.last = child2;
- }
- else if (currentNode.last === child2)
- {
- currentNode.last = child1;
- }
- }
-
- currentNode = currentNode._iNext;
- }
- while (currentNode != endNode)
-
- if (child1._iNext == child2)
- {
- // This is a downward (A to B) neighbour swap
- child1._iNext = child2Next;
- child1._iPrev = child2;
- child2._iNext = child1;
- child2._iPrev = child1Prev;
-
- if (child1Prev) { child1Prev._iNext = child2; }
- if (child2Next) { child2Next._iPrev = child1; }
-
- if (child1.__renderGroup)
- {
- child1.__renderGroup.updateTexture(child1);
- }
-
- if (child2.__renderGroup)
- {
- child2.__renderGroup.updateTexture(child2);
- }
-
- return true;
- }
- else if (child2._iNext == child1)
- {
- // This is an upward (B to A) neighbour swap
- child1._iNext = child2;
- child1._iPrev = child2Prev;
- child2._iNext = child1Next;
- child2._iPrev = child1;
-
- if (child2Prev) { child2Prev._iNext = child1; }
- if (child1Next) { child1Next._iPrev = child2; }
-
- if (child1.__renderGroup)
- {
- child1.__renderGroup.updateTexture(child1);
- }
-
- if (child2.__renderGroup)
- {
- child2.__renderGroup.updateTexture(child2);
- }
-
- return true;
- }
- else
- {
- // Children are far apart
- child1._iNext = child2Next;
- child1._iPrev = child2Prev;
- child2._iNext = child1Next;
- child2._iPrev = child1Prev;
-
- if (child1Prev) { child1Prev._iNext = child2; }
- if (child1Next) { child1Next._iPrev = child2; }
- if (child2Prev) { child2Prev._iNext = child1; }
- if (child2Next) { child2Next._iPrev = child1; }
-
- if (child1.__renderGroup)
- {
- child1.__renderGroup.updateTexture(child1);
- }
-
- if (child2.__renderGroup)
- {
- child2.__renderGroup.updateTexture(child2);
- }
-
- return true;
- }
-
- return false;
-
- },
-
- /**
- * Brings the given child to the top of this Group so it renders above all other children.
- *
- * @method Phaser.Group#bringToTop
- * @param {*} child - The child to bring to the top of this Group.
- * @return {*} The child that was moved.
- */
- bringToTop: function (child) {
-
- if (child.group === this)
- {
- this.remove(child);
- this.add(child);
- }
-
- return child;
-
- },
-
- /**
- * Get the index position of the given child in this Group.
- *
- * @method Phaser.Group#getIndex
- * @param {*} child - The child to get the index for.
- * @return {number} The index of the child or -1 if it's not a member of this Group.
- */
- getIndex: function (child) {
-
- return this._container.children.indexOf(child);
-
- },
-
- /**
- * Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group.
- *
- * @method Phaser.Group#replace
- * @param {*} oldChild - The child in this Group that will be replaced.
- * @param {*} newChild - The child to be inserted into this group.
- */
- replace: function (oldChild, newChild) {
-
- if (!this._container.first._iNext)
- {
- return;
- }
-
- var index = this.getIndex(oldChild);
-
- if (index != -1)
- {
- if (newChild.parent != undefined)
- {
- newChild.events.onRemovedFromGroup.dispatch(newChild, this);
- newChild.parent.removeChild(newChild);
- }
-
- this._container.removeChild(oldChild);
- this._container.addChildAt(newChild, index);
-
- newChild.events.onAddedToGroup.dispatch(newChild, this);
- newChild.updateTransform();
-
- if (this.cursor == oldChild)
- {
- this.cursor = this._container._iNext;
- }
- }
-
- },
-
- /**
- * Sets the given property to the given value on the child. The operation controls the assignment of the value.
- *
- * @method Phaser.Group#setProperty
- * @param {*} child - The child to set the property value on.
- * @param {array} key - An array of strings that make up the property that will be set.
- * @param {*} value - The value that will be set.
- * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
- */
- setProperty: function (child, key, value, operation) {
-
- operation = operation || 0;
-
- // As ugly as this approach looks, and although it's limited to a depth of only 4, it's extremely fast.
- // Much faster than a for loop or object iteration. There are no checks, so if the key isn't valid then it'll fail
- // but as you are likely to call this from inner loops that have to perform well, I'll take that trade off.
-
- // 0 = Equals
- // 1 = Add
- // 2 = Subtract
- // 3 = Multiply
- // 4 = Divide
-
- var len = key.length;
-
- if (len == 1)
- {
- if (operation == 0) { child[key[0]] = value; }
- else if (operation == 1) { child[key[0]] += value; }
- else if (operation == 2) { child[key[0]] -= value; }
- else if (operation == 3) { child[key[0]] *= value; }
- else if (operation == 4) { child[key[0]] /= value; }
- }
- else if (len == 2)
- {
- if (operation == 0) { child[key[0]][key[1]] = value; }
- else if (operation == 1) { child[key[0]][key[1]] += value; }
- else if (operation == 2) { child[key[0]][key[1]] -= value; }
- else if (operation == 3) { child[key[0]][key[1]] *= value; }
- else if (operation == 4) { child[key[0]][key[1]] /= value; }
- }
- else if (len == 3)
- {
- if (operation == 0) { child[key[0]][key[1]][key[2]] = value; }
- else if (operation == 1) { child[key[0]][key[1]][key[2]] += value; }
- else if (operation == 2) { child[key[0]][key[1]][key[2]] -= value; }
- else if (operation == 3) { child[key[0]][key[1]][key[2]] *= value; }
- else if (operation == 4) { child[key[0]][key[1]][key[2]] /= value; }
- }
- else if (len == 4)
- {
- if (operation == 0) { child[key[0]][key[1]][key[2]][key[3]] = value; }
- else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; }
- else if (operation == 2) { child[key[0]][key[1]][key[2]][key[3]] -= value; }
- else if (operation == 3) { child[key[0]][key[1]][key[2]][key[3]] *= value; }
- else if (operation == 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; }
- }
- else
- {
- // TODO - Deep property scane
- }
-
- },
-
- /**
- * This function allows you to quickly set the same property across all children of this Group to a new value.
- * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.
- *
- * @method Phaser.Group#setAll
- * @param {string} key - The property, as a string, to be set. For example: 'body.velocity.x'
- * @param {*} value - The value that will be set.
- * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated.
- * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated.
- * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
- */
- setAll: function (key, value, checkAlive, checkVisible, operation) {
-
- key = key.split('.');
-
- if (typeof checkAlive === 'undefined') { checkAlive = false; }
- if (typeof checkVisible === 'undefined') { checkVisible = false; }
-
- operation = operation || 0;
-
- if (this._container.children.length > 0 && this._container.first._iNext)
- {
- var currentNode = this._container.first._iNext;
-
- do
- {
- if ((checkAlive == false || (checkAlive && currentNode.alive)) && (checkVisible == false || (checkVisible && currentNode.visible)))
- {
- this.setProperty(currentNode, key, value, operation);
- }
-
- currentNode = currentNode._iNext;
- }
- while (currentNode != this._container.last._iNext)
- }
-
- },
-
- /**
- * Adds the amount to the given property on all children in this Group.
- * Group.addAll('x', 10) will add 10 to the child.x value.
- *
- * @method Phaser.Group#addAll
- * @param {string} property - The property to increment, for example 'body.velocity.x' or 'angle'.
- * @param {number} amount - The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50.
- * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
- * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
- */
- addAll: function (property, amount, checkAlive, checkVisible) {
-
- this.setAll(property, amount, checkAlive, checkVisible, 1);
-
- },
-
- /**
- * Subtracts the amount from the given property on all children in this Group.
- * Group.subAll('x', 10) will minus 10 from the child.x value.
- *
- * @method Phaser.Group#subAll
- * @param {string} property - The property to decrement, for example 'body.velocity.x' or 'angle'.
- * @param {number} amount - The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10.
- * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
- * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
- */
- subAll: function (property, amount, checkAlive, checkVisible) {
-
- this.setAll(property, amount, checkAlive, checkVisible, 2);
-
- },
-
- /**
- * Multiplies the given property by the amount on all children in this Group.
- * Group.multiplyAll('x', 2) will x2 the child.x value.
- *
- * @method Phaser.Group#multiplyAll
- * @param {string} property - The property to multiply, for example 'body.velocity.x' or 'angle'.
- * @param {number} amount - The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20.
- * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
- * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
- */
- multiplyAll: function (property, amount, checkAlive, checkVisible) {
-
- this.setAll(property, amount, checkAlive, checkVisible, 3);
-
- },
-
- /**
- * Divides the given property by the amount on all children in this Group.
- * Group.divideAll('x', 2) will half the child.x value.
- *
- * @method Phaser.Group#divideAll
- * @param {string} property - The property to divide, for example 'body.velocity.x' or 'angle'.
- * @param {number} amount - The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50.
- * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
- * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
- */
- divideAll: function (property, amount, checkAlive, checkVisible) {
-
- this.setAll(property, amount, checkAlive, checkVisible, 4);
-
- },
-
- /**
- * Calls a function on all of the children that have exists=true in this Group.
- * After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback.
- *
- * @method Phaser.Group#callAllExists
- * @param {function} callback - The function that exists on the children that will be called.
- * @param {boolean} existsValue - Only children with exists=existsValue will be called.
- * @param {...*} parameter - Additional parameters that will be passed to the callback.
- */
- callAllExists: function (callback, existsValue) {
-
- var args = Array.prototype.splice.call(arguments, 2);
-
- if (this._container.children.length > 0 && this._container.first._iNext)
- {
- var currentNode = this._container.first._iNext;
-
- do
- {
- if (currentNode.exists == existsValue && currentNode[callback])
- {
- currentNode[callback].apply(currentNode, args);
- }
-
- currentNode = currentNode._iNext;
- }
- while (currentNode != this._container.last._iNext)
-
- }
-
- },
-
- /**
- * Calls a function on all of the children that have exists=true in this Group.
- *
- * @method Phaser.Group#callbackFromArray
- * @param {object} child - The object to inspect.
- * @param {array} callback - The array of function names.
- * @param {number} length - The size of the array (pre-calculated in callAll).
- * @protected
- */
- callbackFromArray: function (child, callback, length) {
-
- // Kinda looks like a Christmas tree
-
- if (length == 1)
- {
- if (child[callback[0]])
- {
- return child[callback[0]];
- }
- }
- else if (length == 2)
- {
- if (child[callback[0]][callback[1]])
- {
- return child[callback[0]][callback[1]];
- }
- }
- else if (length == 3)
- {
- if (child[callback[0]][callback[1]][callback[2]])
- {
- return child[callback[0]][callback[1]][callback[2]];
- }
- }
- else if (length == 4)
- {
- if (child[callback[0]][callback[1]][callback[2]][callback[3]])
- {
- return child[callback[0]][callback[1]][callback[2]][callback[3]];
- }
- }
- else
- {
- if (child[callback])
- {
- return child[callback];
- }
- }
-
- return false;
-
- },
-
- /**
- * Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that)
- * After the method parameter and context you can add as many extra parameters as you like, which will all be passed to the child.
- *
- * @method Phaser.Group#callAll
- * @param {string} method - A string containing the name of the function that will be called. The function must exist on the child.
- * @param {string} [context=''] - A string containing the context under which the method will be executed. Leave to '' to default to the child.
- * @param {...*} parameter - Additional parameters that will be passed to the method.
- */
- callAll: function (method, context) {
-
- if (typeof method === 'undefined')
- {
- return;
- }
-
- // Extract the method into an array
- method = method.split('.');
-
- var methodLength = method.length;
-
- if (typeof context === 'undefined')
- {
- context = null;
- }
- else
- {
- // Extract the context into an array
- if (typeof context === 'string')
- {
- context = context.split('.');
- var contextLength = context.length;
- }
- }
-
- var args = Array.prototype.splice.call(arguments, 2);
- var callback = null;
-
- if (this._container.children.length > 0 && this._container.first._iNext)
- {
- var child = this._container.first._iNext;
-
- do
- {
- callback = this.callbackFromArray(child, method, methodLength);
-
- if (context && callback)
- {
- callbackContext = this.callbackFromArray(child, context, contextLength);
-
- if (callback)
- {
- callback.apply(callbackContext, args);
- }
- }
- else if (callback)
- {
- callback.apply(child, args);
- }
-
- child = child._iNext;
- }
- while (child != this._container.last._iNext)
-
- }
-
- },
-
- /**
- * Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run.
- * After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child.
- * For example: Group.forEach(awardBonusGold, this, true, 100, 500)
- *
- * @method Phaser.Group#forEach
- * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
- * @param {Object} callbackContext - The context in which the function should be called (usually 'this').
- * @param {boolean} checkExists - If set only children with exists=true will be passed to the callback, otherwise all children will be passed.
- */
- forEach: function (callback, callbackContext, checkExists) {
-
- if (typeof checkExists === 'undefined')
- {
- checkExists = false;
- }
-
- var args = Array.prototype.splice.call(arguments, 3);
- args.unshift(null);
-
- if (this._container.children.length > 0 && this._container.first._iNext)
- {
- var currentNode = this._container.first._iNext;
-
- do
- {
- if (checkExists == false || (checkExists && currentNode.exists))
- {
- args[0] = currentNode;
- callback.apply(callbackContext, args);
- }
-
- currentNode = currentNode._iNext;
- }
- while (currentNode != this._container.last._iNext);
-
- }
-
- },
-
- /**
- * Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run.
- * You can add as many parameters as you like, which will all be passed to the callback along with the child.
- * For example: Group.forEachAlive(causeDamage, this, 500)
- *
- * @method Phaser.Group#forEachAlive
- * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
- * @param {Object} callbackContext - The context in which the function should be called (usually 'this').
- */
- forEachExists: function (callback, callbackContext) {
-
- var args = Array.prototype.splice.call(arguments, 2);
- args.unshift(null);
-
- this.iterate('exists', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args);
-
- },
-
- /**
- * Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run.
- * You can add as many parameters as you like, which will all be passed to the callback along with the child.
- * For example: Group.forEachAlive(causeDamage, this, 500)
- *
- * @method Phaser.Group#forEachAlive
- * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
- * @param {Object} callbackContext - The context in which the function should be called (usually 'this').
- */
- forEachAlive: function (callback, callbackContext) {
-
- var args = Array.prototype.splice.call(arguments, 2);
- args.unshift(null);
-
- this.iterate('alive', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args);
-
- },
-
- /**
- * Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run.
- * You can add as many parameters as you like, which will all be passed to the callback along with the child.
- * For example: Group.forEachDead(bringToLife, this)
- *
- * @method Phaser.Group#forEachDead
- * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
- * @param {Object} callbackContext - The context in which the function should be called (usually 'this').
- */
- forEachDead: function (callback, callbackContext) {
-
- var args = Array.prototype.splice.call(arguments, 2);
- args.unshift(null);
-
- this.iterate('alive', false, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args);
-
- },
-
- /**
- * Call this function to sort the group according to a particular value and order.
- * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`.
- *
- * @method Phaser.Group#sort
- * @param {string} [index='y'] - The `string` name of the property you want to sort on.
- * @param {number} [order=Phaser.Group.SORT_ASCENDING] - The `Group` constant that defines the sort order. Possible values are Phaser.Group.SORT_ASCENDING and Phaser.Group.SORT_DESCENDING.
- */
- sort: function (index, order) {
-
- if (typeof index === 'undefined') { index = 'y'; }
- if (typeof order === 'undefined') { order = Phaser.Group.SORT_ASCENDING; }
-
- var swapped;
- var temp;
-
- do {
-
- swapped = false;
-
- for (var i = 0, len = this._container.children.length - 1; i < len; i++)
- {
- if (order == Phaser.Group.SORT_ASCENDING)
- {
- if (this._container.children[i][index] > this._container.children[i + 1][index])
- {
- this.swap(this.getAt(i), this.getAt(i + 1));
- temp = this._container.children[i];
- this._container.children[i] = this._container.children[i + 1];
- this._container.children[i + 1] = temp;
- swapped = true;
- }
- }
- else
- {
- if (this._container.children[i][index] < this._container.children[i + 1][index])
- {
- this.swap(this.getAt(i), this.getAt(i + 1));
- temp = this._container.children[i];
- this._container.children[i] = this._container.children[i + 1];
- this._container.children[i + 1] = temp;
- swapped = true;
- }
- }
- }
- } while (swapped);
-
- },
-
- /**
- * Iterates over the children of the Group. When a child has a property matching key that equals the given value, it is considered as a match.
- * Matched children can be sent to the optional callback, or simply returned or counted.
- * You can add as many callback parameters as you like, which will all be passed to the callback along with the child, after the callbackContext parameter.
- *
- * @method Phaser.Group#iterate
- * @param {string} key - The child property to check, i.e. 'exists', 'alive', 'health'
- * @param {any} value - If child.key === this value it will be considered a match. Note that a strict comparison is used.
- * @param {number} returnType - How to return the data from this method. Either Phaser.Group.RETURN_NONE, Phaser.Group.RETURN_TOTAL or Phaser.Group.RETURN_CHILD.
- * @param {function} [callback=null] - Optional function that will be called on each matching child. Each child of the Group will be passed to it as its first parameter.
- * @param {Object} [callbackContext] - The context in which the function should be called (usually 'this').
- */
- iterate: function (key, value, returnType, callback, callbackContext, args) {
-
- if (returnType == Phaser.Group.RETURN_TOTAL && this._container.children.length == 0)
- {
- return -1;
- }
-
- if (typeof callback === 'undefined')
- {
- callback = false;
- }
-
- var total = 0;
-
- if (this._container.children.length > 0 && this._container.first._iNext)
- {
- var currentNode = this._container.first._iNext;
-
- do
- {
- if (currentNode[key] === value)
- {
- total++;
-
- if (callback)
- {
- args[0] = currentNode;
- callback.apply(callbackContext, args);
- }
-
- if (returnType == Phaser.Group.RETURN_CHILD)
- {
- return currentNode;
- }
- }
-
- currentNode = currentNode._iNext;
- }
- while (currentNode != this._container.last._iNext);
- }
-
- if (returnType == Phaser.Group.RETURN_TOTAL)
- {
- return total;
- }
- else if (returnType == Phaser.Group.RETURN_CHILD)
- {
- return null;
- }
-
- },
-
- /**
- * Call this function to retrieve the first object with exists == (the given state) in the Group.
- *
- * @method Phaser.Group#getFirstExists
- * @param {boolean} state - True or false.
- * @return {Any} The first child, or null if none found.
- */
- getFirstExists: function (state) {
-
- if (typeof state !== 'boolean')
- {
- state = true;
- }
-
- return this.iterate('exists', state, Phaser.Group.RETURN_CHILD);
-
- },
-
- /**
- * Call this function to retrieve the first object with alive == true in the group.
- * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.
- *
- * @method Phaser.Group#getFirstAlive
- * @return {Any} The first alive child, or null if none found.
- */
- getFirstAlive: function () {
-
- return this.iterate('alive', true, Phaser.Group.RETURN_CHILD);
-
- },
-
- /**
- * Call this function to retrieve the first object with alive == false in the group.
- * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.
- *
- * @method Phaser.Group#getFirstDead
- * @return {Any} The first dead child, or null if none found.
- */
- getFirstDead: function () {
-
- return this.iterate('alive', false, Phaser.Group.RETURN_CHILD);
-
- },
-
- /**
- * Call this function to find out how many members of the group are alive.
- *
- * @method Phaser.Group#countLiving
- * @return {number} The number of children flagged as alive. Returns -1 if Group is empty.
- */
- countLiving: function () {
-
- return this.iterate('alive', true, Phaser.Group.RETURN_TOTAL);
-
- },
-
- /**
- * Call this function to find out how many members of the group are dead.
- *
- * @method Phaser.Group#countDead
- * @return {number} The number of children flagged as dead. Returns -1 if Group is empty.
- */
- countDead: function () {
-
- return this.iterate('alive', false, Phaser.Group.RETURN_TOTAL);
-
- },
-
- /**
- * Returns a member at random from the group.
- *
- * @method Phaser.Group#getRandom
- * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array.
- * @param {number} length - Optional restriction on the number of values you want to randomly select from.
- * @return {Any} A random child of this Group.
- */
- getRandom: function (startIndex, length) {
-
- if (this._container.children.length == 0)
- {
- return null;
- }
-
- startIndex = startIndex || 0;
- length = length || this._container.children.length;
-
- return this.game.math.getRandom(this._container.children, startIndex, length);
-
- },
-
- /**
- * Removes the given child from this Group and sets its group property to null.
- *
- * @method Phaser.Group#remove
- * @param {Any} child - The child to remove.
- */
- remove: function (child) {
-
- if (child.events)
- {
- child.events.onRemovedFromGroup.dispatch(child, this);
- }
-
- this._container.removeChild(child);
-
- if (this.cursor == child)
- {
- if (this._container._iNext)
- {
- this.cursor = this._container._iNext;
- }
- else
- {
- this.cursor = null;
- }
- }
-
- child.group = null;
-
- },
-
- /**
- * Removes all children from this Group, setting all group properties to null.
- * The Group container remains on the display list.
- *
- * @method Phaser.Group#removeAll
- */
- removeAll: function () {
-
- if (this._container.children.length == 0)
- {
- return;
- }
-
- do
- {
- if (this._container.children[0].events)
- {
- this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0], this);
- }
- this._container.removeChild(this._container.children[0]);
- }
- while (this._container.children.length > 0);
-
- this.cursor = null;
-
- },
-
- /**
- * Removes all children from this Group whos index falls beteen the given startIndex and endIndex values.
- *
- * @method Phaser.Group#removeBetween
- * @param {number} startIndex - The index to start removing children from.
- * @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group.
- */
- removeBetween: function (startIndex, endIndex) {
-
- if (this._container.children.length == 0)
- {
- return;
- }
-
- if (startIndex > endIndex || startIndex < 0 || endIndex > this._container.children.length)
- {
- return false;
- }
-
- for (var i = startIndex; i < endIndex; i++)
- {
- var child = this._container.children[i];
- child.events.onRemovedFromGroup.dispatch(child, this);
- this._container.removeChild(child);
-
- if (this.cursor == child)
- {
- if (this._container._iNext)
- {
- this.cursor = this._container._iNext;
- }
- else
- {
- this.cursor = null;
- }
- }
- }
-
- },
-
- /**
- * Destroys this Group. Removes all children, then removes the container from the display list and nulls references.
- *
- * @method Phaser.Group#destroy
- */
- destroy: function () {
-
- this.removeAll();
-
- this._container.parent.removeChild(this._container);
-
- this._container = null;
-
- this.game = null;
-
- this.exists = false;
-
- this.cursor = null;
-
- },
-
- validate: function () {
-
- var testObject = this.game.stage._stage.last._iNext;
- var displayObject = this.game.stage._stage;
- var nextObject = null;
- var prevObject = null;
- var count = 0;
-
- do
- {
- if (count > 0)
- {
- // check next
- if (displayObject !== nextObject)
- {
- console.log('check next fail');
- return false;
- }
-
- // check previous
- if (displayObject._iPrev !== prevObject)
- {
- console.log('check previous fail');
- return false;
- }
- }
-
- // Set the next object
- nextObject = displayObject._iNext;
- prevObject = displayObject;
-
- displayObject = displayObject._iNext;
-
- count++;
-
- }
- while(displayObject != testObject)
-
- return true;
-
- },
-
- /**
- * Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging.
- *
- * @method Phaser.Group#dump
- * @param {boolean} [full=false] - If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container.
- */
- dump: function (full) {
-
- if (typeof full == 'undefined')
- {
- full = false;
- }
-
- var spacing = 20;
- var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing);
-
- console.log(output);
-
- var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing);
- console.log(output);
-
- if (full)
- {
- var testObject = this.game.stage._stage.last._iNext;
- var displayObject = this.game.stage._stage;
- }
- else
- {
- var testObject = this._container.last._iNext;
- var displayObject = this._container;
- }
-
- do
- {
- var name = displayObject.name || '*';
-
- if (this.cursor == displayObject)
- {
- var name = '> ' + name;
- }
-
- var nameNext = '-';
- var namePrev = '-';
- var nameFirst = '-';
- var nameLast = '-';
-
- if (displayObject._iNext)
- {
- nameNext = displayObject._iNext.name;
- }
-
- if (displayObject._iPrev)
- {
- namePrev = displayObject._iPrev.name;
- }
-
- if (displayObject.first)
- {
- nameFirst = displayObject.first.name;
- }
-
- if (displayObject.last)
- {
- nameLast = displayObject.last.name;
- }
-
- if (typeof nameNext === 'undefined')
- {
- nameNext = '-';
- }
-
- if (typeof namePrev === 'undefined')
- {
- namePrev = '-';
- }
-
- if (typeof nameFirst === 'undefined')
- {
- nameFirst = '-';
- }
-
- if (typeof nameLast === 'undefined')
- {
- nameLast = '-';
- }
-
- var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing);
- console.log(output);
-
- displayObject = displayObject._iNext;
-
- }
- while(displayObject != testObject)
-
- }
-
-};
-
-/**
-* @name Phaser.Group#total
-* @property {number} total - The total number of children in this Group, regardless of their alive state.
-* @readonly
-*/
-Object.defineProperty(Phaser.Group.prototype, "total", {
-
- get: function () {
- return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL);
- // return this._container.children.length;
- }
-
-});
-
-/**
-* @name Phaser.Group#length
-* @property {number} length - The number of children in this Group.
-* @readonly
-*/
-Object.defineProperty(Phaser.Group.prototype, "length", {
-
- get: function () {
- return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL);
- // return this._container.children.length;
- }
-
-});
-
-/**
-* The x coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates.
-* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.
-* @name Phaser.Group#x
-* @property {number} x - The x coordinate of the Group container.
-*/
-Object.defineProperty(Phaser.Group.prototype, "x", {
-
- get: function () {
- return this._container.position.x;
- },
-
- set: function (value) {
- this._container.position.x = value;
- }
-
-});
-
-/**
-* The y coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates.
-* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.
-* @name Phaser.Group#y
-* @property {number} y - The y coordinate of the Group container.
-*/
-Object.defineProperty(Phaser.Group.prototype, "y", {
-
- get: function () {
- return this._container.position.y;
- },
-
- set: function (value) {
- this._container.position.y = value;
- }
-
-});
-
-/**
-* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation.
-* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.
-* @name Phaser.Group#angle
-* @property {number} angle - The angle of rotation given in degrees, where 0 degrees = to the right.
-*/
-Object.defineProperty(Phaser.Group.prototype, "angle", {
-
- get: function() {
- return Phaser.Math.radToDeg(this._container.rotation);
- },
-
- set: function(value) {
- this._container.rotation = Phaser.Math.degToRad(value);
- }
-
-});
-
-/**
-* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation.
-* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.
-* @name Phaser.Group#rotation
-* @property {number} rotation - The angle of rotation given in radians.
-*/
-Object.defineProperty(Phaser.Group.prototype, "rotation", {
-
- get: function () {
- return this._container.rotation;
- },
-
- set: function (value) {
- this._container.rotation = value;
- }
-
-});
-
-/**
-* @name Phaser.Group#visible
-* @property {boolean} visible - The visible state of the Group. Non-visible Groups and all of their children are not rendered.
-*/
-Object.defineProperty(Phaser.Group.prototype, "visible", {
-
- get: function () {
- return this._container.visible;
- },
-
- set: function (value) {
- this._container.visible = value;
- }
-
-});
-
-/**
-* @name Phaser.Group#alpha
-* @property {number} alpha - The alpha value of the Group container.
-*/
-Object.defineProperty(Phaser.Group.prototype, "alpha", {
-
- get: function () {
- return this._container.alpha;
- },
-
- set: function (value) {
- this._container.alpha = value;
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* "This world is but a canvas to our imagination." - Henry David Thoreau
-*
-* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
-* by stage limits and can be any size. You look into the world via cameras. All game objects live within
-* the world at world-based coordinates. By default a world is created the same size as your Stage.
-*
-* @class Phaser.World
-* @constructor
-* @param {Phaser.Game} game - Reference to the current game instance.
-*/
-Phaser.World = function (game) {
-
- Phaser.Group.call(this, game, null, '__world', false);
-
- /**
- * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one.
- */
- this.scale = new Phaser.Point(1, 1);
-
- /**
- * The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects.
- * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display.
- * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0.
- * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0.
- * @property {Phaser.Rectangle} bounds - Bound of this world that objects can not escape from.
- */
- this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height);
-
- /**
- * @property {Phaser.Camera} camera - Camera instance.
- */
- this.camera = null;
-
- /**
- * @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated.
- */
- this.currentRenderOrderID = 0;
-
-};
-
-Phaser.World.prototype = Object.create(Phaser.Group.prototype);
-Phaser.World.prototype.constructor = Phaser.World;
-
-/**
-* Initialises the game world.
-*
-* @method Phaser.World#boot
-* @protected
-*/
-Phaser.World.prototype.boot = function () {
-
- this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height);
-
- this.camera.displayObject = this._container;
-
- this.game.camera = this.camera;
-
-}
-
-/**
-* This is called automatically every frame, and is where main logic happens.
-*
-* @method Phaser.World#update
-*/
-Phaser.World.prototype.update = function () {
-
- this.currentRenderOrderID = 0;
-
- if (this.game.stage._stage.first._iNext)
- {
- var currentNode = this.game.stage._stage.first._iNext;
-
- do
- {
- if (currentNode['preUpdate'])
- {
- currentNode.preUpdate();
- }
-
- if (currentNode['update'])
- {
- currentNode.update();
- }
-
- currentNode = currentNode._iNext;
- }
- while (currentNode != this.game.stage._stage.last._iNext)
- }
-
-}
-
-/**
-* This is called automatically every frame, and is where main logic happens.
-* @method Phaser.World#postUpdate
-*/
-Phaser.World.prototype.postUpdate = function () {
-
- this.camera.update();
-
- if (this.game.stage._stage.first._iNext)
- {
- var currentNode = this.game.stage._stage.first._iNext;
-
- do
- {
- if (currentNode['postUpdate'])
- {
- currentNode.postUpdate();
- }
-
- currentNode = currentNode._iNext;
- }
- while (currentNode != this.game.stage._stage.last._iNext)
- }
-
-}
-
-/**
-* Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height.
-* If you need to adjust the bounds of the world
-* @method Phaser.World#setBounds
-* @param {number} x - Top left most corner of the world.
-* @param {number} y - Top left most corner of the world.
-* @param {number} width - New width of the world.
-* @param {number} height - New height of the world.
-*/
-Phaser.World.prototype.setBounds = function (x, y, width, height) {
-
- this.bounds.setTo(x, y, width, height);
-
- if (this.camera.bounds)
- {
- this.camera.bounds.setTo(x, y, width, height);
- }
-
-}
-
-/**
-* Destroyer of worlds.
-* @method Phaser.World#destroy
-*/
-Phaser.World.prototype.destroy = function () {
-
- this.camera.x = 0;
- this.camera.y = 0;
-
- this.game.input.reset(true);
-
- this.removeAll();
-
-}
-
-/**
-* @name Phaser.World#width
-* @property {number} width - Gets or sets the current width of the game world.
-*/
-Object.defineProperty(Phaser.World.prototype, "width", {
-
- get: function () {
- return this.bounds.width;
- },
-
- set: function (value) {
- this.bounds.width = value;
- }
-
-});
-
-/**
-* @name Phaser.World#height
-* @property {number} height - Gets or sets the current height of the game world.
-*/
-Object.defineProperty(Phaser.World.prototype, "height", {
-
- get: function () {
- return this.bounds.height;
- },
-
- set: function (value) {
- this.bounds.height = value;
- }
-
-});
-
-/**
-* @name Phaser.World#centerX
-* @property {number} centerX - Gets the X position corresponding to the center point of the world.
-* @readonly
-*/
-Object.defineProperty(Phaser.World.prototype, "centerX", {
-
- get: function () {
- return this.bounds.halfWidth;
- }
-
-});
-
-/**
-* @name Phaser.World#centerY
-* @property {number} centerY - Gets the Y position corresponding to the center point of the world.
-* @readonly
-*/
-Object.defineProperty(Phaser.World.prototype, "centerY", {
-
- get: function () {
- return this.bounds.halfHeight;
- }
-
-});
-
-/**
-* @name Phaser.World#randomX
-* @property {number} randomX - Gets a random integer which is lesser than or equal to the current width of the game world.
-* @readonly
-*/
-Object.defineProperty(Phaser.World.prototype, "randomX", {
-
- get: function () {
-
- if (this.bounds.x < 0)
- {
- return this.game.rnd.integerInRange(this.bounds.x, (this.bounds.width - Math.abs(this.bounds.x)));
- }
- else
- {
- return this.game.rnd.integerInRange(this.bounds.x, this.bounds.width);
- }
-
- }
-
-});
-
-/**
-* @name Phaser.World#randomY
-* @property {number} randomY - Gets a random integer which is lesser than or equal to the current height of the game world.
-* @readonly
-*/
-Object.defineProperty(Phaser.World.prototype, "randomY", {
-
- get: function () {
-
- if (this.bounds.y < 0)
- {
- return this.game.rnd.integerInRange(this.bounds.y, (this.bounds.height - Math.abs(this.bounds.y)));
- }
- else
- {
- return this.game.rnd.integerInRange(this.bounds.y, this.bounds.height);
- }
-
- }
-
-});
-
-/**
-* @name Phaser.World#visible
-* @property {boolean} visible - Gets or sets the visible state of the World.
-*/
-Object.defineProperty(Phaser.World.prototype, "visible", {
-
- get: function () {
- return this._container.visible;
- },
-
- set: function (value) {
- this._container.visible = value;
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Game constructor
-*
-* Instantiate a new Phaser.Game object.
-* @class Phaser.Game
-* @classdesc This is where the magic happens. The Game object is the heart of your game,
-* providing quick access to common functions and handling the boot process.
-* "Hell, there are no rules here - we're trying to accomplish something."
-* Thomas A. Edison
-* @constructor
-* @param {number} [width=800] - The width of your game in game pixels.
-* @param {number} [height=600] - The height of your game in game pixels.
-* @param {number} [renderer=Phaser.AUTO] - Which renderer to use (canvas or webgl)
-* @param {HTMLElement} [parent=''] - The Games DOM parent.
-* @param {any} [state=null] - Description.
-* @param {boolean} [transparent=false] - Use a transparent canvas background or not.
-* @param {boolean} [antialias=true] - Anti-alias graphics.
-*/
-Phaser.Game = function (width, height, renderer, parent, state, transparent, antialias) {
-
- width = width || 800;
- height = height || 600;
- renderer = renderer || Phaser.AUTO;
- parent = parent || '';
- state = state || null;
-
- if (typeof transparent == 'undefined') { transparent = false; }
- if (typeof antialias == 'undefined') { antialias = true; }
-
- /**
- * @property {number} id - Phaser Game ID (for when Pixi supports multiple instances).
- */
- this.id = Phaser.GAMES.push(this) - 1;
-
- /**
- * @property {HTMLElement} parent - The Games DOM parent.
- */
- this.parent = parent;
-
- // Do some more intelligent size parsing here, so they can set "100%" for example, maybe pass the scale mode in here too?
-
- /**
- * @property {number} width - The Game width (in pixels).
- */
- this.width = width;
-
- /**
- * @property {number} height - The Game height (in pixels).
- */
- this.height = height;
-
- /**
- * @property {boolean} transparent - Use a transparent canvas background or not.
- */
- this.transparent = transparent;
-
- /**
- * @property {boolean} antialias - Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality).
- */
- this.antialias = antialias;
-
- /**
- * @property {number} renderer - The Pixi Renderer
- * @default
- */
- this.renderer = null;
-
- /**
- * @property {number} state - The StateManager.
- */
- this.state = new Phaser.StateManager(this, state);
-
- /**
- * @property {boolean} _paused - Is game paused?
- * @private
- * @default
- */
- this._paused = false;
-
- /**
- * @property {number} renderType - The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL.
- */
- this.renderType = renderer;
-
- /**
- * @property {boolean} _loadComplete - Whether load complete loading or not.
- * @private
- * @default
- */
- this._loadComplete = false;
-
- /**
- * @property {boolean} isBooted - Whether the game engine is booted, aka available.
- * @default
- */
- this.isBooted = false;
-
- /**
- * @property {boolean} id -Is game running or paused?
- * @default
- */
- this.isRunning = false;
-
- /**
- * @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout
- * @default
- */
- this.raf = null;
-
- /**
- * @property {Phaser.GameObjectFactory} add - Reference to the GameObject Factory.
- * @default
- */
- this.add = null;
-
- /**
- * @property {Phaser.Cache} cache - Reference to the assets cache.
- * @default
- */
- this.cache = null;
-
- /**
- * @property {Phaser.Input} input - Reference to the input manager
- * @default
- */
- this.input = null;
-
- /**
- * @property {Phaser.Loader} load - Reference to the assets loader.
- * @default
- */
- this.load = null;
-
- /**
- * @property {Phaser.GameMath} math - Reference to the math helper.
- * @default
- */
- this.math = null;
-
- /**
- * @property {Phaser.Net} net - Reference to the network class.
- * @default
- */
- this.net = null;
-
- /**
- * @property {Phaser.SoundManager} sound - Reference to the sound manager.
- * @default
- */
- this.sound = null;
-
- /**
- * @property {Phaser.Stage} stage - Reference to the stage.
- * @default
- */
- this.stage = null;
-
- /**
- * @property {Phaser.TimeManager} time - Reference to game clock.
- * @default
- */
- this.time = null;
-
- /**
- * @property {Phaser.TweenManager} tweens - Reference to the tween manager.
- * @default
- */
- this.tweens = null;
-
- /**
- * @property {Phaser.World} world - Reference to the world.
- * @default
- */
- this.world = null;
-
- /**
- * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager.
- * @default
- */
- this.physics = null;
-
- /**
- * @property {Phaser.RandomDataGenerator} rnd - Instance of repeatable random data generator helper.
- * @default
- */
- this.rnd = null;
-
- /**
- * @property {Phaser.Device} device - Contains device information and capabilities.
- * @default
- */
- this.device = null;
-
- /**
- * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera.
- * @default
- */
- this.camera = null;
-
- /**
- * @property {HTMLCanvasElement} canvas - A handy reference to renderer.view.
- * @default
- */
- this.canvas = null;
-
- /**
- * @property {Context} context - A handy reference to renderer.context (only set for CANVAS games)
- * @default
- */
- this.context = null;
-
- /**
- * @property {Phaser.Utils.Debug} debug - A set of useful debug utilitie.
- * @default
- */
- this.debug = null;
-
- /**
- * @property {Phaser.Particles} particles - The Particle Manager.
- * @default
- */
- this.particles = null;
-
- var _this = this;
-
- this._onBoot = function () {
- return _this.boot();
- }
-
- if (document.readyState === 'complete' || document.readyState === 'interactive')
- {
- window.setTimeout(this._onBoot, 0);
- }
- else
- {
- document.addEventListener('DOMContentLoaded', this._onBoot, false);
- window.addEventListener('load', this._onBoot, false);
- }
-
- return this;
-
-};
-
-Phaser.Game.prototype = {
-
- /**
- * Initialize engine sub modules and start the game.
- *
- * @method Phaser.Game#boot
- * @protected
- */
- boot: function () {
-
- if (this.isBooted)
- {
- return;
- }
-
- if (!document.body)
- {
- window.setTimeout(this._onBoot, 20);
- }
- else
- {
- document.removeEventListener('DOMContentLoaded', this._onBoot);
- window.removeEventListener('load', this._onBoot);
-
- this.onPause = new Phaser.Signal;
- this.onResume = new Phaser.Signal;
-
- this.isBooted = true;
-
- this.device = new Phaser.Device();
- this.math = Phaser.Math;
- this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]);
-
- this.stage = new Phaser.Stage(this, this.width, this.height);
-
- this.setUpRenderer();
-
- this.world = new Phaser.World(this);
- this.add = new Phaser.GameObjectFactory(this);
- this.cache = new Phaser.Cache(this);
- this.load = new Phaser.Loader(this);
- this.time = new Phaser.Time(this);
- this.tweens = new Phaser.TweenManager(this);
- this.input = new Phaser.Input(this);
- this.sound = new Phaser.SoundManager(this);
- this.physics = new Phaser.Physics.Arcade(this);
- this.particles = new Phaser.Particles(this);
- this.plugins = new Phaser.PluginManager(this, this);
- this.net = new Phaser.Net(this);
- this.debug = new Phaser.Utils.Debug(this);
-
- this.stage.boot();
- this.world.boot();
- this.input.boot();
- this.sound.boot();
- this.state.boot();
-
- this.load.onLoadComplete.add(this.loadComplete, this);
-
- this.showDebugHeader();
-
- this.isRunning = true;
- this._loadComplete = false;
-
- this.raf = new Phaser.RequestAnimationFrame(this);
- this.raf.start();
-
- }
-
- },
-
- /**
- * Displays a Phaser version debug header in the console.
- *
- * @method Phaser.Game#showDebugHeader
- * @protected
- */
- showDebugHeader: function () {
-
- var v = Phaser.DEV_VERSION;
- var r = 'Canvas';
- var a = 'HTML Audio';
-
- if (this.renderType == Phaser.WEBGL)
- {
- r = 'WebGL';
- }
-
- if (this.device.webAudio)
- {
- a = 'WebAudio';
- }
-
- if (this.device.chrome)
- {
- var args = [
- '%c %c %c Phaser v' + v + ' - Renderer: ' + r + ' - Audio: ' + a + ' %c %c ',
- 'background: #00bff3',
- 'background: #0072bc',
- 'color: #ffffff; background: #003471',
- 'background: #0072bc',
- 'background: #00bff3'
- ];
-
- console.log.apply(console, args);
- }
- else
- {
- console.log('Phaser v' + v + ' - Renderer: ' + r + ' - Audio: ' + a);
- }
-
- },
-
- /**
- * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not.
- *
- * @method Phaser.Game#setUpRenderer
- * @protected
- */
- setUpRenderer: function () {
-
- if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL == false))
- {
- if (this.device.canvas)
- {
- this.renderType = Phaser.CANVAS;
- this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.stage.canvas, this.transparent);
- Phaser.Canvas.setSmoothingEnabled(this.renderer.context, this.antialias);
- this.canvas = this.renderer.view;
- this.context = this.renderer.context;
- }
- else
- {
- throw new Error('Phaser.Game - cannot create Canvas or WebGL context, aborting.');
- }
- }
- else
- {
- // They requested WebGL, and their browser supports it
- this.renderType = Phaser.WEBGL;
- this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.stage.canvas, this.transparent, this.antialias);
- this.canvas = this.renderer.view;
- this.context = null;
- }
-
- Phaser.Canvas.addToDOM(this.renderer.view, this.parent, true);
- Phaser.Canvas.setTouchAction(this.renderer.view);
-
- },
-
- /**
- * Called when the load has finished, after preload was run.
- *
- * @method Phaser.Game#loadComplete
- * @protected
- */
- loadComplete: function () {
-
- this._loadComplete = true;
-
- this.state.loadComplete();
-
- },
-
- /**
- * The core game loop.
- *
- * @method Phaser.Game#update
- * @protected
- * @param {number} time - The current time as provided by RequestAnimationFrame.
- */
- update: function (time) {
-
- this.time.update(time);
-
- if (this._paused)
- {
- this.renderer.render(this.stage._stage);
- this.plugins.render();
- this.state.render();
- }
- else
- {
- this.plugins.preUpdate();
- this.physics.preUpdate();
-
- this.stage.update();
- this.input.update();
- this.tweens.update();
- this.sound.update();
- this.world.update();
- this.particles.update();
- this.state.update();
- this.plugins.update();
-
- this.world.postUpdate();
- this.plugins.postUpdate();
-
- this.renderer.render(this.stage._stage);
- this.plugins.render();
- this.state.render();
-
- this.plugins.postRender();
- }
-
- },
-
- /**
- * Nuke the entire game from orbit
- *
- * @method Phaser.Game#destroy
- */
- destroy: function () {
-
- this.raf.stop();
-
- this.input.destroy();
-
- this.state.destroy();
-
- this.state = null;
- this.cache = null;
- this.input = null;
- this.load = null;
- this.sound = null;
- this.stage = null;
- this.time = null;
- this.world = null;
- this.isBooted = false;
-
- }
-
-};
-
-/**
-* The paused state of the Game. A paused game doesn't update any of its subsystems.
-* When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched.
-* @name Phaser.Game#paused
-* @property {boolean} paused - Gets and sets the paused state of the Game.
-*/
-Object.defineProperty(Phaser.Game.prototype, "paused", {
-
- get: function () {
- return this._paused;
- },
-
- set: function (value) {
-
- if (value === true)
- {
- if (this._paused == false)
- {
- this._paused = true;
- this.onPause.dispatch(this);
- }
- }
- else
- {
- if (this._paused)
- {
- this._paused = false;
- this.onResume.dispatch(this);
- }
- }
-
- }
-
-});
-
-/**
-* "Deleted code is debugged code." - Jeff Sickel
-*/
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Constructor for Phaser Input.
-* @class Phaser.Input
-* @classdesc A game specific Input manager that looks after the mouse, keyboard and touch objects.
-* This is updated by the core game loop.
-* @constructor
-* @param {Phaser.Game} game - Current game instance.
-*/
-Phaser.Input = function (game) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = game;
-
- /**
- * @property {Description} hitCanvas - Description.
- * @default
- */
- this.hitCanvas = null;
-
- /**
- * @property {Description} hitContext - Description.
- * @default
- */
- this.hitContext = null;
-
-};
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Input.MOUSE_OVERRIDES_TOUCH = 0;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Input.TOUCH_OVERRIDES_MOUSE = 1;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Input.MOUSE_TOUCH_COMBINE = 2;
-
-Phaser.Input.prototype = {
-
- /**
- * @property {Phaser.Game} game
- */
- game: null,
-
- /**
- * How often should the input pointers be checked for updates?
- * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.
- * @property {number} pollRate
- * @default
- */
- pollRate: 0,
-
- /**
- * @property {number} _pollCounter - Description.
- * @private
- * @default
- */
- _pollCounter: 0,
-
- /**
- * A vector object representing the previous position of the Pointer.
- * @property {Vec2} vector
- * @private
- * @default
- */
- _oldPosition: null,
-
- /**
- * X coordinate of the most recent Pointer event
- * @property {number} _x
- * @private
- * @default
- */
- _x: 0,
-
- /**
- * Y coordinate of the most recent Pointer event
- * @property {number} _y
- * @private
- * @default
- */
- _y: 0,
-
- /**
- * You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored.
- * If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead
- * @property {boolean} disabled
- * @default
- */
- disabled: false,
-
- /**
- * Controls the expected behaviour when using a mouse and touch together on a multi-input device.
- * @property {Description} multiInputOverride
- */
- multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE,
-
- /**
- * A vector object representing the current position of the Pointer.
- * @property {Phaser.Point} position
- * @default
- */
- position: null,
-
- /**
- * A vector object representing the speed of the Pointer. Only really useful in single Pointer games,
- * otherwise see the Pointer objects directly.
- * @property {Phaser.Point} speed
- * @default
- */
- speed: null,
-
- /**
- * A Circle object centered on the x/y screen coordinates of the Input.
- * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything.
- * @property {Phaser.Circle} circle
- * @default
- */
- circle: null,
-
- /**
- * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode.
- * In an un-scaled game the values will be x: 1 and y: 1.
- * @property {Phaser.Point} scale
- * @default
- */
- scale: null,
-
- /**
- * The maximum number of Pointers allowed to be active at any one time.
- * For lots of games it's useful to set this to 1.
- * @property {number} maxPointers
- * @default
- */
- maxPointers: 10,
-
- /**
- * The current number of active Pointers.
- * @property {number} currentPointers
- * @default
- */
- currentPointers: 0,
-
- /**
- * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke
- * @property {number} tapRate
- * @default
- */
- tapRate: 200,
-
- /**
- * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click
- * @property {number} doubleTapRate
- * @default
- */
- doubleTapRate: 300,
-
- /**
- * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
- * @property {number} holdRate
- * @default
- */
- holdRate: 2000,
-
- /**
- * The number of milliseconds below which the Pointer is considered justPressed
- * @property {number} justPressedRate
- * @default
- */
- justPressedRate: 200,
-
- /**
- * The number of milliseconds below which the Pointer is considered justReleased
- * @property {number} justReleasedRate
- * @default
- */
- justReleasedRate: 200,
-
- /**
- * Sets if the Pointer objects should record a history of x/y coordinates they have passed through.
- * The history is cleared each time the Pointer is pressed down.
- * The history is updated at the rate specified in Input.pollRate
- * @property {boolean} recordPointerHistory
- * @default
- */
- recordPointerHistory: false,
-
- /**
- * The rate in milliseconds at which the Pointer objects should update their tracking history
- * @property {number} recordRate
- * @default
- */
- recordRate: 100,
-
- /**
- * The total number of entries that can be recorded into the Pointer objects tracking history.
- * If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.
- * @property {number} recordLimit
- * @default
- */
- recordLimit: 100,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer1
- */
- pointer1: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer2
- */
- pointer2: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer3
- */
- pointer3: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer4
- */
- pointer4: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer5
- */
- pointer5: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer6
- */
- pointer6: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer7
- */
- pointer7: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer8
- */
- pointer8: null,
-
- /**
- * A Pointer object
- * @property {Phaser.Pointer} pointer9
- */
- pointer9: null,
-
- /**
- * A Pointer object.
- * @property {Phaser.Pointer} pointer10
- */
- pointer10: null,
-
- /**
- * The most recently active Pointer object.
- * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.
- * @property {Phaser.Pointer} activePointer
- * @default
- */
- activePointer: null,
-
- /**
- * The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game.
- * @property {Pointer} mousePointer
- * @default
- */
- mousePointer: null,
-
- /**
- * The Mouse Input manager.
- * @property {Phaser.Mouse} mouse - The Mouse Input manager.
- * @default
- */
- mouse: null,
-
- /**
- * The Keyboard Input manager.
- * @property {Phaser.Keyboard} keyboard - The Keyboard Input manager.
- * @default
- */
- keyboard: null,
-
- /**
- * The Touch Input manager.
- * @property {Phaser.Touch} touch - the Touch Input manager.
- * @default
- */
- touch: null,
-
- /**
- * The MSPointer Input manager.
- * @property {Phaser.MSPointer} mspointer - The MSPointer Input manager.
- * @default
- */
- mspointer: null,
-
- /**
- * A Signal that is dispatched each time a pointer is pressed down.
- * @property {Phaser.Signal} onDown
- * @default
- */
- onDown: null,
-
- /**
- * A Signal that is dispatched each time a pointer is released.
- * @property {Phaser.Signal} onUp
- * @default
- */
- onUp: null,
-
- /**
- * A Signal that is dispatched each time a pointer is tapped.
- * @property {Phaser.Signal} onTap
- * @default
- */
- onTap: null,
-
- /**
- * A Signal that is dispatched each time a pointer is held down.
- * @property {Phaser.Signal} onHold
- * @default
- */
- onHold: null,
-
- /**
- * A linked list of interactive objects, the InputHandler components (belonging to Sprites) register themselves with this.
- * @property {Phaser.LinkedList} interactiveItems
- */
- interactiveItems: new Phaser.LinkedList(),
-
- /**
- * Starts the Input Manager running.
- * @method Phaser.Input#boot
- * @protected
- */
- boot: function () {
-
- this.mousePointer = new Phaser.Pointer(this.game, 0);
- this.pointer1 = new Phaser.Pointer(this.game, 1);
- this.pointer2 = new Phaser.Pointer(this.game, 2);
-
- this.mouse = new Phaser.Mouse(this.game);
- this.keyboard = new Phaser.Keyboard(this.game);
- this.touch = new Phaser.Touch(this.game);
- this.mspointer = new Phaser.MSPointer(this.game);
-
- this.onDown = new Phaser.Signal();
- this.onUp = new Phaser.Signal();
- this.onTap = new Phaser.Signal();
- this.onHold = new Phaser.Signal();
-
- this.scale = new Phaser.Point(1, 1);
- this.speed = new Phaser.Point();
- this.position = new Phaser.Point();
- this._oldPosition = new Phaser.Point();
-
- this.circle = new Phaser.Circle(0, 0, 44);
-
- this.activePointer = this.mousePointer;
- this.currentPointers = 0;
-
- this.hitCanvas = document.createElement('canvas');
- this.hitCanvas.width = 1;
- this.hitCanvas.height = 1;
- this.hitContext = this.hitCanvas.getContext('2d');
-
- this.mouse.start();
- this.keyboard.start();
- this.touch.start();
- this.mspointer.start();
- this.mousePointer.active = true;
-
- },
-
- /**
- * Stops all of the Input Managers from running.
- * @method Phaser.Input#destroy
- */
- destroy: function () {
-
- this.mouse.stop();
- this.keyboard.stop();
- this.touch.stop();
- this.mspointer.stop();
-
- },
-
- /**
- * Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2.
- * If you need more then use this to create a new one, up to a maximum of 10.
- * @method Phaser.Input#addPointer
- * @return {Phaser.Pointer} A reference to the new Pointer object that was created.
- */
- addPointer: function () {
-
- var next = 0;
-
- for (var i = 10; i > 0; i--)
- {
- if (this['pointer' + i] === null)
- {
- next = i;
- }
- }
-
- if (next == 0)
- {
- console.warn("You can only have 10 Pointer objects");
- return null;
- }
- else
- {
- this['pointer' + next] = new Phaser.Pointer(this.game, next);
- return this['pointer' + next];
- }
-
- },
-
- /**
- * Updates the Input Manager. Called by the core Game loop.
- * @method Phaser.Input#update
- * @protected
- */
- update: function () {
-
- if (this.pollRate > 0 && this._pollCounter < this.pollRate)
- {
- this._pollCounter++;
- return;
- }
-
- this.speed.x = this.position.x - this._oldPosition.x;
- this.speed.y = this.position.y - this._oldPosition.y;
-
- this._oldPosition.copyFrom(this.position);
- this.mousePointer.update();
-
- this.pointer1.update();
- this.pointer2.update();
-
- if (this.pointer3) { this.pointer3.update(); }
- if (this.pointer4) { this.pointer4.update(); }
- if (this.pointer5) { this.pointer5.update(); }
- if (this.pointer6) { this.pointer6.update(); }
- if (this.pointer7) { this.pointer7.update(); }
- if (this.pointer8) { this.pointer8.update(); }
- if (this.pointer9) { this.pointer9.update(); }
- if (this.pointer10) { this.pointer10.update(); }
-
- this._pollCounter = 0;
- },
-
- /**
- * Reset all of the Pointers and Input states
- * @method Phaser.Input#reset
- * @param {boolean} hard - A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will.
- */
- reset: function (hard) {
-
- if (this.game.isBooted == false)
- {
- return;
- }
-
- if (typeof hard == 'undefined') { hard = false; }
-
- this.keyboard.reset();
- this.mousePointer.reset();
-
- for (var i = 1; i <= 10; i++)
- {
- if (this['pointer' + i])
- {
- this['pointer' + i].reset();
- }
- }
-
- this.currentPointers = 0;
- this.game.stage.canvas.style.cursor = "default";
-
- if (hard == true)
- {
- this.onDown.dispose();
- this.onUp.dispose();
- this.onTap.dispose();
- this.onHold.dispose();
- this.onDown = new Phaser.Signal();
- this.onUp = new Phaser.Signal();
- this.onTap = new Phaser.Signal();
- this.onHold = new Phaser.Signal();
-
- this.interactiveItems.callAll('reset');
- }
-
- this._pollCounter = 0;
-
- },
-
- /**
- * Resets the speed and old position properties.
- * @method Phaser.Input#resetSpeed
- * @param {number} x - Sets the oldPosition.x value.
- * @param {number} y - Sets the oldPosition.y value.
- */
- resetSpeed: function (x, y) {
-
- this._oldPosition.setTo(x, y);
- this.speed.setTo(0, 0);
-
- },
-
- /**
- * Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer.
- * @method Phaser.Input#startPointer
- * @param {Any} event - The event data from the Touch event.
- * @return {Phaser.Pointer} The Pointer object that was started or null if no Pointer object is available.
- */
- startPointer: function (event) {
-
- if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers)
- {
- return null;
- }
-
- if (this.pointer1.active == false)
- {
- return this.pointer1.start(event);
- }
- else if (this.pointer2.active == false)
- {
- return this.pointer2.start(event);
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active == false)
- {
- return this['pointer' + i].start(event);
- }
- }
- }
-
- return null;
-
- },
-
- /**
- * Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked.
- * @method Phaser.Input#updatePointer
- * @param {Any} event - The event data from the Touch event.
- * @return {Phaser.Pointer} The Pointer object that was updated or null if no Pointer object is available.
- */
- updatePointer: function (event) {
-
- if (this.pointer1.active && this.pointer1.identifier == event.identifier)
- {
- return this.pointer1.move(event);
- }
- else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
- {
- return this.pointer2.move(event);
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
- {
- return this['pointer' + i].move(event);
- }
- }
- }
-
- return null;
-
- },
-
- /**
- * Stops the matching Pointer object, passing in the event data.
- * @method Phaser.Input#stopPointer
- * @param {Any} event - The event data from the Touch event.
- * @return {Phaser.Pointer} The Pointer object that was stopped or null if no Pointer object is available.
- */
- stopPointer: function (event) {
-
- if (this.pointer1.active && this.pointer1.identifier == event.identifier)
- {
- return this.pointer1.stop(event);
- }
- else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
- {
- return this.pointer2.stop(event);
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
- {
- return this['pointer' + i].stop(event);
- }
- }
- }
-
- return null;
-
- },
-
- /**
- * Get the next Pointer object whos active property matches the given state
- * @method Phaser.Input#getPointer
- * @param {boolean} state - The state the Pointer should be in (false for inactive, true for active).
- * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested state.
- */
- getPointer: function (state) {
-
- state = state || false;
-
- if (this.pointer1.active == state)
- {
- return this.pointer1;
- }
- else if (this.pointer2.active == state)
- {
- return this.pointer2;
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active == state)
- {
- return this['pointer' + i];
- }
- }
- }
-
- return null;
-
- },
-
- /**
- * Get the Pointer object whos identified property matches the given identifier value.
- * @method Phaser.Input#getPointerFromIdentifier
- * @param {number} identifier - The Pointer.identifier value to search for.
- * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
- */
- getPointerFromIdentifier: function (identifier) {
-
- if (this.pointer1.identifier == identifier)
- {
- return this.pointer1;
- }
- else if (this.pointer2.identifier == identifier)
- {
- return this.pointer2;
- }
- else
- {
- for (var i = 3; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].identifier == identifier)
- {
- return this['pointer' + i];
- }
- }
- }
-
- return null;
-
- }
-
-};
-
-/**
-* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
-* @name Phaser.Input#x
-* @property {number} x - The X coordinate of the most recently active pointer.
-*/
-Object.defineProperty(Phaser.Input.prototype, "x", {
-
- get: function () {
- return this._x;
- },
-
- set: function (value) {
- this._x = Math.floor(value);
- }
-
-});
-
-/**
-* The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.
-* @name Phaser.Input#y
-* @property {number} y - The Y coordinate of the most recently active pointer.
-*/
-Object.defineProperty(Phaser.Input.prototype, "y", {
-
- get: function () {
- return this._y;
- },
-
- set: function (value) {
- this._y = Math.floor(value);
- }
-
-});
-
-/**
-* @name Phaser.Input#pollLocked
-* @property {boolean} pollLocked - True if the Input is currently poll rate locked.
-* @readonly
-*/
-Object.defineProperty(Phaser.Input.prototype, "pollLocked", {
-
- get: function () {
- return (this.pollRate > 0 && this._pollCounter < this.pollRate);
- }
-
-});
-
-/**
-* The total number of inactive Pointers
-* @name Phaser.Input#totalInactivePointers
-* @property {number} totalInactivePointers - The total number of inactive Pointers.
-* @readonly
-*/
-Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
-
- get: function () {
- return 10 - this.currentPointers;
- }
-
-});
-
-/**
-* The total number of active Pointers
-* @name Phaser.Input#totalActivePointers
-* @property {number} totalActivePointers - The total number of active Pointers.
-* @readonly
-*/
-Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
-
- get: function () {
-
- this.currentPointers = 0;
-
- for (var i = 1; i <= 10; i++)
- {
- if (this['pointer' + i] && this['pointer' + i].active)
- {
- this.currentPointers++;
- }
- }
-
- return this.currentPointers;
-
- }
-
-});
-
-/**
-* The world X coordinate of the most recently active pointer.
-* @name Phaser.Input#worldX
-* @property {number} worldX - The world X coordinate of the most recently active pointer.
-*/
-Object.defineProperty(Phaser.Input.prototype, "worldX", {
-
- get: function () {
- return this.game.camera.view.x + this.x;
- }
-
-});
-
-/**
-* The world Y coordinate of the most recently active pointer.
-* @name Phaser.Input#worldY
-* @property {number} worldY - The world Y coordinate of the most recently active pointer.
-*/
-Object.defineProperty(Phaser.Input.prototype, "worldY", {
-
- get: function () {
- return this.game.camera.view.y + this.y;
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* @class Phaser.Key
-* @classdesc If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects.
-* @constructor
-* @param {Phaser.Game} game - Current game instance.
-* @param {number} keycode - The key code this Key is responsible for.
-*/
-Phaser.Key = function (game, keycode) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = game;
-
- /**
- * @property {boolean} isDown - The "down" state of the key.
- * @default
- */
- this.isDown = false;
-
- /**
- * @property {boolean} isUp - The "up" state of the key.
- * @default
- */
- this.isUp = false;
-
- /**
- * @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key.
- * @default
- */
- this.altKey = false;
-
- /**
- * @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key.
- * @default
- */
- this.ctrlKey = false;
-
- /**
- * @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key.
- * @default
- */
- this.shiftKey = false;
-
- /**
- * @property {number} timeDown - The timestamp when the key was last pressed down.
- * @default
- */
- this.timeDown = 0;
-
- /**
- * If the key is down this value holds the duration of that key press and is constantly updated.
- * If the key is up it holds the duration of the previous down session.
- * @property {number} duration - The number of milliseconds this key has been held down for.
- * @default
- */
- this.duration = 0;
-
- /**
- * @property {number} timeUp - The timestamp when the key was last released.
- * @default
- */
- this.timeUp = 0;
-
- /**
- * @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'.
- * @default
- */
- this.repeats = 0;
-
- /**
- * @property {number} keyCode - The keycode of this key.
- */
- this.keyCode = keycode;
-
- /**
- * @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).
- */
- this.onDown = new Phaser.Signal();
-
- /**
- * @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).
- */
- this.onUp = new Phaser.Signal();
-
-};
-
-Phaser.Key.prototype = {
-
- /**
- * Called automatically by Phaser.Keyboard.
- * @method Phaser.Key#processKeyDown
- * @param {KeyboardEvent} event.
- * @protected
- */
- processKeyDown: function (event) {
-
- this.altKey = event.altKey;
- this.ctrlKey = event.ctrlKey;
- this.shiftKey = event.shiftKey;
-
- if (this.isDown)
- {
- // Key was already held down, this must be a repeat rate based event
- this.duration = event.timeStamp - this.timeDown;
- this.repeats++;
- }
- else
- {
- this.isDown = true;
- this.isUp = false;
- this.timeDown = event.timeStamp;
- this.duration = 0;
- this.repeats = 0;
-
- this.onDown.dispatch(this);
- }
-
- },
-
- /**
- * Called automatically by Phaser.Keyboard.
- * @method Phaser.Key#processKeyUp
- * @param {KeyboardEvent} event.
- * @protected
- */
- processKeyUp: function (event) {
-
- this.isDown = false;
- this.isUp = true;
- this.timeUp = event.timeStamp;
-
- this.onUp.dispatch(this);
-
- },
-
- /**
- * Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)
- * @method Phaser.Key#justPressed
- * @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
- * @return {boolean} True if the key is just pressed otherwise false.
- */
- justPressed: function (duration) {
-
- if (typeof duration === "undefined") { duration = 250; }
-
- return (this.isDown && this.duration < duration);
-
- },
-
- /**
- * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)
- * @method Phaser.Key#justPressed
- * @param {number} [duration=250] - The duration below which the key is considered as being just released.
- * @return {boolean} True if the key is just released otherwise false.
- */
- justReleased: function (duration) {
-
- if (typeof duration === "undefined") { duration = 250; }
-
- return (this.isDown == false && (this.game.time.now - this.timeUp < duration));
-
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser - Keyboard constructor.
-*
-* @class Phaser.Keyboard
-* @classdesc A Keyboard object Description.
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-*/
-Phaser.Keyboard = function (game) {
-
- /**
- * @property {Phaser.Game} game - Local reference to game.
- */
- this.game = game;
-
- /**
- * @property {Description} _keys - Description.
- * @private
- */
- this._keys = {};
-
- /**
- * @property {Description} _hotkeys - Description.
- * @private
- */
- this._hotkeys = {};
-
- /**
- * @property {Description} _capture - Description.
- * @private
- */
- this._capture = {};
-
- /**
- * You can disable all Keyboard Input by setting disabled to true. While true all new input related events will be ignored.
- * @property {boolean} disabled - The disabled state of the Keyboard.
- * @default
- */
- this.disabled = false;
-
- /**
- * @property {function} _onKeyDown
- * @private
- * @default
- */
- this._onKeyDown = null;
-
- /**
- * @property {function} _onKeyUp
- * @private
- * @default
- */
- this._onKeyUp = null;
-
- /**
- * @property {Object} callbackContext - The context under which the callbacks are run.
- */
- this.callbackContext = this;
-
- /**
- * @property {function} onDownCallback - This callback is invoked every time a key is pressed down.
- */
- this.onDownCallback = null;
-
- /**
- * @property {function} onUpCallback - This callback is invoked every time a key is released.
- */
- this.onUpCallback = null;
-
-};
-
-Phaser.Keyboard.prototype = {
-
- /**
- * Add callbacks to the Keyboard handler so that each time a key is pressed down or releases the callbacks are activated.
- * @method Phaser.Keyboard#addCallbacks
- * @param {Object} context - The context under which the callbacks are run.
- * @param {function} onDown - This callback is invoked every time a key is pressed down.
- * @param {function} [onUp=null] - This callback is invoked every time a key is released.
- */
- addCallbacks: function (context, onDown, onUp) {
-
- this.callbackContext = context;
- this.onDownCallback = onDown;
-
- if (typeof onUp !== 'undefined')
- {
- this.onUpCallback = onUp;
- }
-
- },
-
- /**
- * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method.
- * The Key object can then be polled, have events attached to it, etc.
- *
- * @method Phaser.Keyboard#addKey
- * @param {number} keycode - The keycode of the key, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
- * @return {Phaser.Key} The Key object which you can store locally and reference directly.
- */
- addKey: function (keycode) {
-
- this._hotkeys[keycode] = new Phaser.Key(this.game, keycode);
-
- this.addKeyCapture(keycode);
-
- return this._hotkeys[keycode];
-
- },
-
- /**
- * Removes a Key object from the Keyboard manager.
- *
- * @method Phaser.Keyboard#removeKey
- * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
- */
- removeKey: function (keycode) {
-
- delete (this._hotkeys[keycode]);
-
- },
-
- /**
- * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right.
- *
- * @method Phaser.Keyboard#createCursorKeys
- * @return {object} An object containing properties: up, down, left and right. Which can be polled like any other Phaser.Key object.
- */
- createCursorKeys: function () {
-
- return {
- up: this.addKey(Phaser.Keyboard.UP),
- down: this.addKey(Phaser.Keyboard.DOWN),
- left: this.addKey(Phaser.Keyboard.LEFT),
- right: this.addKey(Phaser.Keyboard.RIGHT)
- }
-
- },
-
- /**
- * Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body.
- * This is called automatically by Phaser.Input and should not normally be invoked directly.
- *
- * @method Phaser.Keyboard#start
- */
- start: function () {
-
- var _this = this;
-
- this._onKeyDown = function (event) {
- return _this.processKeyDown(event);
- };
-
- this._onKeyUp = function (event) {
- return _this.processKeyUp(event);
- };
-
- document.body.addEventListener('keydown', this._onKeyDown, false);
- document.body.addEventListener('keyup', this._onKeyUp, false);
-
- },
-
- /**
- * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the document.body.
- *
- * @method Phaser.Keyboard#stop
- */
- stop: function () {
-
- document.body.removeEventListener('keydown', this._onKeyDown);
- document.body.removeEventListener('keyup', this._onKeyUp);
-
- },
-
- /**
- * By default when a key is pressed Phaser will not stop the event from propagating up to the browser.
- * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll.
- * You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser.
- * Pass in either a single keycode or an array/hash of keycodes.
- * @method Phaser.Keyboard#addKeyCapture
- * @param {Any} keycode
- */
- addKeyCapture: function (keycode) {
-
- if (typeof keycode === 'object')
- {
- for (var key in keycode)
- {
- this._capture[keycode[key]] = true;
- }
- }
- else
- {
- this._capture[keycode] = true;
- }
- },
-
- /**
- * Removes an existing key capture.
- * @method Phaser.Keyboard#removeKeyCapture
- * @param {number} keycode
- */
- removeKeyCapture: function (keycode) {
-
- delete this._capture[keycode];
-
- },
-
- /**
- * Clear all set key captures.
- * @method Phaser.Keyboard#clearCaptures
- */
- clearCaptures: function () {
-
- this._capture = {};
-
- },
-
- /**
- * Process the keydown event.
- * @method Phaser.Keyboard#processKeyDown
- * @param {KeyboardEvent} event
- * @protected
- */
- processKeyDown: function (event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- if (this._capture[event.keyCode])
- {
- event.preventDefault();
- }
-
- if (this.onDownCallback)
- {
- this.onDownCallback.call(this.callbackContext, event);
- }
-
- if (this._keys[event.keyCode] && this._keys[event.keyCode].isDown)
- {
- // Key already down and still down, so update
- this._keys[event.keyCode].duration = this.game.time.now - this._keys[event.keyCode].timeDown;
- }
- else
- {
- if (!this._keys[event.keyCode])
- {
- // Not used this key before, so register it
- this._keys[event.keyCode] = {
- isDown: true,
- timeDown: this.game.time.now,
- timeUp: 0,
- duration: 0
- };
- }
- else
- {
- // Key used before but freshly down
- this._keys[event.keyCode].isDown = true;
- this._keys[event.keyCode].timeDown = this.game.time.now;
- this._keys[event.keyCode].duration = 0;
- }
- }
-
- if (this._hotkeys[event.keyCode])
- {
- this._hotkeys[event.keyCode].processKeyDown(event);
- }
-
- },
-
- /**
- * Process the keyup event.
- * @method Phaser.Keyboard#processKeyUp
- * @param {KeyboardEvent} event
- * @protected
- */
- processKeyUp: function (event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- if (this._capture[event.keyCode])
- {
- event.preventDefault();
- }
-
- if (this.onUpCallback)
- {
- this.onUpCallback.call(this.callbackContext, event);
- }
-
- if (this._hotkeys[event.keyCode])
- {
- this._hotkeys[event.keyCode].processKeyUp(event);
- }
-
- if (this._keys[event.keyCode])
- {
- this._keys[event.keyCode].isDown = false;
- this._keys[event.keyCode].timeUp = this.game.time.now;
- }
- else
- {
- // Not used this key before, so register it
- this._keys[event.keyCode] = {
- isDown: false,
- timeDown: this.game.time.now,
- timeUp: this.game.time.now,
- duration: 0
- };
- }
-
- },
-
- /**
- * Reset the "isDown" state of all keys.
- * @method Phaser.Keyboard#reset
- */
- reset: function () {
-
- for (var key in this._keys)
- {
- this._keys[key].isDown = false;
- }
-
- },
-
- /**
- * Returns the "just pressed" state of the key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)
- * @method Phaser.Keyboard#justPressed
- * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
- * @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
- * @return {boolean} True if the key is just pressed otherwise false.
- */
- justPressed: function (keycode, duration) {
-
- if (typeof duration === "undefined") { duration = 250; }
-
- if (this._keys[keycode] && this._keys[keycode].isDown && this._keys[keycode].duration < duration)
- {
- return true;
- }
-
- return false;
-
- },
-
- /**
- * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)
- * @method Phaser.Keyboard#justPressed
- * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
- * @param {number} [duration=250] - The duration below which the key is considered as being just released.
- * @return {boolean} True if the key is just released otherwise false.
- */
- justReleased: function (keycode, duration) {
-
- if (typeof duration === "undefined") { duration = 250; }
-
- if (this._keys[keycode] && this._keys[keycode].isDown === false && (this.game.time.now - this._keys[keycode].timeUp < duration))
- {
- return true;
- }
-
- return false;
-
- },
-
- /**
- * Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser.
- * @method Phaser.Keyboard#isDown
- * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
- * @return {boolean} True if the key is currently down.
- */
- isDown: function (keycode) {
-
- if (this._keys[keycode])
- {
- return this._keys[keycode].isDown;
- }
-
- return false;
-
- }
-
-};
-
-Phaser.Keyboard.A = "A".charCodeAt(0);
-Phaser.Keyboard.B = "B".charCodeAt(0);
-Phaser.Keyboard.C = "C".charCodeAt(0);
-Phaser.Keyboard.D = "D".charCodeAt(0);
-Phaser.Keyboard.E = "E".charCodeAt(0);
-Phaser.Keyboard.F = "F".charCodeAt(0);
-Phaser.Keyboard.G = "G".charCodeAt(0);
-Phaser.Keyboard.H = "H".charCodeAt(0);
-Phaser.Keyboard.I = "I".charCodeAt(0);
-Phaser.Keyboard.J = "J".charCodeAt(0);
-Phaser.Keyboard.K = "K".charCodeAt(0);
-Phaser.Keyboard.L = "L".charCodeAt(0);
-Phaser.Keyboard.M = "M".charCodeAt(0);
-Phaser.Keyboard.N = "N".charCodeAt(0);
-Phaser.Keyboard.O = "O".charCodeAt(0);
-Phaser.Keyboard.P = "P".charCodeAt(0);
-Phaser.Keyboard.Q = "Q".charCodeAt(0);
-Phaser.Keyboard.R = "R".charCodeAt(0);
-Phaser.Keyboard.S = "S".charCodeAt(0);
-Phaser.Keyboard.T = "T".charCodeAt(0);
-Phaser.Keyboard.U = "U".charCodeAt(0);
-Phaser.Keyboard.V = "V".charCodeAt(0);
-Phaser.Keyboard.W = "W".charCodeAt(0);
-Phaser.Keyboard.X = "X".charCodeAt(0);
-Phaser.Keyboard.Y = "Y".charCodeAt(0);
-Phaser.Keyboard.Z = "Z".charCodeAt(0);
-Phaser.Keyboard.ZERO = "0".charCodeAt(0);
-Phaser.Keyboard.ONE = "1".charCodeAt(0);
-Phaser.Keyboard.TWO = "2".charCodeAt(0);
-Phaser.Keyboard.THREE = "3".charCodeAt(0);
-Phaser.Keyboard.FOUR = "4".charCodeAt(0);
-Phaser.Keyboard.FIVE = "5".charCodeAt(0);
-Phaser.Keyboard.SIX = "6".charCodeAt(0);
-Phaser.Keyboard.SEVEN = "7".charCodeAt(0);
-Phaser.Keyboard.EIGHT = "8".charCodeAt(0);
-Phaser.Keyboard.NINE = "9".charCodeAt(0);
-Phaser.Keyboard.NUMPAD_0 = 96;
-Phaser.Keyboard.NUMPAD_1 = 97;
-Phaser.Keyboard.NUMPAD_2 = 98;
-Phaser.Keyboard.NUMPAD_3 = 99;
-Phaser.Keyboard.NUMPAD_4 = 100;
-Phaser.Keyboard.NUMPAD_5 = 101;
-Phaser.Keyboard.NUMPAD_6 = 102;
-Phaser.Keyboard.NUMPAD_7 = 103;
-Phaser.Keyboard.NUMPAD_8 = 104;
-Phaser.Keyboard.NUMPAD_9 = 105;
-Phaser.Keyboard.NUMPAD_MULTIPLY = 106;
-Phaser.Keyboard.NUMPAD_ADD = 107;
-Phaser.Keyboard.NUMPAD_ENTER = 108;
-Phaser.Keyboard.NUMPAD_SUBTRACT = 109;
-Phaser.Keyboard.NUMPAD_DECIMAL = 110;
-Phaser.Keyboard.NUMPAD_DIVIDE = 111;
-Phaser.Keyboard.F1 = 112;
-Phaser.Keyboard.F2 = 113;
-Phaser.Keyboard.F3 = 114;
-Phaser.Keyboard.F4 = 115;
-Phaser.Keyboard.F5 = 116;
-Phaser.Keyboard.F6 = 117;
-Phaser.Keyboard.F7 = 118;
-Phaser.Keyboard.F8 = 119;
-Phaser.Keyboard.F9 = 120;
-Phaser.Keyboard.F10 = 121;
-Phaser.Keyboard.F11 = 122;
-Phaser.Keyboard.F12 = 123;
-Phaser.Keyboard.F13 = 124;
-Phaser.Keyboard.F14 = 125;
-Phaser.Keyboard.F15 = 126;
-Phaser.Keyboard.COLON = 186;
-Phaser.Keyboard.EQUALS = 187;
-Phaser.Keyboard.UNDERSCORE = 189;
-Phaser.Keyboard.QUESTION_MARK = 191;
-Phaser.Keyboard.TILDE = 192;
-Phaser.Keyboard.OPEN_BRACKET = 219;
-Phaser.Keyboard.BACKWARD_SLASH = 220;
-Phaser.Keyboard.CLOSED_BRACKET = 221;
-Phaser.Keyboard.QUOTES = 222;
-Phaser.Keyboard.BACKSPACE = 8;
-Phaser.Keyboard.TAB = 9;
-Phaser.Keyboard.CLEAR = 12;
-Phaser.Keyboard.ENTER = 13;
-Phaser.Keyboard.SHIFT = 16;
-Phaser.Keyboard.CONTROL = 17;
-Phaser.Keyboard.ALT = 18;
-Phaser.Keyboard.CAPS_LOCK = 20;
-Phaser.Keyboard.ESC = 27;
-Phaser.Keyboard.SPACEBAR = 32;
-Phaser.Keyboard.PAGE_UP = 33;
-Phaser.Keyboard.PAGE_DOWN = 34;
-Phaser.Keyboard.END = 35;
-Phaser.Keyboard.HOME = 36;
-Phaser.Keyboard.LEFT = 37;
-Phaser.Keyboard.UP = 38;
-Phaser.Keyboard.RIGHT = 39;
-Phaser.Keyboard.DOWN = 40;
-Phaser.Keyboard.INSERT = 45;
-Phaser.Keyboard.DELETE = 46;
-Phaser.Keyboard.HELP = 47;
-Phaser.Keyboard.NUM_LOCK = 144;
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser - Mouse constructor.
-*
-* @class Phaser.Mouse
-* @classdesc The Mouse class
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-*/
-Phaser.Mouse = function (game) {
-
- /**
- * @property {Phaser.Game} game - Local reference to game.
- */
- this.game = game;
-
- /**
- * @property {Object} callbackContext - Description.
- */
- this.callbackContext = this.game;
-
- /**
- * @property {function} mouseDownCallback - Description.
- * @default
- */
- this.mouseDownCallback = null;
-
- /**
- * @property {function} mouseMoveCallback - Description.
- * @default
- */
- this.mouseMoveCallback = null;
-
- /**
- * @property {function} mouseUpCallback - Description.
- * @default
- */
- this.mouseUpCallback = null;
-
- /**
- * @property {number} button- The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON.
- * @default
- */
- this.button = -1;
-
- /**
- * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
- * @property {boolean} disabled
- * @default
- */
- this.disabled = false;
-
- /**
- * If the mouse has been Pointer Locked successfully this will be set to true.
- * @property {boolean} locked
- * @default
- */
- this.locked = false;
-
- /**
- * This event is dispatched when the browser enters or leaves pointer lock state.
- * @property {Phaser.Signal} pointerLock
- * @default
- */
- this.pointerLock = new Phaser.Signal;
-
-};
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Mouse.NO_BUTTON = -1;
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Mouse.LEFT_BUTTON = 0;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Mouse.MIDDLE_BUTTON = 1;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.Mouse.RIGHT_BUTTON = 2;
-
-Phaser.Mouse.prototype = {
-
- /**
- * Starts the event listeners running.
- * @method Phaser.Mouse#start
- */
- start: function () {
-
- var _this = this;
-
- if (this.game.device.android && this.game.device.chrome == false)
- {
- // Android stock browser fires mouse events even if you preventDefault on the touchStart, so ...
- return;
- }
-
- this._onMouseDown = function (event) {
- return _this.onMouseDown(event);
- };
-
- this._onMouseMove = function (event) {
- return _this.onMouseMove(event);
- };
-
- this._onMouseUp = function (event) {
- return _this.onMouseUp(event);
- };
-
- this.game.renderer.view.addEventListener('mousedown', this._onMouseDown, true);
- this.game.renderer.view.addEventListener('mousemove', this._onMouseMove, true);
- this.game.renderer.view.addEventListener('mouseup', this._onMouseUp, true);
-
- },
-
- /**
- * The internal method that handles the mouse down event from the browser.
- * @method Phaser.Mouse#onMouseDown
- * @param {MouseEvent} event
- */
- onMouseDown: function (event) {
-
- event.preventDefault();
-
- if (event.which === 1)
- {
- this.button = Phaser.Mouse.LEFT_BUTTON;
- }
- else if (event.which === 2)
- {
- this.button = Phaser.Mouse.MIDDLE_BUTTON;
- }
- else if (event.which === 3)
- {
- this.button = Phaser.Mouse.RIGHT_BUTTON;
- }
-
- if (this.mouseDownCallback)
- {
- this.mouseDownCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event['identifier'] = 0;
-
- this.game.input.mousePointer.start(event);
-
- },
-
- /**
- * The internal method that handles the mouse move event from the browser.
- * @method Phaser.Mouse#onMouseMove
- * @param {MouseEvent} event
- */
- onMouseMove: function (event) {
-
- event.preventDefault();
-
- if (this.mouseMoveCallback)
- {
- this.mouseMoveCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event['identifier'] = 0;
-
- this.game.input.mousePointer.move(event);
-
- },
-
- /**
- * The internal method that handles the mouse up event from the browser.
- * @method Phaser.Mouse#onMouseUp
- * @param {MouseEvent} event
- */
- onMouseUp: function (event) {
-
- event.preventDefault();
-
- this.button = Phaser.Mouse.NO_BUTTON;
-
- if (this.mouseUpCallback)
- {
- this.mouseUpCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event['identifier'] = 0;
-
- this.game.input.mousePointer.stop(event);
-
- },
-
- /**
- * If the browser supports it you can request that the pointer be locked to the browser window.
- * This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key.
- * If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'.
- * @method Phaser.Mouse#requestPointerLock
- */
- requestPointerLock: function () {
-
- if (this.game.device.pointerLock)
- {
- var element = this.game.stage.canvas;
-
- element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock;
-
- element.requestPointerLock();
-
- var _this = this;
-
- this._pointerLockChange = function (event) {
- return _this.pointerLockChange(event);
- };
-
- document.addEventListener('pointerlockchange', this._pointerLockChange, true);
- document.addEventListener('mozpointerlockchange', this._pointerLockChange, true);
- document.addEventListener('webkitpointerlockchange', this._pointerLockChange, true);
- }
-
- },
-
- /**
- * Internal pointerLockChange handler.
- * @method Phaser.Mouse#pointerLockChange
- * @param {MouseEvent} event
- */
- pointerLockChange: function (event) {
-
- var element = this.game.stage.canvas;
-
- if (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element)
- {
- // Pointer was successfully locked
- this.locked = true;
- this.pointerLock.dispatch(true);
- }
- else
- {
- // Pointer was unlocked
- this.locked = false;
- this.pointerLock.dispatch(false);
- }
-
- },
-
- /**
- * Internal release pointer lock handler.
- * @method Phaser.Mouse#releasePointerLock
- */
- releasePointerLock: function () {
-
- document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock;
-
- document.exitPointerLock();
-
- document.removeEventListener('pointerlockchange', this._pointerLockChange, true);
- document.removeEventListener('mozpointerlockchange', this._pointerLockChange, true);
- document.removeEventListener('webkitpointerlockchange', this._pointerLockChange, true);
-
- },
-
- /**
- * Stop the event listeners.
- * @method Phaser.Mouse#stop
- */
- stop: function () {
-
- this.game.stage.canvas.removeEventListener('mousedown', this._onMouseDown, true);
- this.game.stage.canvas.removeEventListener('mousemove', this._onMouseMove, true);
- this.game.stage.canvas.removeEventListener('mouseup', this._onMouseUp, true);
-
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser - MSPointer constructor.
-*
-* @class Phaser.MSPointer
-* @classdesc The MSPointer class handles touch interactions with the game and the resulting Pointer objects.
-* It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript.
-* http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-*/
-Phaser.MSPointer = function (game) {
-
- /**
- * @property {Phaser.Game} game - Local reference to game.
- */
- this.game = game;
-
- /**
- * @property {Phaser.Game} callbackContext - Description.
- */
- this.callbackContext = this.game;
-
- /**
- * @property {Description} mouseDownCallback - Description.
- * @default
- */
- this.mouseDownCallback = null;
-
- /**
- * @property {Description} mouseMoveCallback - Description.
- * @default
- */
- this.mouseMoveCallback = null;
-
- /**
- * @property {Description} mouseUpCallback - Description.
- * @default
- */
- this.mouseUpCallback = null;
-
- /**
- * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
- * @property {boolean} disabled
- */
- this.disabled = false;
-
- /**
- * Description.
- * @property {Description} _onMSPointerDown
- * @private
- * @default
- */
- this._onMSPointerDown = null;
-
- /**
- * Description.
- * @property {Description} _onMSPointerMove
- * @private
- * @default
- */
- this._onMSPointerMove = null;
-
- /**
- * Description.
- * @property {Description} _onMSPointerUp
- * @private
- * @default
- */
- this._onMSPointerUp = null;
-
-};
-
-Phaser.MSPointer.prototype = {
-
- /**
- * Starts the event listeners running.
- * @method Phaser.MSPointer#start
- */
- start: function () {
-
- var _this = this;
-
- if (this.game.device.mspointer == true)
- {
- this._onMSPointerDown = function (event) {
- return _this.onPointerDown(event);
- };
-
- this._onMSPointerMove = function (event) {
- return _this.onPointerMove(event);
- };
-
- this._onMSPointerUp = function (event) {
- return _this.onPointerUp(event);
- };
-
- this.game.renderer.view.addEventListener('MSPointerDown', this._onMSPointerDown, false);
- this.game.renderer.view.addEventListener('MSPointerMove', this._onMSPointerMove, false);
- this.game.renderer.view.addEventListener('MSPointerUp', this._onMSPointerUp, false);
-
- this.game.renderer.view.style['-ms-content-zooming'] = 'none';
- this.game.renderer.view.style['-ms-touch-action'] = 'none';
-
- }
-
- },
-
- /**
- * Description.
- * @method Phaser.MSPointer#onPointerDown
- * @param {Any} event
- **/
- onPointerDown: function (event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
- event.identifier = event.pointerId;
-
- this.game.input.startPointer(event);
-
- },
-
- /**
- * Description.
- * @method Phaser.MSPointer#onPointerMove
- * @param {Any} event
- **/
- onPointerMove: function (event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
- event.identifier = event.pointerId;
-
- this.game.input.updatePointer(event);
-
- },
-
- /**
- * Description.
- * @method Phaser.MSPointer#onPointerUp
- * @param {Any} event
- **/
- onPointerUp: function (event) {
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- event.preventDefault();
- event.identifier = event.pointerId;
-
- this.game.input.stopPointer(event);
-
- },
-
- /**
- * Stop the event listeners.
- * @method Phaser.MSPointer#stop
- */
- stop: function () {
-
- this.game.stage.canvas.removeEventListener('MSPointerDown', this._onMSPointerDown);
- this.game.stage.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove);
- this.game.stage.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp);
-
- }
-
-};
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser - Pointer constructor.
-*
-* @class Phaser.Pointer
-* @classdesc A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen.
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {Description} id - Description.
-*/
-Phaser.Pointer = function (game, id) {
-
- /**
- * @property {Phaser.Game} game - Local reference to game.
- */
- this.game = game;
-
- /**
- * @property {Description} id - Description.
- */
- this.id = id;
-
- /**
- * Local private variable to store the status of dispatching a hold event.
- * @property {boolean} _holdSent
- * @private
- * @default
- */
- this._holdSent = false;
-
- /**
- * Local private variable storing the short-term history of pointer movements.
- * @property {array} _history
- * @private
- */
- this._history = [];
-
- /**
- * Local private variable storing the time at which the next history drop should occur
- * @property {number} _lastDrop
- * @private
- * @default
- */
- this._nextDrop = 0;
-
- /**
- * Monitor events outside of a state reset loop.
- * @property {boolean} _stateReset
- * @private
- * @default
- */
- this._stateReset = false;
-
- /**
- * A Vector object containing the initial position when the Pointer was engaged with the screen.
- * @property {Vec2} positionDown
- * @default
- **/
- this.positionDown = null;
-
- /**
- * A Vector object containing the current position of the Pointer on the screen.
- * @property {Vec2} position
- * @default
- **/
- this.position = null;
-
- /**
- * A Circle object centered on the x/y screen coordinates of the Pointer.
- * Default size of 44px (Apple's recommended "finger tip" size).
- * @property {Circle} circle
- * @default
- **/
- this.circle = null;
-
- /**
- * Description.
- * @property {boolean} withinGame
- */
- this.withinGame = false;
-
- /**
- * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset.
- * @property {number} clientX
- * @default
- */
- this.clientX = -1;
-
- /**
- * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset.
- * @property {number} clientY
- * @default
- */
- this.clientY = -1;
-
- /**
- * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset.
- * @property {number} pageX
- * @default
- */
- this.pageX = -1;
-
- /**
- * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset.
- * @property {number} pageY
- * @default
- */
- this.pageY = -1;
-
- /**
- * The horizontal coordinate of point relative to the screen in pixels.
- * @property {number} screenX
- * @default
- */
- this.screenX = -1;
-
- /**
- * The vertical coordinate of point relative to the screen in pixels.
- * @property {number} screenY
- * @default
- */
- this.screenY = -1;
-
- /**
- * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
- * @property {number} x
- * @default
- */
- this.x = -1;
-
- /**
- * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.
- * @property {number} y
- * @default
- */
- this.y = -1;
-
- /**
- * If the Pointer is a mouse this is true, otherwise false.
- * @property {boolean} isMouse
- * @type {boolean}
- */
- this.isMouse = false;
-
- /**
- * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
- * @property {boolean} isDown
- * @default
- */
- this.isDown = false;
-
- /**
- * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true.
- * @property {boolean} isUp
- * @default
- */
- this.isUp = true;
-
- /**
- * A timestamp representing when the Pointer first touched the touchscreen.
- * @property {number} timeDown
- * @default
- */
- this.timeDown = 0;
-
- /**
- * A timestamp representing when the Pointer left the touchscreen.
- * @property {number} timeUp
- * @default
- */
- this.timeUp = 0;
-
- /**
- * A timestamp representing when the Pointer was last tapped or clicked.
- * @property {number} previousTapTime
- * @default
- */
- this.previousTapTime = 0;
-
- /**
- * The total number of times this Pointer has been touched to the touchscreen.
- * @property {number} totalTouches
- * @default
- */
- this.totalTouches = 0;
-
- /**
- * The number of miliseconds since the last click.
- * @property {number} msSinceLastClick
- * @default
- */
- this.msSinceLastClick = Number.MAX_VALUE;
-
- /**
- * The Game Object this Pointer is currently over / touching / dragging.
- * @property {Any} targetObject
- * @default
- */
- this.targetObject = null;
-
- /**
- * Description.
- * @property {boolean} isDown - Description.
- * @default
- */
- this.active = false;
-
- /**
- * Description
- * @property {Phaser.Point} position
- */
- this.position = new Phaser.Point();
-
- /**
- * Description
- * @property {Phaser.Point} positionDown
- */
- this.positionDown = new Phaser.Point();
-
- /**
- * Description
- * @property {Phaser.Circle} circle
- */
- this.circle = new Phaser.Circle(0, 0, 44);
-
- if (id == 0)
- {
- this.isMouse = true;
- }
-
-};
-
-Phaser.Pointer.prototype = {
-
- /**
- * Called when the Pointer is pressed onto the touchscreen.
- * @method Phaser.Pointer#start
- * @param {Any} event
- */
- start: function (event) {
-
- this.identifier = event.identifier;
- this.target = event.target;
-
- if (typeof event.button !== 'undefined')
- {
- this.button = event.button;
- }
-
- // Fix to stop rogue browser plugins from blocking the visibility state event
- if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false)
- {
- this.game.paused = false;
- return this;
- }
-
- this._history.length = 0;
- this.active = true;
- this.withinGame = true;
- this.isDown = true;
- this.isUp = false;
-
- // Work out how long it has been since the last click
- this.msSinceLastClick = this.game.time.now - this.timeDown;
- this.timeDown = this.game.time.now;
- this._holdSent = false;
-
- // This sets the x/y and other local values
- this.move(event);
-
- // x and y are the old values here?
- this.positionDown.setTo(this.x, this.y);
-
- if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- this.game.input.x = this.x;
- this.game.input.y = this.y;
- this.game.input.position.setTo(this.x, this.y);
- this.game.input.onDown.dispatch(this, event);
- this.game.input.resetSpeed(this.x, this.y);
- }
-
- this._stateReset = false;
- this.totalTouches++;
-
- if (this.isMouse == false)
- {
- this.game.input.currentPointers++;
- }
-
- if (this.targetObject !== null)
- {
- this.targetObject._touchedHandler(this);
- }
-
- return this;
-
- },
-
- /**
- * Description.
- * @method Phaser.Pointer#update
- */
- update: function () {
-
- if (this.active)
- {
- if (this._holdSent == false && this.duration >= this.game.input.holdRate)
- {
- if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- this.game.input.onHold.dispatch(this);
- }
-
- this._holdSent = true;
- }
-
- // Update the droppings history
- if (this.game.input.recordPointerHistory && this.game.time.now >= this._nextDrop)
- {
- this._nextDrop = this.game.time.now + this.game.input.recordRate;
-
- this._history.push({
- x: this.position.x,
- y: this.position.y
- });
-
- if (this._history.length > this.game.input.recordLimit)
- {
- this._history.shift();
- }
- }
- }
-
- },
-
- /**
- * Called when the Pointer is moved
- * @method Phaser.Pointer#move
- * @param {Any} event
- */
- move: function (event) {
-
- if (this.game.input.pollLocked)
- {
- return;
- }
-
- if (typeof event.button !== 'undefined')
- {
- this.button = event.button;
- }
-
- this.clientX = event.clientX;
- this.clientY = event.clientY;
-
- this.pageX = event.pageX;
- this.pageY = event.pageY;
-
- this.screenX = event.screenX;
- this.screenY = event.screenY;
-
- this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x;
- this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y;
-
- this.position.setTo(this.x, this.y);
- this.circle.x = this.x;
- this.circle.y = this.y;
-
- if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- this.game.input.activePointer = this;
- this.game.input.x = this.x;
- this.game.input.y = this.y;
- this.game.input.position.setTo(this.game.input.x, this.game.input.y);
- this.game.input.circle.x = this.game.input.x;
- this.game.input.circle.y = this.game.input.y;
- }
-
- // If the game is paused we don't process any target objects
- if (this.game.paused)
- {
- return this;
- }
-
- // Easy out if we're dragging something and it still exists
- if (this.targetObject !== null && this.targetObject.isDragged == true)
- {
- if (this.targetObject.update(this) == false)
- {
- this.targetObject = null;
- }
-
- return this;
- }
-
- // Work out which object is on the top
- this._highestRenderOrderID = -1;
- this._highestRenderObject = null;
- this._highestInputPriorityID = -1;
-
- // Just run through the linked list
- if (this.game.input.interactiveItems.total > 0)
- {
- var currentNode = this.game.input.interactiveItems.next;
-
- do
- {
- // If the object is using pixelPerfect checks, or has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
- if (currentNode.pixelPerfect || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID == this._highestInputPriorityID && currentNode.sprite.renderOrderID > this._highestRenderOrderID))
- {
- if (currentNode.checkPointerOver(this))
- {
- // console.log('HRO set', currentNode.sprite.name);
- this._highestRenderOrderID = currentNode.sprite.renderOrderID;
- this._highestInputPriorityID = currentNode.priorityID;
- this._highestRenderObject = currentNode;
- }
- }
- currentNode = currentNode.next;
- }
- while (currentNode != null)
- }
-
- if (this._highestRenderObject == null)
- {
- // The pointer isn't currently over anything, check if we've got a lingering previous target
- if (this.targetObject)
- {
- // console.log("The pointer isn't currently over anything, check if we've got a lingering previous target");
- this.targetObject._pointerOutHandler(this);
- this.targetObject = null;
- }
- }
- else
- {
- if (this.targetObject == null)
- {
- // And now set the new one
- // console.log('And now set the new one');
- this.targetObject = this._highestRenderObject;
- this._highestRenderObject._pointerOverHandler(this);
- }
- else
- {
- // We've got a target from the last update
- // console.log("We've got a target from the last update");
- if (this.targetObject == this._highestRenderObject)
- {
- // Same target as before, so update it
- // console.log("Same target as before, so update it");
- if (this._highestRenderObject.update(this) == false)
- {
- this.targetObject = null;
- }
- }
- else
- {
- // The target has changed, so tell the old one we've left it
- // console.log("The target has changed, so tell the old one we've left it");
- this.targetObject._pointerOutHandler(this);
-
- // And now set the new one
- this.targetObject = this._highestRenderObject;
- this.targetObject._pointerOverHandler(this);
- }
- }
- }
-
- return this;
-
- },
-
- /**
- * Called when the Pointer leaves the target area.
- * @method Phaser.Pointer#leave
- * @param {Any} event
- */
- leave: function (event) {
-
- this.withinGame = false;
- this.move(event);
-
- },
-
- /**
- * Called when the Pointer leaves the touchscreen.
- * @method Phaser.Pointer#stop
- * @param {Any} event
- */
- stop: function (event) {
-
- if (this._stateReset)
- {
- event.preventDefault();
- return;
- }
-
- this.timeUp = this.game.time.now;
-
- if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
- {
- this.game.input.onUp.dispatch(this, event);
-
- // Was it a tap?
- if (this.duration >= 0 && this.duration <= this.game.input.tapRate)
- {
- // Was it a double-tap?
- if (this.timeUp - this.previousTapTime < this.game.input.doubleTapRate)
- {
- // Yes, let's dispatch the signal then with the 2nd parameter set to true
- this.game.input.onTap.dispatch(this, true);
- }
- else
- {
- // Wasn't a double-tap, so dispatch a single tap signal
- this.game.input.onTap.dispatch(this, false);
- }
-
- this.previousTapTime = this.timeUp;
- }
- }
-
- // Mouse is always active
- if (this.id > 0)
- {
- this.active = false;
- }
-
- this.withinGame = false;
- this.isDown = false;
- this.isUp = true;
-
- if (this.isMouse == false)
- {
- this.game.input.currentPointers--;
- }
-
- if (this.game.input.interactiveItems.total > 0)
- {
- var currentNode = this.game.input.interactiveItems.next;
-
- do
- {
- if (currentNode)
- {
- currentNode._releasedHandler(this);
- }
-
- currentNode = currentNode.next;
- }
- while (currentNode != null)
- }
-
- if (this.targetObject)
- {
- this.targetObject._releasedHandler(this);
- }
-
- this.targetObject = null;
- return this;
-
- },
-
- /**
- * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate.
- * @method Phaser.Pointer#justPressed
- * @param {number} [duration]
- * @return {boolean}
- */
- justPressed: function (duration) {
-
- duration = duration || this.game.input.justPressedRate;
-
- return (this.isDown === true && (this.timeDown + duration) > this.game.time.now);
-
- },
-
- /**
- * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate.
- * @method Phaser.Pointer#justReleased
- * @param {number} [duration]
- * @return {boolean}
- */
- justReleased: function (duration) {
-
- duration = duration || this.game.input.justReleasedRate;
-
- return (this.isUp === true && (this.timeUp + duration) > this.game.time.now);
-
- },
-
- /**
- * Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
- * @method Phaser.Pointer#reset
- */
- reset: function () {
-
- if (this.isMouse == false)
- {
- this.active = false;
- }
-
- this.identifier = null;
- this.isDown = false;
- this.isUp = true;
- this.totalTouches = 0;
- this._holdSent = false;
- this._history.length = 0;
- this._stateReset = true;
-
- if (this.targetObject)
- {
- this.targetObject._releasedHandler(this);
- }
-
- this.targetObject = null;
-
- },
-
- /**
- * Returns a string representation of this object.
- * @method Phaser.Pointer#toString
- * @return {string} A string representation of the instance.
- **/
- toString: function () {
- return "[{Pointer (id=" + this.id + " identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]";
- }
-
-};
-
-/**
-* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
-* @name Phaser.Pointer#duration
-* @property {number} duration - How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
-* @readonly
-*/
-Object.defineProperty(Phaser.Pointer.prototype, "duration", {
-
- get: function () {
-
- if (this.isUp)
- {
- return -1;
- }
-
- return this.game.time.now - this.timeDown;
-
- }
-
-});
-
-/**
-* Gets the X value of this Pointer in world coordinates based on the world camera.
-* @name Phaser.Pointer#worldX
-* @property {number} duration - The X value of this Pointer in world coordinates based on the world camera.
-* @readonly
-*/
-Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
-
- get: function () {
-
- return this.game.world.camera.x + this.x;
-
- }
-
-});
-
-/**
-* Gets the Y value of this Pointer in world coordinates based on the world camera.
-* @name Phaser.Pointer#worldY
-* @property {number} duration - The Y value of this Pointer in world coordinates based on the world camera.
-* @readonly
-*/
-Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
-
- get: function () {
-
- return this.game.world.camera.y + this.y;
-
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch.
-*
-* @class Phaser.Touch
-* @classdesc The Touch class handles touch interactions with the game and the resulting Pointer objects.
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-*/
-Phaser.Touch = function (game) {
-
- /**
- * @property {Phaser.Game} game - Local reference to game.
- */
- this.game = game;
-
- /**
- * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
- * @method Phaser.Touch#disabled
- * @return {boolean}
- */
- this.disabled = false;
-
- /**
- * @property {Phaser.Game} callbackContext - Description.
- */
- this.callbackContext = this.game;
-
- /**
- * @property {Phaser.Game} touchStartCallback - Description.
- * @default
- */
- this.touchStartCallback = null;
-
- /**
- * @property {Phaser.Game} touchMoveCallback - Description.
- * @default
- */
- this.touchMoveCallback = null;
-
- /**
- * @property {Phaser.Game} touchEndCallback - Description.
- * @default
- */
- this.touchEndCallback = null;
-
- /**
- * @property {Phaser.Game} touchEnterCallback - Description.
- * @default
- */
- this.touchEnterCallback = null;
-
- /**
- * @property {Phaser.Game} touchLeaveCallback - Description.
- * @default
- */
- this.touchLeaveCallback = null;
-
- /**
- * @property {Description} touchCancelCallback - Description.
- * @default
- */
- this.touchCancelCallback = null;
-
- /**
- * @property {boolean} preventDefault - Description.
- * @default
- */
- this.preventDefault = true;
-
- this._onTouchStart = null;
- this._onTouchMove = null;
- this._onTouchEnd = null;
- this._onTouchEnter = null;
- this._onTouchLeave = null;
- this._onTouchCancel = null;
- this._onTouchMove = null;
-
-};
-
-Phaser.Touch.prototype = {
-
- /**
- * Starts the event listeners running.
- * @method Phaser.Touch#start
- */
- start: function () {
-
- var _this = this;
-
- if (this.game.device.touch)
- {
- this._onTouchStart = function (event) {
- return _this.onTouchStart(event);
- };
-
- this._onTouchMove = function (event) {
- return _this.onTouchMove(event);
- };
-
- this._onTouchEnd = function (event) {
- return _this.onTouchEnd(event);
- };
-
- this._onTouchEnter = function (event) {
- return _this.onTouchEnter(event);
- };
-
- this._onTouchLeave = function (event) {
- return _this.onTouchLeave(event);
- };
-
- this._onTouchCancel = function (event) {
- return _this.onTouchCancel(event);
- };
-
- this.game.renderer.view.addEventListener('touchstart', this._onTouchStart, false);
- this.game.renderer.view.addEventListener('touchmove', this._onTouchMove, false);
- this.game.renderer.view.addEventListener('touchend', this._onTouchEnd, false);
- this.game.renderer.view.addEventListener('touchenter', this._onTouchEnter, false);
- this.game.renderer.view.addEventListener('touchleave', this._onTouchLeave, false);
- this.game.renderer.view.addEventListener('touchcancel', this._onTouchCancel, false);
- }
-
- },
-
- /**
- * Consumes all touchmove events on the document (only enable this if you know you need it!).
- * @method Phaser.Touch#consumeTouchMove
- */
- consumeDocumentTouches: function () {
-
- this._documentTouchMove = function (event) {
- event.preventDefault();
- };
-
- document.addEventListener('touchmove', this._documentTouchMove, false);
-
- },
-
- /**
- * Description.
- * @method Phaser.Touch#onTouchStart
- * @param {Any} event
- */
- onTouchStart: function (event) {
-
- if (this.touchStartCallback)
- {
- this.touchStartCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- if (this.preventDefault)
- {
- event.preventDefault();
- }
-
- // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
- // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
- // event.changedTouches = the touches that CHANGED in this event, not the total number of them
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.startPointer(event.changedTouches[i]);
- }
-
- },
-
- /**
- * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome).
- * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears.
- * @method Phaser.Touch#onTouchCancel
- * @param {Any} event
- */
- onTouchCancel: function (event) {
-
- if (this.touchCancelCallback)
- {
- this.touchCancelCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- if (this.preventDefault)
- {
- event.preventDefault();
- }
-
- // Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome)
- // http://www.w3.org/TR/touch-events/#dfn-touchcancel
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.stopPointer(event.changedTouches[i]);
- }
-
- },
-
- /**
- * For touch enter and leave its a list of the touch points that have entered or left the target.
- * Doesn't appear to be supported by most browsers on a canvas element yet.
- * @method Phaser.Touch#onTouchEnter
- * @param {Any} event
- */
- onTouchEnter: function (event) {
-
- if (this.touchEnterCallback)
- {
- this.touchEnterCallback.call(this.callbackContext, event);
- }
-
- if (this.game.input.disabled || this.disabled)
- {
- return;
- }
-
- if (this.preventDefault)
- {
- event.preventDefault();
- }
-
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- //console.log('touch enter');
- }
-
- },
-
- /**
- * For touch enter and leave its a list of the touch points that have entered or left the target.
- * Doesn't appear to be supported by most browsers on a canvas element yet.
- * @method Phaser.Touch#onTouchLeave
- * @param {Any} event
- */
- onTouchLeave: function (event) {
-
- if (this.touchLeaveCallback)
- {
- this.touchLeaveCallback.call(this.callbackContext, event);
- }
-
- if (this.preventDefault)
- {
- event.preventDefault();
- }
-
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- //console.log('touch leave');
- }
-
- },
-
- /**
- * Description.
- * @method Phaser.Touch#onTouchMove
- * @param {Any} event
- */
- onTouchMove: function (event) {
-
- if (this.touchMoveCallback)
- {
- this.touchMoveCallback.call(this.callbackContext, event);
- }
-
- if (this.preventDefault)
- {
- event.preventDefault();
- }
-
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.updatePointer(event.changedTouches[i]);
- }
-
- },
-
- /**
- * Description.
- * @method Phaser.Touch#onTouchEnd
- * @param {Any} event
- */
- onTouchEnd: function (event) {
-
- if (this.touchEndCallback)
- {
- this.touchEndCallback.call(this.callbackContext, event);
- }
-
- if (this.preventDefault)
- {
- event.preventDefault();
- }
-
- // For touch end its a list of the touch points that have been removed from the surface
- // https://developer.mozilla.org/en-US/docs/DOM/TouchList
- // event.changedTouches = the touches that CHANGED in this event, not the total number of them
- for (var i = 0; i < event.changedTouches.length; i++)
- {
- this.game.input.stopPointer(event.changedTouches[i]);
- }
-
- },
-
- /**
- * Stop the event listeners.
- * @method Phaser.Touch#stop
- */
- stop: function () {
-
- if (this.game.device.touch)
- {
- this.game.stage.canvas.removeEventListener('touchstart', this._onTouchStart);
- this.game.stage.canvas.removeEventListener('touchmove', this._onTouchMove);
- this.game.stage.canvas.removeEventListener('touchend', this._onTouchEnd);
- this.game.stage.canvas.removeEventListener('touchenter', this._onTouchEnter);
- this.game.stage.canvas.removeEventListener('touchleave', this._onTouchLeave);
- this.game.stage.canvas.removeEventListener('touchcancel', this._onTouchCancel);
- }
-
- }
-
-};
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Constructor for Phaser InputHandler.
-* @class Phaser.InputHandler
-* @classdesc Description.
-* @constructor
-* @param {Phaser.Sprite} game - Description.
-*/
-Phaser.InputHandler = function (sprite) {
-
- /**
- * @property {Phaser.Sprite} sprite - Description.
- */
- this.sprite = sprite;
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = sprite.game;
-
- /**
- * @property {boolean} enabled - Description.
- * @default
- */
- this.enabled = false;
-
- // Linked list references
- /**
- * @property {Description} parent - Description.
- * @default
- */
- this.parent = null;
-
- /**
- * @property {Description} next - Description.
- * @default
- */
- this.next = null;
-
- /**
- * @property {Description} prev - Description.
- * @default
- */
- this.prev = null;
-
- /**
- * @property {Description} last - Description.
- * @default
- */
- this.last = this;
-
- /**
- * @property {Description} first - Description.
- * @default
- */
- this.first = this;
-
- /**
- * @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap.
- * @default
- */
- this.priorityID = 0;
-
- /**
- * @property {boolean} useHandCursor - Description.
- * @default
- */
- this.useHandCursor = false;
-
- /**
- * @property {boolean} isDragged - Description.
- * @default
- */
- this.isDragged = false;
-
- /**
- * @property {boolean} allowHorizontalDrag - Description.
- * @default
- */
- this.allowHorizontalDrag = true;
-
- /**
- * @property {boolean} allowVerticalDrag - Description.
- * @default
- */
- this.allowVerticalDrag = true;
-
- /**
- * @property {boolean} bringToTop - Description.
- * @default
- */
- this.bringToTop = false;
-
- /**
- * @property {Description} snapOffset - Description.
- * @default
- */
- this.snapOffset = null;
-
- /**
- * @property {boolean} snapOnDrag - Description.
- * @default
- */
- this.snapOnDrag = false;
-
- /**
- * @property {boolean} snapOnRelease - Description.
- * @default
- */
- this.snapOnRelease = false;
-
- /**
- * @property {number} snapX - Description.
- * @default
- */
- this.snapX = 0;
-
- /**
- * @property {number} snapY - Description.
- * @default
- */
- this.snapY = 0;
-
- /**
- * @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it!
- * @default
- */
- this.pixelPerfect = false;
-
- /**
- * @property {number} pixelPerfectAlpha - The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit.
- * @default
- */
- this.pixelPerfectAlpha = 255;
-
- /**
- * @property {boolean} draggable - Is this sprite allowed to be dragged by the mouse? true = yes, false = no
- * @default
- */
- this.draggable = false;
-
- /**
- * @property {Description} boundsRect - A region of the game world within which the sprite is restricted during drag.
- * @default
- */
- this.boundsRect = null;
-
- /**
- * @property {Description} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag.
- * @default
- */
- this.boundsSprite = null;
-
- /**
- * If this object is set to consume the pointer event then it will stop all propogation from this object on.
- * For example if you had a stack of 6 sprites with the same priority IDs and one consumed the event, none of the others would receive it.
- * @property {boolean} consumePointerEvent
- * @default
- */
- this.consumePointerEvent = false;
-
- /**
- * @property {Phaser.Point} _tempPoint - Description.
- * @private
- */
- this._tempPoint = new Phaser.Point;
-
- this._pointerData = [];
-
- this._pointerData.push({
- id: 0,
- x: 0,
- y: 0,
- isDown: false,
- isUp: false,
- isOver: false,
- isOut: false,
- timeOver: 0,
- timeOut: 0,
- timeDown: 0,
- timeUp: 0,
- downDuration: 0,
- isDragged: false
- });
-
-};
-
-Phaser.InputHandler.prototype = {
-
- /**
- * Description.
- * @method Phaser.InputHandler#start
- * @param {number} priority - Description.
- * @param {boolean} useHandCursor - Description.
- * @return {Phaser.Sprite} Description.
- */
- start: function (priority, useHandCursor) {
-
- priority = priority || 0;
- if (typeof useHandCursor == 'undefined') { useHandCursor = false; }
-
- // Turning on
- if (this.enabled == false)
- {
- // Register, etc
- this.game.input.interactiveItems.add(this);
- this.useHandCursor = useHandCursor;
- this.priorityID = priority;
-
- for (var i = 0; i < 10; i++)
- {
- this._pointerData[i] = {
- id: i,
- x: 0,
- y: 0,
- isDown: false,
- isUp: false,
- isOver: false,
- isOut: false,
- timeOver: 0,
- timeOut: 0,
- timeDown: 0,
- timeUp: 0,
- downDuration: 0,
- isDragged: false
- };
- }
-
- this.snapOffset = new Phaser.Point;
- this.enabled = true;
-
- // Create the signals the Input component will emit
- if (this.sprite.events && this.sprite.events.onInputOver == null)
- {
- this.sprite.events.onInputOver = new Phaser.Signal;
- this.sprite.events.onInputOut = new Phaser.Signal;
- this.sprite.events.onInputDown = new Phaser.Signal;
- this.sprite.events.onInputUp = new Phaser.Signal;
- this.sprite.events.onDragStart = new Phaser.Signal;
- this.sprite.events.onDragStop = new Phaser.Signal;
- }
- }
-
- return this.sprite;
-
- },
-
- /**
- * Description.
- * @method Phaser.InputHandler#reset
- */
- reset: function () {
-
- this.enabled = false;
-
- for (var i = 0; i < 10; i++)
- {
- this._pointerData[i] = {
- id: i,
- x: 0,
- y: 0,
- isDown: false,
- isUp: false,
- isOver: false,
- isOut: false,
- timeOver: 0,
- timeOut: 0,
- timeDown: 0,
- timeUp: 0,
- downDuration: 0,
- isDragged: false
- };
- }
- },
-
- /**
- * Description.
- * @method Phaser.InputHandler#stop
- */
- stop: function () {
-
- // Turning off
- if (this.enabled == false)
- {
- return;
- }
- else
- {
- // De-register, etc
- this.enabled = false;
- this.game.input.interactiveItems.remove(this);
- }
-
- },
-
- /**
- * Clean up memory.
- * @method Phaser.InputHandler#destroy
- */
- destroy: function () {
-
- if (this.enabled)
- {
- this.enabled = false;
-
- this.game.input.interactiveItems.remove(this);
-
- this.stop();
-
- this.sprite = null;
- }
- },
-
- /**
- * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite.
- * This value is only set when the pointer is over this Sprite.
- * @method Phaser.InputHandler#pointerX
- * @param {Pointer} pointer
- * @return {number} The x coordinate of the Input pointer.
- */
- pointerX: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].x;
-
- },
-
- /**
- * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite
- * This value is only set when the pointer is over this Sprite.
- * @method Phaser.InputHandler#pointerY
- * @param {Pointer} pointer
- * @return {number} The y coordinate of the Input pointer.
- */
- pointerY: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].y;
-
- },
-
- /**
- * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
- * @method Phaser.InputHandler#pointerDown
- * @param {Pointer} pointer
- * @return {boolean}
- */
- pointerDown: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].isDown;
-
- },
-
- /**
- * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
- * @method Phaser.InputHandler#pointerUp
- * @param {Pointer} pointer
- * @return {boolean}
- */
- pointerUp: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].isUp;
-
- },
-
- /**
- * A timestamp representing when the Pointer first touched the touchscreen.
- * @method Phaser.InputHandler#pointerTimeDown
- * @param {Pointer} pointer
- * @return {number}
- */
- pointerTimeDown: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].timeDown;
-
- },
-
- /**
- * A timestamp representing when the Pointer left the touchscreen.
- * @method Phaser.InputHandler#pointerTimeUp
- * @param {Pointer} pointer
- * @return {number}
- */
- pointerTimeUp: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].timeUp;
-
- },
-
- /**
- * Is the Pointer over this Sprite?
- * @method Phaser.InputHandler#pointerOver
- * @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers.
- * @return {boolean} True if the given pointer (if a index was given, or any pointer if not) is over this object.
- */
- pointerOver: function (index) {
-
- if (this.enabled)
- {
- if (typeof index === 'undefined')
- {
- for (var i = 0; i < 10; i++)
- {
- if (this._pointerData[i].isOver)
- {
- return true;
- }
- }
- }
- else
- {
- return this._pointerData[index].isOver;
- }
- }
-
- return false;
-
- },
-
- /**
- * Is the Pointer outside of this Sprite?
- * @method Phaser.InputHandler#pointerOut
- * @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers.
- * @return {boolean} True if the given pointer (if a index was given, or any pointer if not) is out of this object.
- */
- pointerOut: function (pointer) {
-
- if (this.enabled)
- {
- if (typeof index === 'undefined')
- {
- for (var i = 0; i < 10; i++)
- {
- if (this._pointerData[i].isOut)
- {
- return true;
- }
- }
- }
- else
- {
- return this._pointerData[index].isOut;
- }
- }
-
- return false;
-
- },
-
- /**
- * A timestamp representing when the Pointer first touched the touchscreen.
- * @method Phaser.InputHandler#pointerTimeOver
- * @param {Pointer} pointer
- * @return {number}
- */
- pointerTimeOver: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].timeOver;
-
- },
-
- /**
- * A timestamp representing when the Pointer left the touchscreen.
- * @method Phaser.InputHandler#pointerTimeOut
- * @param {Pointer} pointer
- * @return {number}
- */
- pointerTimeOut: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].timeOut;
-
- },
-
- /**
- * Is this sprite being dragged by the mouse or not?
- * @method Phaser.InputHandler#pointerTimeOut
- * @param {Pointer} pointer
- * @return {number}
- */
- pointerDragged: function (pointer) {
-
- pointer = pointer || 0;
-
- return this._pointerData[pointer].isDragged;
-
- },
-
- /**
- * Checks if the given pointer is over this Sprite.
- * @method Phaser.InputHandler#checkPointerOver
- * @param {Pointer} pointer
- * @return {boolean}
- */
- checkPointerOver: function (pointer) {
-
- if (this.enabled && this.sprite.visible)
- {
- this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y);
-
- if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.currentFrame.height)
- {
- if (this.pixelPerfect)
- {
- return this.checkPixel(this._tempPoint.x, this._tempPoint.y);
- }
- else
- {
- return true;
- }
- }
- }
-
- return false;
-
- },
-
- /**
- * Runs a pixel perfect check against the given x/y coordinates of the Sprite this InputHandler is bound to.
- * It compares the alpha value of the pixel and if >= InputHandler.pixelPerfectAlpha it returns true.
- * @method Phaser.InputHandler#checkPixel
- * @param {number} x - The x coordinate to check.
- * @param {number} y - The y coordinate to check.
- * @return {boolean} true if there is the alpha of the pixel is >= InputHandler.pixelPerfectAlpha
- */
- checkPixel: function (x, y) {
-
- // Grab a pixel from our image into the hitCanvas and then test it
- if (this.sprite.texture.baseTexture.source)
- {
- this.game.input.hitContext.clearRect(0, 0, 1, 1);
-
- x += this.sprite.texture.frame.x;
- y += this.sprite.texture.frame.y;
-
- this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, x, y, 1, 1, 0, 0, 1, 1);
-
- var rgb = this.game.input.hitContext.getImageData(0, 0, 1, 1);
-
- if (rgb.data[3] >= this.pixelPerfectAlpha)
- {
- return true;
- }
- }
-
- return false;
-
- },
-
- /**
- * Update.
- * @method Phaser.InputHandler#update
- * @param {Pointer} pointer
- */
- update: function (pointer) {
-
- if (this.enabled == false || this.sprite.visible == false || (this.sprite.group && this.sprite.group.visible == false))
- {
- this._pointerOutHandler(pointer);
- return false;
- }
-
- if (this.draggable && this._draggedPointerID == pointer.id)
- {
- return this.updateDrag(pointer);
- }
- else if (this._pointerData[pointer.id].isOver == true)
- {
- if (this.checkPointerOver(pointer))
- {
- this._pointerData[pointer.id].x = pointer.x - this.sprite.x;
- this._pointerData[pointer.id].y = pointer.y - this.sprite.y;
- return true;
- }
- else
- {
- this._pointerOutHandler(pointer);
- return false;
- }
- }
- },
-
- /**
- * Description.
- * @method Phaser.InputHandler#_pointerOverHandler
- * @private
- * @param {Pointer} pointer
- */
- _pointerOverHandler: function (pointer) {
-
- if (this._pointerData[pointer.id].isOver == false)
- {
- this._pointerData[pointer.id].isOver = true;
- this._pointerData[pointer.id].isOut = false;
- this._pointerData[pointer.id].timeOver = this.game.time.now;
- this._pointerData[pointer.id].x = pointer.x - this.sprite.x;
- this._pointerData[pointer.id].y = pointer.y - this.sprite.y;
-
- if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
- {
- this.game.stage.canvas.style.cursor = "pointer";
- }
-
- this.sprite.events.onInputOver.dispatch(this.sprite, pointer);
- }
- },
-
- /**
- * Description.
- * @method Phaser.InputHandler#_pointerOutHandler
- * @private
- * @param {Pointer} pointer
- */
- _pointerOutHandler: function (pointer) {
-
- this._pointerData[pointer.id].isOver = false;
- this._pointerData[pointer.id].isOut = true;
- this._pointerData[pointer.id].timeOut = this.game.time.now;
-
- if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
- {
- this.game.stage.canvas.style.cursor = "default";
- }
-
- if (this.sprite && this.sprite.events)
- {
- this.sprite.events.onInputOut.dispatch(this.sprite, pointer);
- }
-
- },
-
- /**
- * Description.
- * @method Phaser.InputHandler#_touchedHandler
- * @private
- * @param {Pointer} pointer
- */
- _touchedHandler: function (pointer) {
-
- if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true)
- {
- this._pointerData[pointer.id].isDown = true;
- this._pointerData[pointer.id].isUp = false;
- this._pointerData[pointer.id].timeDown = this.game.time.now;
- this.sprite.events.onInputDown.dispatch(this.sprite, pointer);
-
- // Start drag
- if (this.draggable && this.isDragged == false)
- {
- this.startDrag(pointer);
- }
-
- if (this.bringToTop)
- {
- this.sprite.bringToTop();
- }
- }
-
- // Consume the event?
- return this.consumePointerEvent;
-
- },
-
- /**
- * Description.
- * @method Phaser.InputHandler#_releasedHandler
- * @private
- * @param {Pointer} pointer
- */
- _releasedHandler: function (pointer) {
-
- // If was previously touched by this Pointer, check if still is AND still over this item
- if (this._pointerData[pointer.id].isDown && pointer.isUp)
- {
- this._pointerData[pointer.id].isDown = false;
- this._pointerData[pointer.id].isUp = true;
- this._pointerData[pointer.id].timeUp = this.game.time.now;
- this._pointerData[pointer.id].downDuration = this._pointerData[pointer.id].timeUp - this._pointerData[pointer.id].timeDown;
-
- // Only release the InputUp signal if the pointer is still over this sprite
- if (this.checkPointerOver(pointer))
- {
- //console.log('releasedHandler: ' + Date.now());
- this.sprite.events.onInputUp.dispatch(this.sprite, pointer);
- }
- else
- {
- // Pointer outside the sprite? Reset the cursor
- if (this.useHandCursor)
- {
- this.game.stage.canvas.style.cursor = "default";
- }
- }
-
- // Stop drag
- if (this.draggable && this.isDragged && this._draggedPointerID == pointer.id)
- {
- this.stopDrag(pointer);
- }
- }
-
- },
-
- /**
- * Updates the Pointer drag on this Sprite.
- * @method Phaser.InputHandler#updateDrag
- * @param {Pointer} pointer
- * @return {boolean}
- */
- updateDrag: function (pointer) {
-
- if (pointer.isUp)
- {
- this.stopDrag(pointer);
- return false;
- }
-
- if (this.allowHorizontalDrag)
- {
- this.sprite.x = pointer.x + this._dragPoint.x + this.dragOffset.x;
- }
-
- if (this.allowVerticalDrag)
- {
- this.sprite.y = pointer.y + this._dragPoint.y + this.dragOffset.y;
- }
-
- if (this.boundsRect)
- {
- this.checkBoundsRect();
- }
-
- if (this.boundsSprite)
- {
- this.checkBoundsSprite();
- }
-
- if (this.snapOnDrag)
- {
- this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX;
- this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY;
- }
-
- return true;
-
- },
-
- /**
- * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @method Phaser.InputHandler#justOver
- * @param {Pointer} pointer
- * @param {number} delay - The time below which the pointer is considered as just over.
- * @return {boolean}
- */
- justOver: function (pointer, delay) {
-
- pointer = pointer || 0;
- delay = delay || 500;
-
- return (this._pointerData[pointer].isOver && this.overDuration(pointer) < delay);
-
- },
-
- /**
- * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @method Phaser.InputHandler#justOut
- * @param {Pointer} pointer
- * @param {number} delay - The time below which the pointer is considered as just out.
- * @return {boolean}
- */
- justOut: function (pointer, delay) {
-
- pointer = pointer || 0;
- delay = delay || 500;
-
- return (this._pointerData[pointer].isOut && (this.game.time.now - this._pointerData[pointer].timeOut < delay));
-
- },
-
- /**
- * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @method Phaser.InputHandler#justPressed
- * @param {Pointer} pointer
- * @param {number} delay - The time below which the pointer is considered as just over.
- * @return {boolean}
- */
- justPressed: function (pointer, delay) {
-
- pointer = pointer || 0;
- delay = delay || 500;
-
- return (this._pointerData[pointer].isDown && this.downDuration(pointer) < delay);
-
- },
-
- /**
- * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
- * @method Phaser.InputHandler#justReleased
- * @param {Pointer} pointer
- * @param {number} delay - The time below which the pointer is considered as just out.
- * @return {boolean}
- */
- justReleased: function (pointer, delay) {
-
- pointer = pointer || 0;
- delay = delay || 500;
-
- return (this._pointerData[pointer].isUp && (this.game.time.now - this._pointerData[pointer].timeUp < delay));
-
- },
-
- /**
- * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
- * @method Phaser.InputHandler#overDuration
- * @param {Pointer} pointer
- * @return {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over.
- */
- overDuration: function (pointer) {
-
- pointer = pointer || 0;
-
- if (this._pointerData[pointer].isOver)
- {
- return this.game.time.now - this._pointerData[pointer].timeOver;
- }
-
- return -1;
-
- },
-
- /**
- * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
- * @method Phaser.InputHandler#downDuration
- * @param {Pointer} pointer
- * @return {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over.
- */
- downDuration: function (pointer) {
-
- pointer = pointer || 0;
-
- if (this._pointerData[pointer].isDown)
- {
- return this.game.time.now - this._pointerData[pointer].timeDown;
- }
-
- return -1;
-
- },
-
- /**
- * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback
- * @method Phaser.InputHandler#enableDrag
- * @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer.
- * @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group.
- * @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.
- * @param alphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)
- * @param boundsRect If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere
- * @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here
- */
- enableDrag: function (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) {
-
- if (typeof lockCenter == 'undefined') { lockCenter = false; }
- if (typeof bringToTop == 'undefined') { bringToTop = false; }
- if (typeof pixelPerfect == 'undefined') { pixelPerfect = false; }
-
- alphaThreshold = alphaThreshold || 255;
- boundsRect = boundsRect || null;
- boundsSprite = boundsSprite || null;
-
- this._dragPoint = new Phaser.Point();
- this.draggable = true;
- this.bringToTop = bringToTop;
- this.dragOffset = new Phaser.Point();
- this.dragFromCenter = lockCenter;
-
- this.pixelPerfect = pixelPerfect;
- this.pixelPerfectAlpha = alphaThreshold;
-
- if (boundsRect)
- {
- this.boundsRect = boundsRect;
- }
-
- if (boundsSprite)
- {
- this.boundsSprite = boundsSprite;
- }
-
- },
-
- /**
- * Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.
- * @method Phaser.InputHandler#disableDrag
- */
- disableDrag: function () {
-
- if (this._pointerData)
- {
- for (var i = 0; i < 10; i++)
- {
- this._pointerData[i].isDragged = false;
- }
- }
-
- this.draggable = false;
- this.isDragged = false;
- this._draggedPointerID = -1;
-
- },
-
- /**
- * Called by Pointer when drag starts on this Sprite. Should not usually be called directly.
- * @method Phaser.InputHandler#startDrag
- */
- startDrag: function (pointer) {
-
- this.isDragged = true;
- this._draggedPointerID = pointer.id;
- this._pointerData[pointer.id].isDragged = true;
-
- if (this.dragFromCenter)
- {
- this.sprite.centerOn(pointer.x, pointer.y);
- this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
- }
- else
- {
- this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
- }
-
- this.updateDrag(pointer);
-
- if (this.bringToTop)
- {
- this.sprite.bringToTop();
- }
-
- this.sprite.events.onDragStart.dispatch(this.sprite, pointer);
-
- },
-
- /**
- * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.
- * @method Phaser.InputHandler#stopDrag
- */
- stopDrag: function (pointer) {
-
- this.isDragged = false;
- this._draggedPointerID = -1;
- this._pointerData[pointer.id].isDragged = false;
-
- if (this.snapOnRelease)
- {
- this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX;
- this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY;
- }
-
- this.sprite.events.onDragStop.dispatch(this.sprite, pointer);
- this.sprite.events.onInputUp.dispatch(this.sprite, pointer);
-
- if (this.checkPointerOver(pointer) == false)
- {
- this._pointerOutHandler(pointer);
- }
-
- },
-
- /**
- * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!
- * @method Phaser.InputHandler#setDragLock
- * @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false
- * @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false
- */
- setDragLock: function (allowHorizontal, allowVertical) {
-
- if (typeof allowHorizontal == 'undefined') { allowHorizontal = true; }
- if (typeof allowVertical == 'undefined') { allowVertical = true; }
-
- this.allowHorizontalDrag = allowHorizontal;
- this.allowVerticalDrag = allowVertical;
-
- },
-
- /**
- * Make this Sprite snap to the given grid either during drag or when it's released.
- * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels.
- * @method Phaser.InputHandler#enableSnap
- * @param snapX The width of the grid cell in pixels
- * @param snapY The height of the grid cell in pixels
- * @param onDrag If true the sprite will snap to the grid while being dragged
- * @param onRelease If true the sprite will snap to the grid when released
- */
- enableSnap: function (snapX, snapY, onDrag, onRelease) {
-
- if (typeof onDrag == 'undefined') { onDrag = true; }
- if (typeof onRelease == 'undefined') { onRelease = false; }
-
- this.snapX = snapX;
- this.snapY = snapY;
- this.snapOnDrag = onDrag;
- this.snapOnRelease = onRelease;
-
- },
-
- /**
- * Stops the sprite from snapping to a grid during drag or release.
- * @method Phaser.InputHandler#disableSnap
- */
- disableSnap: function () {
-
- this.snapOnDrag = false;
- this.snapOnRelease = false;
-
- },
-
- /**
- * Bounds Rect check for the sprite drag
- * @method Phaser.InputHandler#checkBoundsRect
- */
- checkBoundsRect: function () {
-
- if (this.sprite.x < this.boundsRect.left)
- {
- this.sprite.x = this.boundsRect.x;
- }
- else if ((this.sprite.x + this.sprite.width) > this.boundsRect.right)
- {
- this.sprite.x = this.boundsRect.right - this.sprite.width;
- }
-
- if (this.sprite.y < this.boundsRect.top)
- {
- this.sprite.y = this.boundsRect.top;
- }
- else if ((this.sprite.y + this.sprite.height) > this.boundsRect.bottom)
- {
- this.sprite.y = this.boundsRect.bottom - this.sprite.height;
- }
-
- },
-
- /**
- * Parent Sprite Bounds check for the sprite drag.
- * @method Phaser.InputHandler#checkBoundsSprite
- */
- checkBoundsSprite: function () {
-
- if (this.sprite.x < this.boundsSprite.x)
- {
- this.sprite.x = this.boundsSprite.x;
- }
- else if ((this.sprite.x + this.sprite.width) > (this.boundsSprite.x + this.boundsSprite.width))
- {
- this.sprite.x = (this.boundsSprite.x + this.boundsSprite.width) - this.sprite.width;
- }
-
- if (this.sprite.y < this.boundsSprite.y)
- {
- this.sprite.y = this.boundsSprite.y;
- }
- else if ((this.sprite.y + this.sprite.height) > (this.boundsSprite.y + this.boundsSprite.height))
- {
- this.sprite.y = (this.boundsSprite.y + this.boundsSprite.height) - this.sprite.height;
- }
-
- }
-
-};
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-
-/**
-* The Events component is a collection of events fired by the parent game object and its components.
-*
-* @class Phaser.Events
-* @constructor
-*
-* @param {Phaser.Sprite} sprite - A reference to Description.
-*/
-Phaser.Events = function (sprite) {
-
- this.parent = sprite;
- this.onAddedToGroup = new Phaser.Signal;
- this.onRemovedFromGroup = new Phaser.Signal;
- this.onKilled = new Phaser.Signal;
- this.onRevived = new Phaser.Signal;
- this.onOutOfBounds = new Phaser.Signal;
-
- this.onInputOver = null;
- this.onInputOut = null;
- this.onInputDown = null;
- this.onInputUp = null;
- this.onDragStart = null;
- this.onDragStop = null;
-
- this.onAnimationStart = null;
- this.onAnimationComplete = null;
- this.onAnimationLoop = null;
-
-};
-
-Phaser.Events.prototype = {
-
- destroy: function () {
-
- this.parent = null;
- this.onAddedToGroup.dispose();
- this.onRemovedFromGroup.dispose();
- this.onKilled.dispose();
- this.onRevived.dispose();
- this.onOutOfBounds.dispose();
-
- if (this.onInputOver)
- {
- this.onInputOver.dispose();
- this.onInputOut.dispose();
- this.onInputDown.dispose();
- this.onInputUp.dispose();
- this.onDragStart.dispose();
- this.onDragStop.dispose();
- }
-
- if (this.onAnimationStart)
- {
- this.onAnimationStart.dispose();
- this.onAnimationComplete.dispose();
- this.onAnimationLoop.dispose();
- }
-
- }
-
-};
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* The Game Object Factory is a quick way to create all of the different sorts of core objects that Phaser uses.
-*
-* @class Phaser.GameObjectFactory
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-*/
-Phaser.GameObjectFactory = function (game) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = game;
-
- /**
- * @property {Phaser.World} world - A reference to the game world.
- */
- this.world = this.game.world;
-
-};
-
-Phaser.GameObjectFactory.prototype = {
-
- /**
- * Adds an existing object to the game world.
- * @method Phaser.GameObjectFactory#existing
- * @param {*} object - An instance of Phaser.Sprite, Phaser.Button or any other display object..
- * @return {*} The child that was added to the Group.
- */
- existing: function (object) {
-
- return this.world.add(object);
-
- },
-
- /**
- * Create a new Sprite with specific position and sprite sheet key.
- *
- * @method Phaser.GameObjectFactory#sprite
- * @param {number} x - X position of the new sprite.
- * @param {number} y - Y position of the new sprite.
- * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite 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 the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
- * @returns {Phaser.Sprite} the newly created sprite object.
- */
- sprite: function (x, y, key, frame) {
-
- return this.world.create(x, y, key, frame);
-
- },
-
- /**
- * Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent.
- *
- * @method Phaser.GameObjectFactory#child
- * @param {Phaser.Group} group - The Group to add this child to.
- * @param {number} x - X position of the new sprite.
- * @param {number} y - Y position of the new sprite.
- * @param {string|RenderTexture} [key] - The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture.
- * @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
- * @returns {Phaser.Sprite} the newly created sprite object.
- */
- child: function (group, x, y, key, frame) {
-
- return group.create(x, y, key, frame);
-
- },
-
- /**
- * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
- *
- * @method Phaser.GameObjectFactory#tween
- * @param {object} obj - Object the tween will be run on.
- * @return {Phaser.Tween} Description.
- */
- tween: function (obj) {
-
- return this.game.tweens.create(obj);
-
- },
-
- /**
- * A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
- *
- * @method Phaser.GameObjectFactory#group
- * @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any.
- * @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging.
- * @return {Phaser.Group} The newly created group.
- */
- group: function (parent, name) {
-
- return new Phaser.Group(this.game, parent, name);
-
- },
-
- /**
- * Creates a new instance of the Sound class.
- *
- * @method Phaser.GameObjectFactory#audio
- * @param {string} key - The Game.cache key of the sound that this object will use.
- * @param {number} volume - The volume at which the sound will be played.
- * @param {boolean} loop - Whether or not the sound will loop.
- * @return {Phaser.Sound} The newly created text object.
- */
- audio: function (key, volume, loop) {
-
- return this.game.sound.add(key, volume, loop);
-
- },
-
- /**
- * Creates a new TileSprite.
- *
- * @method Phaser.GameObjectFactory#tileSprite
- * @param {number} x - X position of the new tileSprite.
- * @param {number} y - Y position of the new tileSprite.
- * @param {number} width - the width of the tilesprite.
- * @param {number} height - the height of the tilesprite.
- * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite 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 Sprite 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.
- * @return {Phaser.TileSprite} The newly created tileSprite object.
- */
- tileSprite: function (x, y, width, height, key, frame) {
-
- return this.world.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame));
-
- },
-
- /**
- * Creates a new Text.
- *
- * @method Phaser.GameObjectFactory#text
- * @param {number} x - X position of the new text object.
- * @param {number} y - Y position of the new text object.
- * @param {string} text - The actual text that will be written.
- * @param {object} style - The style object containing style attributes like font, font size , etc.
- * @return {Phaser.Text} The newly created text object.
- */
- text: function (x, y, text, style) {
-
- return this.world.add(new Phaser.Text(this.game, x, y, text, style));
-
- },
-
- /**
- * Creates a new Button object.
- *
- * @method Phaser.GameObjectFactory#button
- * @param {number} [x] X position of the new button object.
- * @param {number} [y] Y position of the new button object.
- * @param {string} [key] The image key as defined in the Game.Cache to use as the texture for this button.
- * @param {function} [callback] The function to call when this button is pressed
- * @param {object} [callbackContext] The context in which the callback will be called (usually 'this')
- * @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
- * @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
- * @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
- * @return {Phaser.Button} The newly created button object.
- */
- button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
-
- return this.world.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
-
- },
-
- /**
- * Creates a new Graphics object.
- *
- * @method Phaser.GameObjectFactory#graphics
- * @param {number} x - X position of the new graphics object.
- * @param {number} y - Y position of the new graphics object.
- * @return {Phaser.Graphics} The newly created graphics object.
- */
- graphics: function (x, y) {
-
- return this.world.add(new Phaser.Graphics(this.game, x, y));
-
- },
-
- /**
- * Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
- * continuous effects like rain and fire. All it really does is launch Particle objects out
- * at set intervals, and fixes their positions and velocities accorindgly.
- *
- * @method Phaser.GameObjectFactory#emitter
- * @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from.
- * @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from.
- * @param {number} [maxParticles=50] - The total number of particles in this emitter.
- * @return {Phaser.Emitter} The newly created emitter object.
- */
- emitter: function (x, y, maxParticles) {
-
- return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles));
-
- },
-
- /**
- * * Create a new BitmapText.
- *
- * @method Phaser.GameObjectFactory#bitmapText
- * @param {number} x - X position of the new bitmapText object.
- * @param {number} y - Y position of the new bitmapText object.
- * @param {string} text - The actual text that will be written.
- * @param {object} style - The style object containing style attributes like font, font size , etc.
- * @return {Phaser.BitmapText} The newly created bitmapText object.
- */
- bitmapText: function (x, y, text, style) {
-
- return this.world.add(new Phaser.BitmapText(this.game, x, y, text, style));
-
- },
-
- /**
- * Creates a new Tilemap object.
- *
- * @method Phaser.GameObjectFactory#tilemap
- * @param {string} key - Asset key for the JSON file.
- * @return {Phaser.Tilemap} The newly created tilemap object.
- */
- tilemap: function (key) {
-
- return new Phaser.Tilemap(this.game, key);
-
- },
-
- /**
- * Creates a new Tileset object.
- *
- * @method Phaser.GameObjectFactory#tileset
- * @param {string} key - The image key as defined in the Game.Cache to use as the tileset.
- * @return {Phaser.Tileset} The newly created tileset object.
- */
- tileset: function (key) {
-
- return this.game.cache.getTileset(key);
-
- },
-
- /**
- * Creates a new Tilemap Layer object.
- *
- * @method Phaser.GameObjectFactory#tilemapLayer
- * @param {number} x - X position of the new tilemapLayer.
- * @param {number} y - Y position of the new tilemapLayer.
- * @param {number} width - the width of the tilemapLayer.
- * @param {number} height - the height of the tilemapLayer.
- * @return {Phaser.TilemapLayer} The newly created tilemaplayer object.
- */
- tilemapLayer: function (x, y, width, height, tileset, tilemap, layer) {
-
- return this.world.add(new Phaser.TilemapLayer(this.game, x, y, width, height, tileset, tilemap, layer));
-
- },
-
- /**
- * A dynamic initially blank canvas to which images can be drawn.
- *
- * @method Phaser.GameObjectFactory#renderTexture
- * @param {string} key - Asset key for the render texture.
- * @param {number} width - the width of the render texture.
- * @param {number} height - the height of the render texture.
- * @return {Phaser.RenderTexture} The newly created renderTexture object.
- */
- renderTexture: function (key, width, height) {
-
- var texture = new Phaser.RenderTexture(this.game, key, width, height);
-
- this.game.cache.addRenderTexture(key, texture);
-
- return texture;
-
- }
-
-};
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Create a new `Sprite` object. Sprites are the lifeblood of your game, used for nearly everything visual.
-* At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas.
-* They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input),
-* events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases.
-*
-* @class Phaser.Sprite
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {number} x - The x coordinate (in world space) to position the Sprite at.
-* @param {number} y - The y coordinate (in world space) to position the Sprite at.
-* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite 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 Sprite 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.Sprite = function (game, x, y, key, frame) {
-
- x = x || 0;
- y = y || 0;
- key = key || null;
- frame = frame || null;
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = game;
-
- /**
- * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
- * @default
- */
- this.exists = true;
-
- /**
- * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
- * @default
- */
- this.alive = true;
-
- /**
- * @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent.
- */
- this.group = null;
-
- /**
- * @property {string} name - The user defined name given to this Sprite.
- * @default
- */
- this.name = '';
-
- /**
- * @property {number} type - The const type of this object.
- * @default
- */
- this.type = Phaser.SPRITE;
-
- /**
- * @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order.
- * @default
- */
- this.renderOrderID = -1;
-
- /**
- * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc.
- * The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.
- * @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed.
- * @default
- */
- this.lifespan = 0;
-
- /**
- * @property {Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components.
- */
- this.events = new Phaser.Events(this);
-
- /**
- * @property {Phaser.AnimationManager} animations - This manages animations of the sprite. You can modify animations through it (see Phaser.AnimationManager)
- */
- this.animations = new Phaser.AnimationManager(this);
-
- /**
- * @property {InputHandler} input - The Input Handler Component.
- */
- this.input = new Phaser.InputHandler(this);
-
- /**
- * @property {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
- */
- this.key = key;
-
- /**
- * @property {Phaser.Frame} currentFrame - A reference to the currently displayed frame.
- */
- this.currentFrame = null;
-
- if (key instanceof Phaser.RenderTexture)
- {
- PIXI.Sprite.call(this, key);
-
- this.currentFrame = this.game.cache.getTextureFrame(key.name);
- }
- else if (key instanceof PIXI.Texture)
- {
- PIXI.Sprite.call(this, key);
-
- this.currentFrame = frame;
- }
- else
- {
- if (key == null || this.game.cache.checkImageKey(key) == false)
- {
- key = '__default';
- this.key = key;
- }
-
- PIXI.Sprite.call(this, PIXI.TextureCache[key]);
-
- if (this.game.cache.isSpriteSheet(key))
- {
- this.animations.loadFrameData(this.game.cache.getFrameData(key));
-
- if (frame !== null)
- {
- if (typeof frame === 'string')
- {
- this.frameName = frame;
- }
- else
- {
- this.frame = frame;
- }
- }
- }
- else
- {
- this.currentFrame = this.game.cache.getFrame(key);
- }
- }
-
- /**
- * The rectangular area from the texture that will be rendered.
- * @property {Phaser.Rectangle} textureRegion
- */
- this.textureRegion = new Phaser.Rectangle(this.texture.frame.x, this.texture.frame.y, this.texture.frame.width, this.texture.frame.height);
-
- /**
- * The anchor sets the origin point of the texture.
- * The default is 0,0 this means the textures origin is the top left
- * Setting than anchor to 0.5,0.5 means the textures origin is centered
- * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
- *
- * @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place.
- */
- this.anchor = new Phaser.Point();
-
- /**
- * @property {number} x - The x coordinate (in world space) of this Sprite.
- */
- this.x = x;
-
- /**
- * @property {number} y - The y coordinate (in world space) of this Sprite.
- */
- this.y = y;
-
- this.position.x = x;
- this.position.y = y;
-
- /**
- * @property {Phaser.Point} world - The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container.
- */
- this.world = new Phaser.Point(x, y);
-
- /**
- * Should this Sprite be automatically culled if out of range of the camera?
- * A culled sprite has its renderable property set to 'false'.
- *
- * @property {boolean} autoCull - A flag indicating if the Sprite should be automatically camera culled or not.
- * @default
- */
- this.autoCull = false;
-
- /**
- * @property {Phaser.Point} scale - The scale of the Sprite when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc.
- */
- this.scale = new Phaser.Point(1, 1);
-
- /**
- * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values.
- * @private
- */
- this._cache = {
-
- dirty: false,
-
- // Transform cache
- a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1,
-
- // Input specific transform cache
- i01: -1, i10: -1, idi: -1,
-
- // Bounds check
- left: null, right: null, top: null, bottom: null,
-
- // delta cache
- prevX: x, prevY: y,
-
- // The previous calculated position
- x: -1, y: -1,
-
- // The actual scale values based on the worldTransform
- scaleX: 1, scaleY: 1,
-
- // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
- width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH,
-
- // The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size
- halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2),
-
- // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
- calcWidth: -1, calcHeight: -1,
-
- // The current frame details
- // frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height,
- frameID: -1, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height,
-
- // If this sprite visible to the camera (regardless of being set to visible or not)
- cameraVisible: true,
-
- // Crop cache
- cropX: 0, cropY: 0, cropWidth: this.currentFrame.sourceSizeW, cropHeight: this.currentFrame.sourceSizeH
-
- };
-
- /**
- * @property {Phaser.Point} offset - Corner point defaults. Should not typically be modified.
- */
- this.offset = new Phaser.Point;
-
- /**
- * @property {Phaser.Point} center - A Point containing the center coordinate of the Sprite. Takes rotation and scale into account.
- */
- this.center = new Phaser.Point(x + Math.floor(this._cache.width / 2), y + Math.floor(this._cache.height / 2));
-
- /**
- * @property {Phaser.Point} topLeft - A Point containing the top left coordinate of the Sprite. Takes rotation and scale into account.
- */
- this.topLeft = new Phaser.Point(x, y);
-
- /**
- * @property {Phaser.Point} topRight - A Point containing the top right coordinate of the Sprite. Takes rotation and scale into account.
- */
- this.topRight = new Phaser.Point(x + this._cache.width, y);
-
- /**
- * @property {Phaser.Point} bottomRight - A Point containing the bottom right coordinate of the Sprite. Takes rotation and scale into account.
- */
- this.bottomRight = new Phaser.Point(x + this._cache.width, y + this._cache.height);
-
- /**
- * @property {Phaser.Point} bottomLeft - A Point containing the bottom left coordinate of the Sprite. Takes rotation and scale into account.
- */
- this.bottomLeft = new Phaser.Point(x, y + this._cache.height);
-
- /**
- * This Rectangle object fully encompasses the Sprite and is updated in real-time.
- * The bounds is the full bounding area after rotation and scale have been taken into account. It should not be modified directly.
- * It's used for Camera culling and physics body alignment.
- * @property {Phaser.Rectangle} bounds
- */
- this.bounds = new Phaser.Rectangle(x, y, this._cache.width, this._cache.height);
-
- /**
- * @property {Phaser.Physics.Arcade.Body} body - By default Sprites have a Phaser.Physics Body attached to them. You can operate physics actions via this property, or null it to skip all physics updates.
- */
- this.body = new Phaser.Physics.Arcade.Body(this);
-
- /**
- * @property {number} health - Health value. Used in combination with damage() to allow for quick killing of Sprites.
- */
- this.health = 1;
-
- /**
- * @property {boolean} inWorld - This value is set to true if the Sprite is positioned within the World, otherwise false.
- */
- this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds);
-
- /**
- * @property {number} inWorldThreshold - A threshold value applied to the inWorld check. If you don't want a Sprite to be considered "out of the world" until at least 100px away for example then set it to 100.
- * @default
- */
- this.inWorldThreshold = 0;
-
- /**
- * @property {boolean} outOfBoundsKill - If true the Sprite is killed as soon as Sprite.inWorld is false.
- * @default
- */
- this.outOfBoundsKill = false;
-
- /**
- * @property {boolean} _outOfBoundsFired - Internal flag.
- * @private
- * @default
- */
- this._outOfBoundsFired = false;
-
- /**
- * A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.
- * @property {boolean} fixedToCamera - Fixes this Sprite to the Camera.
- * @default
- */
- this.fixedToCamera = false;
-
- /**
- * @property {Phaser.Point} cameraOffset - If this Sprite is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
- */
- this.cameraOffset = new Phaser.Point;
-
- /**
- * You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide.
- * The crop is only applied if you have set Sprite.cropEnabled to true.
- * @property {Phaser.Rectangle} crop - The crop Rectangle applied to the Sprite texture before rendering.
- * @default
- */
- this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height);
-
- /**
- * @property {boolean} cropEnabled - If true the Sprite.crop property is used to crop the texture before render. Set to false to disable.
- * @default
- */
- this.cropEnabled = false;
-
- this.updateCache();
- this.updateBounds();
-
-};
-
-// Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly)
-Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype);
-Phaser.Sprite.prototype.constructor = Phaser.Sprite;
-
-/**
-* Automatically called by World.preUpdate. Handles cache updates, lifespan checks, animation updates and physics updates.
-*
-* @method Phaser.Sprite#preUpdate
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.preUpdate = function() {
-
- if (!this.exists)
- {
- this.renderOrderID = -1;
- return;
- }
-
- if (this.lifespan > 0)
- {
- this.lifespan -= this.game.time.elapsed;
-
- if (this.lifespan <= 0)
- {
- this.kill();
- return;
- }
- }
-
- this._cache.dirty = false;
-
- if (this.visible)
- {
- this.renderOrderID = this.game.world.currentRenderOrderID++;
- }
-
- this.updateCache();
-
- this.updateAnimation();
-
- this.updateCrop();
-
- // Re-run the camera visibility check
- if (this._cache.dirty || this.world.x !== this._cache.prevX || this.world.y !== this._cache.prevY)
- {
- this.updateBounds();
- }
-
- if (this.body)
- {
- this.body.preUpdate();
- }
-
-};
-
-/**
-* Internal function called by preUpdate.
-*
-* @method Phaser.Sprite#updateCache
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.updateCache = function() {
-
- this._cache.prevX = this.world.x;
- this._cache.prevY = this.world.y;
-
- if (this.fixedToCamera)
- {
- this.x = this.game.camera.view.x + this.cameraOffset.x;
- this.y = this.game.camera.view.y + this.cameraOffset.y;
- }
-
- this.world.setTo(this.game.camera.x + this.worldTransform[2], this.game.camera.y + this.worldTransform[5]);
-
- if (this.worldTransform[1] != this._cache.i01 || this.worldTransform[3] != this._cache.i10 || this.worldTransform[0] != this._cache.a00 || this.worldTransform[41] != this._cache.a11)
- {
- this._cache.a00 = this.worldTransform[0]; // scaleX a |a c tx|
- this._cache.a01 = this.worldTransform[1]; // skewY c |b d ty|
- this._cache.a10 = this.worldTransform[3]; // skewX b |0 0 1|
- this._cache.a11 = this.worldTransform[4]; // scaleY d
-
- this._cache.i01 = this.worldTransform[1]; // skewY c (remains non-modified for input checks)
- this._cache.i10 = this.worldTransform[3]; // skewX b (remains non-modified for input checks)
-
- this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit?
- this._cache.scaleY = Math.sqrt((this._cache.a10 * this._cache.a10) + (this._cache.a11 * this._cache.a11)); // round this off a bit?
-
- this._cache.a01 *= -1;
- this._cache.a10 *= -1;
-
- this._cache.id = 1 / (this._cache.a00 * this._cache.a11 + this._cache.a01 * -this._cache.a10);
- this._cache.idi = 1 / (this._cache.a00 * this._cache.a11 + this._cache.i01 * -this._cache.i10);
-
- this._cache.dirty = true;
- }
-
- this._cache.a02 = this.worldTransform[2]; // translateX tx
- this._cache.a12 = this.worldTransform[5]; // translateY ty
-
-};
-
-/**
-* Internal function called by preUpdate.
-*
-* @method Phaser.Sprite#updateAnimation
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.updateAnimation = function() {
-
- if (this.animations.update() || (this.currentFrame && this.currentFrame.uuid != this._cache.frameID))
- {
- this._cache.frameID = this.currentFrame.uuid;
-
- this._cache.frameWidth = this.texture.frame.width;
- this._cache.frameHeight = this.texture.frame.height;
-
- this._cache.width = this.currentFrame.width;
- this._cache.height = this.currentFrame.height;
-
- this._cache.halfWidth = Math.floor(this._cache.width / 2);
- this._cache.halfHeight = Math.floor(this._cache.height / 2);
-
- this._cache.dirty = true;
-
- }
-
-};
-
-/**
-* Internal function called by preUpdate.
-*
-* @method Phaser.Sprite#updateCrop
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.updateCrop = function() {
-
- // This only runs if crop is enabled
- if (this.cropEnabled && (this.crop.width != this._cache.cropWidth || this.crop.height != this._cache.cropHeight || this.crop.x != this._cache.cropX || this.crop.y != this._cache.cropY))
- {
- this.crop.floorAll();
-
- this._cache.cropX = this.crop.x;
- this._cache.cropY = this.crop.y;
- this._cache.cropWidth = this.crop.width;
- this._cache.cropHeight = this.crop.height;
-
- this.texture.frame = this.crop;
- this.texture.width = this.crop.width;
- this.texture.height = this.crop.height;
-
- this.texture.updateFrame = true;
-
- PIXI.Texture.frameUpdates.push(this.texture);
- }
-
-};
-
-/**
-* Internal function called by preUpdate.
-*
-* @method Phaser.Sprite#updateBounds
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.updateBounds = function() {
-
- this.offset.setTo(this._cache.a02 - (this.anchor.x * this.width), this._cache.a12 - (this.anchor.y * this.height));
-
- this.getLocalPosition(this.center, this.offset.x + (this.width / 2), this.offset.y + (this.height / 2));
- this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
- this.getLocalPosition(this.topRight, this.offset.x + this.width, this.offset.y);
- this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this.height);
- this.getLocalPosition(this.bottomRight, this.offset.x + this.width, this.offset.y + this.height);
-
- this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
- this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
- this._cache.top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
- this._cache.bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
-
- this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top);
-
- this.updateFrame = true;
-
- if (this.inWorld == false)
- {
- // Sprite WAS out of the screen, is it still?
- this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
-
- if (this.inWorld)
- {
- // It's back again, reset the OOB check
- this._outOfBoundsFired = false;
- }
- }
- else
- {
- // Sprite WAS in the screen, has it now left?
- this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
-
- if (this.inWorld == false)
- {
- this.events.onOutOfBounds.dispatch(this);
- this._outOfBoundsFired = true;
-
- if (this.outOfBoundsKill)
- {
- this.kill();
- }
- }
- }
-
- this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0);
-
- if (this.autoCull)
- {
- // Won't get rendered but will still get its transform updated
- this.renderable = this._cache.cameraVisible;
- }
-
- // Update our physics bounds
- if (this.body)
- {
- this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY);
- }
-
-};
-
-/**
-* Gets the local position of a coordinate relative to the Sprite, factoring in rotation and scale.
-* Mostly only used internally.
-*
-* @method Phaser.Sprite#getLocalPosition
-* @memberof Phaser.Sprite
-* @param {Phaser.Point} p - The Point object to store the results in.
-* @param {number} x - x coordinate within the Sprite to translate.
-* @param {number} y - x coordinate within the Sprite to translate.
-* @param {number} sx - Scale factor to be applied.
-* @param {number} sy - Scale factor to be applied.
-* @return {Phaser.Point} The translated point.
-*/
-Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
-
- p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this.scale.x) + this._cache.a02;
- p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this.scale.y) + this._cache.a12;
-
- return p;
-
-};
-
-/**
-* Gets the local unmodified position of a coordinate relative to the Sprite, factoring in rotation and scale.
-* Mostly only used internally by the Input Manager, but also useful for custom hit detection.
-*
-* @method Phaser.Sprite#getLocalUnmodifiedPosition
-* @memberof Phaser.Sprite
-* @param {Phaser.Point} p - The Point object to store the results in.
-* @param {number} x - x coordinate within the Sprite to translate.
-* @param {number} y - x coordinate within the Sprite to translate.
-* @return {Phaser.Point} The translated point.
-*/
-Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, gx, gy) {
-
- p.x = (this._cache.a11 * this._cache.idi * gx + -this._cache.i01 * this._cache.idi * gy + (this._cache.a12 * this._cache.i01 - this._cache.a02 * this._cache.a11) * this._cache.idi) + (this.anchor.x * this._cache.width);
- p.y = (this._cache.a00 * this._cache.idi * gy + -this._cache.i10 * this._cache.idi * gx + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.i10) * this._cache.idi) + (this.anchor.y * this._cache.height);
-
- return p;
-
-};
-
-/**
-* Resets the Sprite.crop value back to the frame dimensions.
-*
-* @method Phaser.Sprite#resetCrop
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.resetCrop = function() {
-
- this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height);
- this.texture.setFrame(this.crop);
- this.cropEnabled = false;
-
-};
-
-/**
-* Internal function called by the World postUpdate cycle.
-*
-* @method Phaser.Sprite#postUpdate
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.postUpdate = function() {
-
- if (this.exists)
- {
- // The sprite is positioned in this call, after taking into consideration motion updates and collision
- if (this.body)
- {
- this.body.postUpdate();
- }
-
- if (this.fixedToCamera)
- {
- this._cache.x = this.game.camera.view.x + this.cameraOffset.x;
- this._cache.y = this.game.camera.view.y + this.cameraOffset.y;
- }
- else
- {
- this._cache.x = this.x;
- this._cache.y = this.y;
- }
-
- this.world.setTo(this.game.camera.x + this.worldTransform[2], this.game.camera.y + this.worldTransform[5]);
-
- this.position.x = this._cache.x;
- this.position.y = this._cache.y;
- }
-
-};
-
-/**
-* Changes the Texture the Sprite is using entirely. The old texture is removed and the new one is referenced or fetched from the Cache.
-* This causes a WebGL texture update, so use sparingly or in low-intensity portions of your game.
-*
-* @method Phaser.Sprite#loadTexture
-* @memberof Phaser.Sprite
-* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite 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 Sprite 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.Sprite.prototype.loadTexture = function (key, frame) {
-
- this.key = key;
-
- if (key instanceof Phaser.RenderTexture)
- {
- this.currentFrame = this.game.cache.getTextureFrame(key.name);
- }
- else if (key instanceof PIXI.Texture)
- {
- this.currentFrame = frame;
- }
- else
- {
- if (typeof key === 'undefined' || this.game.cache.checkImageKey(key) === false)
- {
- key = '__default';
- this.key = key;
- }
-
- if (this.game.cache.isSpriteSheet(key))
- {
- this.animations.loadFrameData(this.game.cache.getFrameData(key));
-
- if (typeof frame !== 'undefined')
- {
- if (typeof frame === 'string')
- {
- this.frameName = frame;
- }
- else
- {
- this.frame = frame;
- }
- }
- }
- else
- {
- this.currentFrame = this.game.cache.getFrame(key);
- this.setTexture(PIXI.TextureCache[key]);
- }
- }
-
-};
-
-/**
-* Moves the sprite so its center is located on the given x and y coordinates.
-* Doesn't change the anchor point of the sprite.
-*
-* @method Phaser.Sprite#centerOn
-* @memberof Phaser.Sprite
-* @param {number} x - The x coordinate (in world space) to position the Sprite at.
-* @param {number} y - The y coordinate (in world space) to position the Sprite at.
-* @return (Phaser.Sprite) This instance.
-*/
-Phaser.Sprite.prototype.centerOn = function(x, y) {
-
- this.x = x + (this.x - this.center.x);
- this.y = y + (this.y - this.center.y);
- return this;
-
-};
-
-/**
-* Brings a 'dead' Sprite back to life, optionally giving it the health value specified.
-* A resurrected Sprite has its alive, exists and visible properties all set to true.
-* It will dispatch the onRevived event, you can listen to Sprite.events.onRevived for the signal.
-*
-* @method Phaser.Sprite#revive
-* @memberof Phaser.Sprite
-* @param {number} [health=1] - The health to give the Sprite.
-* @return (Phaser.Sprite) This instance.
-*/
-Phaser.Sprite.prototype.revive = function(health) {
-
- if (typeof health === 'undefined') { health = 1; }
-
- this.alive = true;
- this.exists = true;
- this.visible = true;
- this.health = health;
-
- if (this.events)
- {
- this.events.onRevived.dispatch(this);
- }
-
- return this;
-
-};
-
-/**
-* Kills a Sprite. A killed Sprite has its alive, exists and visible properties all set to false.
-* It will dispatch the onKilled event, you can listen to Sprite.events.onKilled for the signal.
-* Note that killing a Sprite is a way for you to quickly recycle it in a Sprite pool, it doesn't free it up from memory.
-* If you don't need this Sprite any more you should call Sprite.destroy instead.
-*
-* @method Phaser.Sprite#kill
-* @memberof Phaser.Sprite
-* @return (Phaser.Sprite) This instance.
-*/
-Phaser.Sprite.prototype.kill = function() {
-
- this.alive = false;
- this.exists = false;
- this.visible = false;
-
- if (this.events)
- {
- this.events.onKilled.dispatch(this);
- }
-
- return this;
-
-};
-
-/**
-* Destroys the Sprite. This removes it from its parent group, destroys the input, event and animation handlers if present
-* and nulls its reference to game, freeing it up for garbage collection.
-*
-* @method Phaser.Sprite#destroy
-* @memberof Phaser.Sprite
-*/
-Phaser.Sprite.prototype.destroy = function() {
-
- if (this.group)
- {
- this.group.remove(this);
- }
-
- if (this.input)
- {
- this.input.destroy();
- }
-
- if (this.events)
- {
- this.events.destroy();
- }
-
- if (this.animations)
- {
- this.animations.destroy();
- }
-
- this.alive = false;
- this.exists = false;
- this.visible = false;
-
- this.game = null;
-
-};
-
-/**
-* Damages the Sprite, this removes the given amount from the Sprites health property.
-* If health is then taken below zero Sprite.kill is called.
-*
-* @method Phaser.Sprite#damage
-* @memberof Phaser.Sprite
-* @param {number} amount - The amount to subtract from the Sprite.health value.
-* @return (Phaser.Sprite) This instance.
-*/
-Phaser.Sprite.prototype.damage = function(amount) {
-
- if (this.alive)
- {
- this.health -= amount;
-
- if (this.health < 0)
- {
- this.kill();
- }
- }
-
- return this;
-
-};
-
-/**
-* Resets the Sprite. This places the Sprite at the given x/y world coordinates and then
-* sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state and health values.
-* If the Sprite has a physics body that too is reset.
-*
-* @method Phaser.Sprite#reset
-* @memberof Phaser.Sprite
-* @param {number} x - The x coordinate (in world space) to position the Sprite at.
-* @param {number} y - The y coordinate (in world space) to position the Sprite at.
-* @param {number} [health=1] - The health to give the Sprite.
-* @return (Phaser.Sprite) This instance.
-*/
-Phaser.Sprite.prototype.reset = function(x, y, health) {
-
- if (typeof health === 'undefined') { health = 1; }
-
- this.x = x;
- this.y = y;
- this.position.x = this.x;
- this.position.y = this.y;
- this.alive = true;
- this.exists = true;
- this.visible = true;
- this.renderable = true;
- this._outOfBoundsFired = false;
-
- this.health = health;
-
- if (this.body)
- {
- this.body.reset();
- }
-
- return this;
-
-};
-
-/**
-* Brings the Sprite to the top of the display list it is a child of. Sprites that are members of a Phaser.Group are only
-* bought to the top of that Group, not the entire display list.
-*
-* @method Phaser.Sprite#bringToTop
-* @memberof Phaser.Sprite
-* @return (Phaser.Sprite) This instance.
-*/
-Phaser.Sprite.prototype.bringToTop = function() {
-
- if (this.group)
- {
- this.group.bringToTop(this);
- }
- else
- {
- this.game.world.bringToTop(this);
- }
-
- return this;
-
-};
-
-/**
-* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add()
-* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.
-*
-* @method Phaser.Sprite#play
-* @memberof Phaser.Sprite
-* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump".
-* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
-* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
-* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
-* @return {Phaser.Animation} A reference to playing Animation instance.
-*/
-Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete) {
-
- if (this.animations)
- {
- return this.animations.play(name, frameRate, loop, killOnComplete);
- }
-
-};
-
-/**
-* Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
-* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
-* If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
-* @name Phaser.Sprite#angle
-* @property {number} angle - Gets or sets the Sprites angle of rotation in degrees.
-*/
-Object.defineProperty(Phaser.Sprite.prototype, 'angle', {
-
- get: function() {
- return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
- },
-
- set: function(value) {
- this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
- }
-
-});
-
-/**
-* @name Phaser.Sprite#frame
-* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
-*/
-Object.defineProperty(Phaser.Sprite.prototype, "frame", {
-
- get: function () {
- return this.animations.frame;
- },
-
- set: function (value) {
- this.animations.frame = value;
- }
-
-});
-
-/**
-* @name Phaser.Sprite#frameName
-* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display.
-*/
-Object.defineProperty(Phaser.Sprite.prototype, "frameName", {
-
- get: function () {
- return this.animations.frameName;
- },
-
- set: function (value) {
- this.animations.frameName = value;
- }
-
-});
-
-/**
-* @name Phaser.Sprite#inCamera
-* @property {boolean} inCamera - Is this sprite visible to the camera or not?
-* @readonly
-*/
-Object.defineProperty(Phaser.Sprite.prototype, "inCamera", {
-
- get: function () {
- return this._cache.cameraVisible;
- }
-
-});
-
-/**
-* The width of the sprite in pixels, setting this will actually modify the scale to acheive the value desired.
-* If you wish to crop the Sprite instead see the Sprite.crop value.
-*
-* @name Phaser.Sprite#width
-* @property {number} width - The width of the Sprite in pixels.
-*/
-Object.defineProperty(Phaser.Sprite.prototype, 'width', {
-
- get: function() {
- return this.scale.x * this.currentFrame.width;
- },
-
- set: function(value) {
-
- this.scale.x = value / this.currentFrame.width;
- this._cache.scaleX = value / this.currentFrame.width;
- this._width = value;
-
- }
-
-});
-
-/**
-* The height of the sprite in pixels, setting this will actually modify the scale to acheive the value desired.
-* If you wish to crop the Sprite instead see the Sprite.crop value.
-*
-* @name Phaser.Sprite#height
-* @property {number} height - The height of the Sprite in pixels.
-*/
-Object.defineProperty(Phaser.Sprite.prototype, 'height', {
-
- get: function() {
- return this.scale.y * this.currentFrame.height;
- },
-
- set: function(value) {
-
- this.scale.y = value / this.currentFrame.height;
- this._cache.scaleY = value / this.currentFrame.height;
- this._height = value;
-
- }
-
-});
-
-/**
-* By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
-* activated for this Sprite instance and it will then start to process click/touch events and more.
-*
-* @name Phaser.Sprite#inputEnabled
-* @property {boolean} inputEnabled - Set to true to allow this Sprite to receive input events, otherwise false.
-*/
-Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
-
- get: function () {
-
- return (this.input.enabled);
-
- },
-
- set: function (value) {
-
- if (value)
- {
- if (this.input.enabled == false)
- {
- this.input.start();
- }
- }
- else
- {
- if (this.input.enabled)
- {
- this.input.stop();
- }
- }
-
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Create a new TileSprite.
-* @class Phaser.Tilemap
-* @constructor
-* @param {Phaser.Game} game - Current game instance.
-* @param {number} x - X position of the new tileSprite.
-* @param {number} y - Y position of the new tileSprite.
-* @param {number} width - the width of the tilesprite.
-* @param {number} height - the height of the tilesprite.
-* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite 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 Sprite 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.TileSprite = function (game, x, y, width, height, key, frame) {
-
- x = x || 0;
- y = y || 0;
- width = width || 256;
- height = height || 256;
- key = key || null;
- frame = frame || null;
-
- Phaser.Sprite.call(this, game, x, y, key, frame);
-
- /**
- * @property {Description} texture - Description.
- */
- this.texture = PIXI.TextureCache[key];
-
- PIXI.TilingSprite.call(this, this.texture, width, height);
-
- /**
- * @property {Description} type - Description.
- */
- this.type = Phaser.TILESPRITE;
-
- /**
- * @property {Point} tileScale - The scaling of the image that is being tiled.
- */
- this.tileScale = new Phaser.Point(1, 1);
-
- /**
- * @property {Point} tilePosition - The offset position of the image that is being tiled.
- */
- this.tilePosition = new Phaser.Point(0, 0);
-
-};
-
-Phaser.TileSprite.prototype = Phaser.Utils.extend(true, PIXI.TilingSprite.prototype, Phaser.Sprite.prototype);
-Phaser.TileSprite.prototype.constructor = Phaser.TileSprite;
-
-// Add our own custom methods
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Create a new Text.
-* @class Phaser.Text
-* @constructor
-* @param {Phaser.Game} game - Current game instance.
-* @param {number} x - X position of the new text object.
-* @param {number} y - Y position of the new text object.
-* @param {string} text - The actual text that will be written.
-* @param {object} style - The style object containing style attributes like font, font size ,
-*/
-Phaser.Text = function (game, x, y, text, style) {
-
- x = x || 0;
- y = y || 0;
- text = text || '';
- style = style || '';
-
- // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
- /**
- * @property {boolean} exists - Description.
- * @default
- */
- this.exists = true;
-
- // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
- /**
- * @property {boolean} alive - Description.
- * @default
- */
- this.alive = true;
-
- /**
- * @property {Description} group - Description.
- * @default
- */
- this.group = null;
-
- /**
- * @property {string} name - Description.
- * @default
- */
- this.name = '';
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = game;
-
- this._text = text;
- this._style = style;
-
- PIXI.Text.call(this, text, style);
-
- /**
- * @property {Description} type - Description.
- */
- this.type = Phaser.TEXT;
-
- /**
- * @property {Description} position - Description.
- */
- this.position.x = this.x = x;
- this.position.y = this.y = y;
-
- // Replaces the PIXI.Point with a slightly more flexible one
- /**
- * @property {Phaser.Point} anchor - Description.
- */
- this.anchor = new Phaser.Point();
-
- /**
- * @property {Phaser.Point} scale - Description.
- */
- this.scale = new Phaser.Point(1, 1);
-
- // A mini cache for storing all of the calculated values
- /**
- * @property {Description} _cache - Description.
- * @private
- */
- this._cache = {
-
- dirty: false,
-
- // Transform cache
- a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1,
-
- // The previous calculated position
- x: -1, y: -1,
-
- // The actual scale values based on the worldTransform
- scaleX: 1, scaleY: 1
-
- };
-
- this._cache.x = this.x;
- this._cache.y = this.y;
-
- /**
- * @property {boolean} renderable - Description.
- */
- this.renderable = true;
-
-};
-
-Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
-Phaser.Text.prototype.constructor = Phaser.Text;
-
-/**
-* Automatically called by World.update.
-* @method Phaser.Text.prototype.update
-*/
-Phaser.Text.prototype.update = function() {
-
- if (!this.exists)
- {
- return;
- }
-
- this._cache.dirty = false;
-
- this._cache.x = this.x;
- this._cache.y = this.y;
-
- if (this.position.x != this._cache.x || this.position.y != this._cache.y)
- {
- this.position.x = this._cache.x;
- this.position.y = this._cache.y;
- this._cache.dirty = true;
- }
-
-}
-
-/**
-* @method Phaser.Text.prototype.destroy
-*/
-Phaser.Text.prototype.destroy = function() {
-
- if (this.group)
- {
- this.group.remove(this);
- }
-
- if (this.canvas.parentNode)
- {
- this.canvas.parentNode.removeChild(this.canvas);
- }
- else
- {
- this.canvas = null;
- this.context = null;
- }
-
- this.exists = false;
-
- this.group = null;
-
-}
-
-/**
-* Get
-* @returns {Description}
-*//**
-* Set
-* @param {Description} value - Description
-*/
-Object.defineProperty(Phaser.Text.prototype, 'angle', {
-
- get: function() {
- return Phaser.Math.radToDeg(this.rotation);
- },
-
- set: function(value) {
- this.rotation = Phaser.Math.degToRad(value);
- }
-
-});
-
-Object.defineProperty(Phaser.Text.prototype, 'content', {
-
- get: function() {
- return this._text;
- },
-
- set: function(value) {
-
- // Let's not update unless needed, this way we can safely update the text in a core loop without constant re-draws
- if (value !== this._text)
- {
- this._text = value;
- this.setText(value);
- }
-
- }
-
-});
-
-Object.defineProperty(Phaser.Text.prototype, 'font', {
-
- get: function() {
- return this._style;
- },
-
- set: function(value) {
-
- // Let's not update unless needed, this way we can safely update the text in a core loop without constant re-draws
- if (value !== this._style)
- {
- this._style = value;
- this.setStyle(value);
- }
-
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Creates a new `BitmapText` object. BitmapText work by taking a texture file and an XML file that describes the font layout.
-* On Windows you can use the free app BMFont: http://www.angelcode.com/products/bmfont/
-* On OS X we recommend Glyph Designer: http://www.71squared.com/en/glyphdesigner
-*
-* @class Phaser.BitmapText
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {number} x - X position of the new bitmapText object.
-* @param {number} y - Y position of the new bitmapText object.
-* @param {string} text - The actual text that will be written.
-* @param {object} style - The style object containing style attributes like font, font size , etc.
-*/
-Phaser.BitmapText = function (game, x, y, text, style) {
-
- x = x || 0;
- y = y || 0;
-
- text = text || '';
- style = style || '';
-
- /**
- * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
- * @default
- */
- this.exists = true;
-
- /**
- * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
- * @default
- */
- this.alive = true;
-
- /**
- * @property {Description} group - Description.
- * @default
- */
- this.group = null;
-
- /**
- * @property {string} name - Description.
- * @default
- */
- this.name = '';
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running Game.
- */
- this.game = game;
-
- PIXI.BitmapText.call(this, text, style);
-
- /**
- * @property {Description} type - Description.
- */
- this.type = Phaser.BITMAPTEXT;
-
- /**
- * @property {number} position.x - Description.
- */
- this.position.x = x;
-
- /**
- * @property {number} position.y - Description.
- */
- this.position.y = y;
-
- // Replaces the PIXI.Point with a slightly more flexible one
- /**
- * @property {Phaser.Point} anchor - Description.
- */
- this.anchor = new Phaser.Point();
-
- /**
- * @property {Phaser.Point} scale - Description.
- */
- this.scale = new Phaser.Point(1, 1);
-
- // A mini cache for storing all of the calculated values
- /**
- * @property {function} _cache - Description.
- * @private
- */
- this._cache = {
-
- dirty: false,
-
- // Transform cache
- a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1,
-
- // The previous calculated position
- x: -1, y: -1,
-
- // The actual scale values based on the worldTransform
- scaleX: 1, scaleY: 1
-
- };
-
- this._cache.x = this.x;
- this._cache.y = this.y;
-
- /**
- * @property {boolean} renderable - Description.
- * @private
- */
- this.renderable = true;
-
-};
-
-Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
-// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
-Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
-
-/**
-* Automatically called by World.update
-* @method Phaser.BitmapText.prototype.update
-*/
-Phaser.BitmapText.prototype.update = function() {
-
- if (!this.exists)
- {
- return;
- }
-
- this._cache.dirty = false;
-
- this._cache.x = this.x;
- this._cache.y = this.y;
-
- if (this.position.x != this._cache.x || this.position.y != this._cache.y)
- {
- this.position.x = this._cache.x;
- this.position.y = this._cache.y;
- this._cache.dirty = true;
- }
-
- this.pivot.x = this.anchor.x*this.width;
- this.pivot.y = this.anchor.y*this.height;
-
-}
-
-/**
-* @method Phaser.Text.prototype.destroy
-*/
-Phaser.BitmapText.prototype.destroy = function() {
-
- if (this.group)
- {
- this.group.remove(this);
- }
-
- if (this.canvas && this.canvas.parentNode)
- {
- this.canvas.parentNode.removeChild(this.canvas);
- }
- else
- {
- this.canvas = null;
- this.context = null;
- }
-
- this.exists = false;
-
- this.group = null;
-
-}
-
-/**
-* Get
-* @returns {Description}
-*//**
-* Set
-* @param {Description} value - Description
-*/
-Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
-
- get: function() {
- return Phaser.Math.radToDeg(this.rotation);
- },
-
- set: function(value) {
- this.rotation = Phaser.Math.degToRad(value);
- }
-
-});
-
-/**
-* Get
-* @returns {Description}
-*//**
-* Set
-* @param {Description} value - Description
-*/
-Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
-
- get: function() {
- return this.position.x;
- },
-
- set: function(value) {
- this.position.x = value;
- }
-
-});
-
-/**
-* Get
-* @returns {Description}
-*//**
-* Set
-* @param {Description} value - Description
-*/
-Object.defineProperty(Phaser.BitmapText.prototype, 'y', {
-
- get: function() {
- return this.position.y;
- },
-
- set: function(value) {
- this.position.y = value;
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Create a new `Button` object. A Button is a special type of Sprite that is set-up to handle Pointer events automatically. The four states a Button responds to are:
-* 'Over' - when the Pointer moves over the Button. This is also commonly known as 'hover'.
-* 'Out' - when the Pointer that was previously over the Button moves out of it.
-* 'Down' - when the Pointer is pressed down on the Button. I.e. touched on a touch enabled device or clicked with the mouse.
-* 'Up' - when the Pointer that was pressed down on the Button is released again.
-* You can set a unique texture frame and Sound for any of these states.
-*
-* @class Phaser.Button
-* @constructor
-*
-* @param {Phaser.Game} game Current game instance.
-* @param {number} [x] - X position of the Button.
-* @param {number} [y] - Y position of the Button.
-* @param {string} [key] - The image key as defined in the Game.Cache to use as the texture for this Button.
-* @param {function} [callback] - The function to call when this Button is pressed.
-* @param {object} [callbackContext] - The context in which the callback will be called (usually 'this').
-* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
-* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
-* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
-*/
-Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
-
- x = x || 0;
- y = y || 0;
- key = key || null;
- callback = callback || null;
- callbackContext = callbackContext || this;
-
- Phaser.Sprite.call(this, game, x, y, key, outFrame);
-
- /**
- * @property {number} type - The Phaser Object Type.
- */
- this.type = Phaser.BUTTON;
-
- /**
- * @property {string} _onOverFrameName - Internal variable.
- * @private
- * @default
- */
- this._onOverFrameName = null;
-
- /**
- * @property {string} _onOutFrameName - Internal variable.
- * @private
- * @default
- */
- this._onOutFrameName = null;
-
- /**
- * @property {string} _onDownFrameName - Internal variable.
- * @private
- * @default
- */
- this._onDownFrameName = null;
-
- /**
- * @property {string} _onUpFrameName - Internal variable.
- * @private
- * @default
- */
- this._onUpFrameName = null;
-
- /**
- * @property {number} _onOverFrameID - Internal variable.
- * @private
- * @default
- */
- this._onOverFrameID = null;
-
- /**
- * @property {number} _onOutFrameID - Internal variable.
- * @private
- * @default
- */
- this._onOutFrameID = null;
-
- /**
- * @property {number} _onDownFrameID - Internal variable.
- * @private
- * @default
- */
- this._onDownFrameID = null;
-
- /**
- * @property {number} _onUpFrameID - Internal variable.
- * @private
- * @default
- */
- this._onUpFrameID = null;
-
- /**
- * @property {Phaser.Sound} onOverSound - The Sound to be played when this Buttons Over state is activated.
- * @default
- */
- this.onOverSound = null;
-
- /**
- * @property {Phaser.Sound} onOutSound - The Sound to be played when this Buttons Out state is activated.
- * @default
- */
- this.onOutSound = null;
-
- /**
- * @property {Phaser.Sound} onDownSound - The Sound to be played when this Buttons Down state is activated.
- * @default
- */
- this.onDownSound = null;
-
- /**
- * @property {Phaser.Sound} onUpSound - The Sound to be played when this Buttons Up state is activated.
- * @default
- */
- this.onUpSound = null;
-
- /**
- * @property {string} onOverSoundMarker - The Sound Marker used in conjunction with the onOverSound.
- * @default
- */
- this.onOverSoundMarker = '';
-
- /**
- * @property {string} onOutSoundMarker - The Sound Marker used in conjunction with the onOutSound.
- * @default
- */
- this.onOutSoundMarker = '';
-
- /**
- * @property {string} onDownSoundMarker - The Sound Marker used in conjunction with the onDownSound.
- * @default
- */
- this.onDownSoundMarker = '';
-
- /**
- * @property {string} onUpSoundMarker - The Sound Marker used in conjunction with the onUpSound.
- * @default
- */
- this.onUpSoundMarker = '';
-
- /**
- * @property {Phaser.Signal} onInputOver - The Signal (or event) dispatched when this Button is in an Over state.
- */
- this.onInputOver = new Phaser.Signal;
-
- /**
- * @property {Phaser.Signal} onInputOut - The Signal (or event) dispatched when this Button is in an Out state.
- */
- this.onInputOut = new Phaser.Signal;
-
- /**
- * @property {Phaser.Signal} onInputDown - The Signal (or event) dispatched when this Button is in an Down state.
- */
- this.onInputDown = new Phaser.Signal;
-
- /**
- * @property {Phaser.Signal} onInputUp - The Signal (or event) dispatched when this Button is in an Up state.
- */
- this.onInputUp = new Phaser.Signal;
-
- /**
- * @property {boolean} freezeFrames - When true the Button will cease to change texture frame on all events (over, out, up, down).
- */
- this.freezeFrames = false;
-
- /**
- * When the Button is clicked you can optionally force the state to "out".
- * @property {boolean} forceOut
- * @default
- */
- this.forceOut = true;
-
- this.setFrames(overFrame, outFrame, downFrame);
-
- if (callback !== null)
- {
- this.onInputUp.add(callback, callbackContext);
- }
-
- this.input.start(0, true);
-
- // Redirect the input events to here so we can handle animation updates, etc
- this.events.onInputOver.add(this.onInputOverHandler, this);
- this.events.onInputOut.add(this.onInputOutHandler, this);
- this.events.onInputDown.add(this.onInputDownHandler, this);
- this.events.onInputUp.add(this.onInputUpHandler, this);
-
-};
-
-Phaser.Button.prototype = Object.create(Phaser.Sprite.prototype);
-Phaser.Button.prototype = Phaser.Utils.extend(true, Phaser.Button.prototype, Phaser.Sprite.prototype, PIXI.Sprite.prototype);
-Phaser.Button.prototype.constructor = Phaser.Button;
-
-/**
-* Used to manually set the frames that will be used for the different states of the button
-* exactly like setting them in the constructor.
-*
-* @method Phaser.Button.prototype.setFrames
-* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
-* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
-* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
-*/
-Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
-
- if (overFrame !== null)
- {
- if (typeof overFrame === 'string')
- {
- this._onOverFrameName = overFrame;
-
- if (this.input.pointerOver())
- {
- this.frameName = overFrame;
- }
- }
- else
- {
- this._onOverFrameID = overFrame;
-
- if (this.input.pointerOver())
- {
- this.frame = overFrame;
- }
- }
- }
-
- if (outFrame !== null)
- {
- if (typeof outFrame === 'string')
- {
- this._onOutFrameName = outFrame;
- this._onUpFrameName = outFrame;
-
- if (this.input.pointerOver() == false)
- {
- this.frameName = outFrame;
- }
- }
- else
- {
- this._onOutFrameID = outFrame;
- this._onUpFrameID = outFrame;
-
- if (this.input.pointerOver() == false)
- {
- this.frame = outFrame;
- }
- }
- }
-
- if (downFrame !== null)
- {
- if (typeof downFrame === 'string')
- {
- this._onDownFrameName = downFrame;
-
- if (this.input.pointerDown())
- {
- this.frameName = downFrame;
- }
- }
- else
- {
- this._onDownFrameID = downFrame;
-
- if (this.input.pointerDown())
- {
- this.frame = downFrame;
- }
- }
- }
-
-};
-
-/**
-* Sets the sounds to be played whenever this Button is interacted with. Sounds can be either full Sound objects, or markers pointing to a section of a Sound object.
-* The most common forms of sounds are 'hover' effects and 'click' effects, which is why the order of the parameters is overSound then downSound.
-* Call this function with no parameters at all to reset all sounds on this Button.
-*
-* @method Phaser.Button.prototype.setSounds
-* @param {Phaser.Sound} [overSound] - Over Button Sound.
-* @param {string} [overMarker] - Over Button Sound Marker.
-* @param {Phaser.Sound} [downSound] - Down Button Sound.
-* @param {string} [downMarker] - Down Button Sound Marker.
-* @param {Phaser.Sound} [outSound] - Out Button Sound.
-* @param {string} [outMarker] - Out Button Sound Marker.
-* @param {Phaser.Sound} [upSound] - Up Button Sound.
-* @param {string} [upMarker] - Up Button Sound Marker.
-*/
-Phaser.Button.prototype.setSounds = function (overSound, overMarker, downSound, downMarker, outSound, outMarker, upSound, upMarker) {
-
- this.setOverSound(overSound, overMarker);
- this.setOutSound(outSound, outMarker);
- this.setUpSound(upSound, upMarker);
- this.setDownSound(downSound, downMarker);
-
-}
-
-/**
-* The Sound to be played when a Pointer moves over this Button.
-*
-* @method Phaser.Button.prototype.setOverSound
-* @param {Phaser.Sound} sound - The Sound that will be played.
-* @param {string} [marker] - A Sound Marker that will be used in the playback.
-*/
-Phaser.Button.prototype.setOverSound = function (sound, marker) {
-
- this.onOverSound = null;
- this.onOverSoundMarker = '';
-
- if (sound instanceof Phaser.Sound)
- {
- this.onOverSound = sound;
- }
-
- if (typeof marker === 'string')
- {
- this.onOverSoundMarker = marker;
- }
-
-}
-
-/**
-* The Sound to be played when a Pointer moves out of this Button.
-*
-* @method Phaser.Button.prototype.setOutSound
-* @param {Phaser.Sound} sound - The Sound that will be played.
-* @param {string} [marker] - A Sound Marker that will be used in the playback.
-*/
-Phaser.Button.prototype.setOutSound = function (sound, marker) {
-
- this.onOutSound = null;
- this.onOutSoundMarker = '';
-
- if (sound instanceof Phaser.Sound)
- {
- this.onOutSound = sound;
- }
-
- if (typeof marker === 'string')
- {
- this.onOutSoundMarker = marker;
- }
-
-}
-
-/**
-* The Sound to be played when a Pointer clicks on this Button.
-*
-* @method Phaser.Button.prototype.setUpSound
-* @param {Phaser.Sound} sound - The Sound that will be played.
-* @param {string} [marker] - A Sound Marker that will be used in the playback.
-*/
-Phaser.Button.prototype.setUpSound = function (sound, marker) {
-
- this.onUpSound = null;
- this.onUpSoundMarker = '';
-
- if (sound instanceof Phaser.Sound)
- {
- this.onUpSound = sound;
- }
-
- if (typeof marker === 'string')
- {
- this.onUpSoundMarker = marker;
- }
-
-}
-
-/**
-* The Sound to be played when a Pointer clicks on this Button.
-*
-* @method Phaser.Button.prototype.setDownSound
-* @param {Phaser.Sound} sound - The Sound that will be played.
-* @param {string} [marker] - A Sound Marker that will be used in the playback.
-*/
-Phaser.Button.prototype.setDownSound = function (sound, marker) {
-
- this.onDownSound = null;
- this.onDownSoundMarker = '';
-
- if (sound instanceof Phaser.Sound)
- {
- this.onDownSound = sound;
- }
-
- if (typeof marker === 'string')
- {
- this.onDownSoundMarker = marker;
- }
-
-}
-
-/**
-* Internal function that handles input events.
-*
-* @protected
-* @method Phaser.Button.prototype.onInputOverHandler
-* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
-*/
-Phaser.Button.prototype.onInputOverHandler = function (pointer) {
-
- if (this.freezeFrames == false)
- {
- if (this._onOverFrameName != null)
- {
- this.frameName = this._onOverFrameName;
- }
- else if (this._onOverFrameID != null)
- {
- this.frame = this._onOverFrameID;
- }
- }
-
- if (this.onOverSound)
- {
- this.onOverSound.play(this.onOverSoundMarker);
- }
-
- if (this.onInputOver)
- {
- this.onInputOver.dispatch(this, pointer);
- }
-};
-
-/**
-* Internal function that handles input events.
-*
-* @protected
-* @method Phaser.Button.prototype.onInputOverHandler
-* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
-*/
-Phaser.Button.prototype.onInputOutHandler = function (pointer) {
-
- if (this.freezeFrames == false)
- {
- if (this._onOutFrameName != null)
- {
- this.frameName = this._onOutFrameName;
- }
- else if (this._onOutFrameID != null)
- {
- this.frame = this._onOutFrameID;
- }
- }
-
- if (this.onOutSound)
- {
- this.onOutSound.play(this.onOutSoundMarker);
- }
-
- if (this.onInputOut)
- {
- this.onInputOut.dispatch(this, pointer);
- }
-};
-
-/**
-* Internal function that handles input events.
-*
-* @protected
-* @method Phaser.Button.prototype.onInputOverHandler
-* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
-*/
-Phaser.Button.prototype.onInputDownHandler = function (pointer) {
-
- if (this.freezeFrames == false)
- {
- if (this._onDownFrameName != null)
- {
- this.frameName = this._onDownFrameName;
- }
- else if (this._onDownFrameID != null)
- {
- this.frame = this._onDownFrameID;
- }
- }
-
- if (this.onDownSound)
- {
- this.onDownSound.play(this.onDownSoundMarker);
- }
-
- if (this.onInputDown)
- {
- this.onInputDown.dispatch(this, pointer);
- }
-};
-
-/**
-* Internal function that handles input events.
-*
-* @protected
-* @method Phaser.Button.prototype.onInputOverHandler
-* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
-*/
-Phaser.Button.prototype.onInputUpHandler = function (pointer) {
-
- if (this.freezeFrames == false)
- {
- if (this._onUpFrameName != null)
- {
- this.frameName = this._onUpFrameName;
- }
- else if (this._onUpFrameID != null)
- {
- this.frame = this._onUpFrameID;
- }
- }
-
- if (this.onUpSound)
- {
- this.onUpSound.play(this.onUpSoundMarker);
- }
-
- if (this.forceOut && this.freezeFrames == false)
- {
- if (this._onOutFrameName != null)
- {
- this.frameName = this._onOutFrameName;
- }
- else if (this._onOutFrameID != null)
- {
- this.frame = this._onOutFrameID;
- }
- }
-
- if (this.onInputUp)
- {
- this.onInputUp.dispatch(this, pointer);
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Creates a new Graphics object.
-*
-* @class Phaser.Graphics
-* @constructor
-*
-* @param {Phaser.Game} game Current game instance.
-* @param {number} x - X position of the new graphics object.
-* @param {number} y - Y position of the new graphics object.
-*/
-Phaser.Graphics = function (game, x, y) {
-
- this.game = game;
-
- PIXI.Graphics.call(this);
-
- /**
- * @property {Description} type - Description.
- */
- this.type = Phaser.GRAPHICS;
-
-};
-
-Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype);
-Phaser.Graphics.prototype.constructor = Phaser.Graphics;
-
-// Add our own custom methods
-
-/**
-* Description.
-*
-* @method Phaser.Sprite.prototype.destroy
-*/
-Phaser.Graphics.prototype.destroy = function() {
-
- this.clear();
-
- if (this.group)
- {
- this.group.remove(this);
- }
-
- this.game = null;
-
-}
-
-/*
-* Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled
-*/
-Phaser.Graphics.prototype.drawPolygon = function (poly) {
-
- graphics.moveTo(poly.points[0].x, poly.points[0].y);
- for (var i = 1; i < poly.points.length; i += 1) {
- graphics.lineTo(poly.points[i].x, poly.points[i].y);
- }
- graphics.lineTo(poly.points[0].x, poly.points[0].y);
-}
-
-Object.defineProperty(Phaser.Graphics.prototype, 'angle', {
-
- get: function() {
- return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
- },
-
- set: function(value) {
- this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
- }
-
-});
-
-Object.defineProperty(Phaser.Graphics.prototype, 'x', {
-
- get: function() {
- return this.position.x;
- },
-
- set: function(value) {
- this.position.x = value;
- }
-
-});
-
-Object.defineProperty(Phaser.Graphics.prototype, 'y', {
-
- get: function() {
- return this.position.y;
- },
-
- set: function(value) {
- this.position.y = value;
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* A dynamic initially blank canvas to which images can be drawn
-* @class Phaser.RenderTexture
-* @constructor
-* @param {Phaser.Game} game - Current game instance.
-* @param {string} key - Asset key for the render texture.
-* @param {number} width - the width of the render texture.
-* @param {number} height - the height of the render texture.
-*/
-Phaser.RenderTexture = function (game, key, width, height) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = game;
-
- /**
- * @property {string} name - the name of the object.
- */
- this.name = key;
-
- PIXI.EventTarget.call( this );
-
- /**
- * @property {number} width - the width.
- */
- this.width = width || 100;
-
- /**
- * @property {number} height - the height.
- */
- this.height = height || 100;
-
- /**
- * I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it
- * once they update pixi to fix the typo, we'll fix it here too :)
- * @property {Description} indetityMatrix - Description.
- */
- this.indetityMatrix = PIXI.mat3.create();
-
- /**
- * @property {Description} frame - Description.
- */
- this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
-
- /**
- * @property {Description} type - Description.
- */
- this.type = Phaser.RENDERTEXTURE;
-
- if (PIXI.gl)
- {
- this.initWebGL();
- }
- else
- {
- this.initCanvas();
- }
-
-};
-
-Phaser.RenderTexture.prototype = Phaser.Utils.extend(true, PIXI.RenderTexture.prototype);
-Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture;
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
-*
-* @class Phaser.Canvas
-* @static
-*/
-Phaser.Canvas = {
-
- /**
- * Creates the <canvas> tag
- *
- * @method Phaser.Canvas.create
- * @param {number} width - The desired width.
- * @param {number} height - The desired height.
- * @return {HTMLCanvasElement} The newly created <canvas> tag.
- */
- create: function (width, height) {
-
- width = width || 256;
- height = height || 256;
-
- var canvas = document.createElement('canvas');
- canvas.width = width;
- canvas.height = height;
- canvas.style.display = 'block';
-
- return canvas;
-
- },
-
- /**
- * Get the DOM offset values of any given element
- * @method Phaser.Canvas.getOffset
- * @param {HTMLElement} element - The targeted element that we want to retrieve the offset.
- * @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset.
- * @return {Phaser.Point} - A point objet with the offsetX and Y as its properties.
- */
- getOffset: function (element, point) {
-
- point = point || new Phaser.Point;
-
- var box = element.getBoundingClientRect();
- var clientTop = element.clientTop || document.body.clientTop || 0;
- var clientLeft = element.clientLeft || document.body.clientLeft || 0;
- var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
- var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
-
- point.x = box.left + scrollLeft - clientLeft;
- point.y = box.top + scrollTop - clientTop;
-
- return point;
-
- },
-
- /**
- * Returns the aspect ratio of the given canvas.
- *
- * @method Phaser.Canvas.getAspectRatio
- * @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from.
- * @return {number} The ratio between canvas' width and height.
- */
- getAspectRatio: function (canvas) {
- return canvas.width / canvas.height;
- },
-
- /**
- * Sets the background color behind the canvas. This changes the canvas style property.
- *
- * @method Phaser.Canvas.setBackgroundColor
- * @param {HTMLCanvasElement} canvas - The canvas to set the background color on.
- * @param {string} [color] - The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- setBackgroundColor: function (canvas, color) {
-
- color = color || 'rgb(0,0,0)';
-
- canvas.style.backgroundColor = color;
-
- return canvas;
-
- },
-
- /**
- * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
- *
- * @method Phaser.Canvas.setTouchAction
- * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
- * @param {String} [value] - The touch action to set. Defaults to 'none'.
- * @return {HTMLCanvasElement} The source canvas.
- */
- setTouchAction: function (canvas, value) {
-
- value = value || 'none';
-
- canvas.style.msTouchAction = value;
- canvas.style['ms-touch-action'] = value;
- canvas.style['touch-action'] = value;
-
- return canvas;
-
- },
-
- /**
- * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.
- *
- * @method Phaser.Canvas.setUserSelect
- * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
- * @param {String} [value] - The touch action to set. Defaults to 'none'.
- * @return {HTMLCanvasElement} The source canvas.
- */
- setUserSelect: function (canvas, value) {
-
- value = value || 'none';
-
- canvas.style['-webkit-touch-callout'] = value;
- canvas.style['-webkit-user-select'] = value;
- canvas.style['-khtml-user-select'] = value;
- canvas.style['-moz-user-select'] = value;
- canvas.style['-ms-user-select'] = value;
- canvas.style['user-select'] = value;
- canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)';
-
- return canvas;
-
- },
-
- /**
- * Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent.
- * If no parent is given it will be added as a child of the document.body.
- *
- * @method Phaser.Canvas.addToDOM
- * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
- * @param {string} parent - The DOM element to add the canvas to. Defaults to ''.
- * @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- addToDOM: function (canvas, parent, overflowHidden) {
-
- parent = parent || '';
-
- if (typeof overflowHidden === 'undefined') { overflowHidden = true; }
-
- if (parent !== '')
- {
- if (document.getElementById(parent))
- {
- document.getElementById(parent).appendChild(canvas);
-
- if (overflowHidden)
- {
- document.getElementById(parent).style.overflow = 'hidden';
- }
- }
- else
- {
- document.body.appendChild(canvas);
- }
- }
- else
- {
- document.body.appendChild(canvas);
- }
-
- return canvas;
-
- },
-
- /**
- * Sets the transform of the given canvas to the matrix values provided.
- *
- * @method Phaser.Canvas.setTransform
- * @param {CanvasRenderingContext2D} context - The context to set the transform on.
- * @param {number} translateX - The value to translate horizontally by.
- * @param {number} translateY - The value to translate vertically by.
- * @param {number} scaleX - The value to scale horizontally by.
- * @param {number} scaleY - The value to scale vertically by.
- * @param {number} skewX - The value to skew horizontaly by.
- * @param {number} skewY - The value to skew vertically by.
- * @return {CanvasRenderingContext2D} Returns the source context.
- */
- setTransform: function (context, translateX, translateY, scaleX, scaleY, skewX, skewY) {
-
- context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
-
- return context;
-
- },
-
- /**
- * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing.
- * By default browsers have image smoothing enabled, which isn't always what you visually want, especially
- * when using pixel art in a game. Note that this sets the property on the context itself, so that any image
- * drawn to the context will be affected. This sets the property across all current browsers but support is
- * patchy on earlier browsers, especially on mobile.
- *
- * @method Phaser.Canvas.setSmoothingEnabled
- * @param {CanvasRenderingContext2D} context - The context to enable or disable the image smoothing on.
- * @param {boolean} value - If set to true it will enable image smoothing, false will disable it.
- * @return {CanvasRenderingContext2D} Returns the source context.
- */
- setSmoothingEnabled: function (context, value) {
-
- context['imageSmoothingEnabled'] = value;
- context['mozImageSmoothingEnabled'] = value;
- context['oImageSmoothingEnabled'] = value;
- context['webkitImageSmoothingEnabled'] = value;
- context['msImageSmoothingEnabled'] = value;
-
- return context;
-
- },
-
- /**
- * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast on webkit').
- * Note that if this doesn't given the desired result then see the setSmoothingEnabled.
- *
- * @method Phaser.Canvas.setImageRenderingCrisp
- * @param {HTMLCanvasElement} canvas - The canvas to set image-rendering crisp on.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- setImageRenderingCrisp: function (canvas) {
-
- canvas.style['image-rendering'] = 'crisp-edges';
- canvas.style['image-rendering'] = '-moz-crisp-edges';
- canvas.style['image-rendering'] = '-webkit-optimize-contrast';
- canvas.style.msInterpolationMode = 'nearest-neighbor';
-
- return canvas;
-
- },
-
- /**
- * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto').
- * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.
- *
- * @method Phaser.Canvas.setImageRenderingBicubic
- * @param {HTMLCanvasElement} canvas The canvas to set image-rendering bicubic on.
- * @return {HTMLCanvasElement} Returns the source canvas.
- */
- setImageRenderingBicubic: function (canvas) {
-
- canvas.style['image-rendering'] = 'auto';
- canvas.style.msInterpolationMode = 'bicubic';
-
- return canvas;
-
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* An Animation instance contains a single animation and the controls to play it.
-* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
-*
-* @class Phaser.StageScaleMode
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-* @param {number} width - Description.
-* @param {number} height - Description.
-*/
-Phaser.StageScaleMode = function (game, width, height) {
-
- /**
- * @property {Phaser.Game} game - A reference to the currently running game.
- */
- this.game = game;
-
- /**
- * @property {number} width - Width of the stage after calculation.
- */
- this.width = width;
-
- /**
- * @property {number} height - Height of the stage after calculation.
- */
- this.height = height;
-
- /**
- * @property {number} minWidth - Minimum width the canvas should be scaled to (in pixels).
- * @default
- */
- this.minWidth = null;
-
- /**
- * @property {number} maxWidth - Maximum width the canvas should be scaled to (in pixels).
- * If null it will scale to whatever width the browser can handle.
- * @default
- */
- this.maxWidth = null;
-
- /**
- * @property {number} minHeight - Minimum height the canvas should be scaled to (in pixels).
- * @default
- */
- this.minHeight = null;
-
- /**
- * @property {number} maxHeight - Maximum height the canvas should be scaled to (in pixels).
- * If null it will scale to whatever height the browser can handle.
- * @default
- */
- this.maxHeight = null;
-
- /**
- * @property {number} _startHeight - Stage height when starting the game.
- * @default
- * @private
- */
- this._startHeight = 0;
-
- /**
- * @property {boolean} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage
- * @default
- */
- this.forceLandscape = false;
-
- /**
- * @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage
- * @default
- */
- this.forcePortrait = false;
-
- /**
- * @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.
- * @default
- */
- this.incorrectOrientation = false;
-
- /**
- * @property {boolean} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true.
- * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
- * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
- * @default
- */
- this.pageAlignHorizontally = false;
-
- /**
- * @property {boolean} pageAlignVertically - If you wish to align your game in the middle of the page then you can set this value to true.
- * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
- * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
- * @default
- */
- this.pageAlignVertically = false;
-
- /**
- * @property {number} _width - Cached stage width for full screen mode.
- * @default
- * @private
- */
- this._width = 0;
-
- /**
- * @property {number} _height - Cached stage height for full screen mode.
- * @default
- * @private
- */
- this._height = 0;
-
- /**
- * @property {number} maxIterations - The maximum number of times it will try to resize the canvas to fill the browser.
- * @default
- */
- this.maxIterations = 5;
-
-
- /**
- * @property {PIXI.Sprite} orientationSprite - The Sprite that is optionally displayed if the browser enters an unsupported orientation.
- * @default
- */
- this.orientationSprite = null;
-
- /**
- * @property {Phaser.Signal} enterLandscape - The event that is dispatched when the browser enters landscape orientation.
- */
- this.enterLandscape = new Phaser.Signal();
-
- /**
- * @property {Phaser.Signal} enterPortrait - The event that is dispatched when the browser enters horizontal orientation.
- */
- this.enterPortrait = new Phaser.Signal();
-
- if (window['orientation'])
- {
- this.orientation = window['orientation'];
- }
- else
- {
- if (window.outerWidth > window.outerHeight)
- {
- this.orientation = 90;
- }
- else
- {
- this.orientation = 0;
- }
- }
-
- /**
- * @property {Phaser.Point} scaleFactor - The scale factor based on the game dimensions vs. the scaled dimensions.
- */
- this.scaleFactor = new Phaser.Point(1, 1);
-
- /**
- * @property {number} aspectRatio - Aspect ratio.
- * @default
- */
- this.aspectRatio = 0;
-
- var _this = this;
-
- window.addEventListener('orientationchange', function (event) {
- return _this.checkOrientation(event);
- }, false);
-
- window.addEventListener('resize', function (event) {
- return _this.checkResize(event);
- }, false);
-
- document.addEventListener('webkitfullscreenchange', function (event) {
- return _this.fullScreenChange(event);
- }, false);
-
- document.addEventListener('mozfullscreenchange', function (event) {
- return _this.fullScreenChange(event);
- }, false);
-
- document.addEventListener('fullscreenchange', function (event) {
- return _this.fullScreenChange(event);
- }, false);
-
-};
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.StageScaleMode.EXACT_FIT = 0;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.StageScaleMode.NO_SCALE = 1;
-
-/**
-* @constant
-* @type {number}
-*/
-Phaser.StageScaleMode.SHOW_ALL = 2;
-
-Phaser.StageScaleMode.prototype = {
-
- /**
- * Tries to enter the browser into full screen mode.
- * Please note that this needs to be supported by the web browser and isn't the same thing as setting your game to fill the browser.
- * @method Phaser.StageScaleMode#startFullScreen
- * @param {boolean} antialias - You can toggle the anti-alias feature of the canvas before jumping in to full screen (false = retain pixel art, true = smooth art)
- */
- startFullScreen: function (antialias) {
-
- if (this.isFullScreen)
- {
- return;
- }
-
- if (typeof antialias !== 'undefined')
- {
- Phaser.Canvas.setSmoothingEnabled(this.game.context, antialias);
- }
-
- var element = this.game.canvas;
-
- this._width = this.width;
- this._height = this.height;
-
- console.log('startFullScreen', this._width, this._height);
-
- if (element['requestFullScreen'])
- {
- element['requestFullScreen']();
- }
- else if (element['mozRequestFullScreen'])
- {
- element['mozRequestFullScreen']();
- }
- else if (element['webkitRequestFullScreen'])
- {
- element['webkitRequestFullScreen'](Element.ALLOW_KEYBOARD_INPUT);
- }
-
- },
-
- /**
- * Stops full screen mode if the browser is in it.
- * @method Phaser.StageScaleMode#stopFullScreen
- */
- stopFullScreen: function () {
-
- if (document['cancelFullScreen'])
- {
- document['cancelFullScreen']();
- }
- else if (document['mozCancelFullScreen'])
- {
- document['mozCancelFullScreen']();
- }
- else if (document['webkitCancelFullScreen'])
- {
- document['webkitCancelFullScreen']();
- }
-
- },
-
- /**
- * Called automatically when the browser enters of leaves full screen mode.
- * @method Phaser.StageScaleMode#fullScreenChange
- * @param {Event} event - The fullscreenchange event
- * @protected
- */
- fullScreenChange: function (event) {
-
- if (this.isFullScreen)
- {
- this.game.stage.canvas.style['width'] = '100%';
- this.game.stage.canvas.style['height'] = '100%';
-
- this.setMaximum();
-
- this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height);
-
- this.aspectRatio = this.width / this.height;
- this.scaleFactor.x = this.game.width / this.width;
- this.scaleFactor.y = this.game.height / this.height;
- }
- else
- {
- this.game.stage.canvas.style['width'] = this.game.width + 'px';
- this.game.stage.canvas.style['height'] = this.game.height + 'px';
-
- this.width = this._width;
- this.height = this._height;
-
- this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height);
-
- this.aspectRatio = this.width / this.height;
- this.scaleFactor.x = this.game.width / this.width;
- this.scaleFactor.y = this.game.height / this.height;
- }
-
- },
-
- /**
- * If you need your game to run in only one orientation you can force that to happen.
- * The optional orientationImage is displayed when the game is in the incorrect orientation.
- * @method Phaser.StageScaleMode#forceOrientation
- * @param {boolean} forceLandscape - true if the game should run in landscape mode only.
- * @param {boolean} forcePortrait - true if the game should run in portrait mode only.
- * @param {string} [forcePortrait=''] - The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation.
- */
- forceOrientation: function (forceLandscape, forcePortrait, orientationImage) {
-
- this.forceLandscape = forceLandscape;
-
- if (typeof forcePortrait === 'undefined')
- {
- this.forcePortrait = false;
- }
-
- if (typeof orientationImage !== 'undefined')
- {
- if (orientationImage == null || this.game.cache.checkImageKey(orientationImage) == false)
- {
- orientationImage = '__default';
- }
-
- this.orientationSprite = new PIXI.Sprite(PIXI.TextureCache[orientationImage]);
- this.orientationSprite.anchor.x = 0.5;
- this.orientationSprite.anchor.y = 0.5;
- this.orientationSprite.position.x = this.game.width / 2;
- this.orientationSprite.position.y = this.game.height / 2;
-
- this.checkOrientationState();
-
- if (this.incorrectOrientation)
- {
- this.orientationSprite.visible = true;
- this.game.world.visible = false;
- }
- else
- {
- this.orientationSprite.visible = false;
- this.game.world.visible = true;
- }
-
- this.game.stage._stage.addChild(this.orientationSprite);
- }
-
- },
-
- /**
- * Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set)
- * @method Phaser.StageScaleMode#checkOrientationState
- */
- checkOrientationState: function () {
-
- // They are in the wrong orientation
- if (this.incorrectOrientation)
- {
- if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth))
- {
- // Back to normal
- this.game.paused = false;
- this.incorrectOrientation = false;
-
- if (this.orientationSprite)
- {
- this.orientationSprite.visible = false;
- this.game.world.visible = true;
- }
-
- this.refresh();
- }
- }
- else
- {
- if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth))
- {
- // Show orientation screen
- this.game.paused = true;
- this.incorrectOrientation = true;
-
- if (this.orientationSprite && this.orientationSprite.visible == false)
- {
- this.orientationSprite.visible = true;
- this.game.world.visible = false;
- }
-
- this.refresh();
- }
- }
- },
-
- /**
- * Handle window.orientationchange events
- * @method Phaser.StageScaleMode#checkOrientation
- * @param {Event} event - The orientationchange event data.
- */
- checkOrientation: function (event) {
-
- this.orientation = window['orientation'];
-
- if (this.isLandscape)
- {
- this.enterLandscape.dispatch(this.orientation, true, false);
- }
- else
- {
- this.enterPortrait.dispatch(this.orientation, false, true);
- }
-
- if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE)
- {
- this.refresh();
- }
-
- },
-
- /**
- * Handle window.resize events
- * @method Phaser.StageScaleMode#checkResize
- * @param {Event} event - The resize event data.
- */
- checkResize: function (event) {
-
- if (window.outerWidth > window.outerHeight)
- {
- this.orientation = 90;
- }
- else
- {
- this.orientation = 0;
- }
-
- if (this.isLandscape)
- {
- this.enterLandscape.dispatch(this.orientation, true, false);
- }
- else
- {
- this.enterPortrait.dispatch(this.orientation, false, true);
- }
-
- if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE)
- {
- this.refresh();
- }
-
- this.checkOrientationState();
-
- },
-
- /**
- * Re-calculate scale mode and update screen size.
- * @method Phaser.StageScaleMode#refresh
- */
- refresh: function () {
-
- var _this = this;
-
- // We can't do anything about the status bars in iPads, web apps or desktops
- if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false)
- {
- // document.documentElement['style'].minHeight = '2000px';
- // this._startHeight = window.innerHeight;
-
- if (this.game.device.android && this.game.device.chrome == false)
- {
- window.scrollTo(0, 1);
- }
- else
- {
- window.scrollTo(0, 0);
- }
- }
-
- if (this._check == null && this.maxIterations > 0)
- {
- this._iterations = this.maxIterations;
- this._check = window.setInterval(function () {
- return _this.setScreenSize();
- }, 10);
- this.setScreenSize();
- }
-
- },
-
- /**
- * Set screen size automatically based on the scaleMode.
- * @param {boolean} force - If force is true it will try to resize the game regardless of the document dimensions.
- */
- setScreenSize: function (force) {
-
- if (typeof force == 'undefined')
- {
- force = false;
- }
-
- if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false)
- {
- if (this.game.device.android && this.game.device.chrome == false)
- {
- window.scrollTo(0, 1);
- }
- else
- {
- window.scrollTo(0, 0);
- }
- }
-
- this._iterations--;
-
- if (force || window.innerHeight > this._startHeight || this._iterations < 0)
- {
- // Set minimum height of content to new window height
- document.documentElement['style'].minHeight = window.innerHeight + 'px';
-
- if (this.incorrectOrientation == true)
- {
- this.setMaximum();
- }
- else if (this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT)
- {
- this.setExactFit();
- }
- else if (this.game.stage.scaleMode == Phaser.StageScaleMode.SHOW_ALL)
- {
- this.setShowAll();
- }
-
- this.setSize();
- clearInterval(this._check);
- this._check = null;
- }
-
- },
-
- /**
- * Sets the canvas style width and height values based on minWidth/Height and maxWidth/Height.
- * @method Phaser.StageScaleMode#setSize
- */
- setSize: function () {
-
- if (this.incorrectOrientation == false)
- {
- if (this.maxWidth && this.width > this.maxWidth)
- {
- this.width = this.maxWidth;
- }
-
- if (this.maxHeight && this.height > this.maxHeight)
- {
- this.height = this.maxHeight;
- }
-
- if (this.minWidth && this.width < this.minWidth)
- {
- this.width = this.minWidth;
- }
-
- if (this.minHeight && this.height < this.minHeight)
- {
- this.height = this.minHeight;
- }
- }
-
- this.game.canvas.style.width = this.width + 'px';
- this.game.canvas.style.height = this.height + 'px';
-
- this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height);
-
- if (this.pageAlignHorizontally)
- {
- if (this.width < window.innerWidth && this.incorrectOrientation == false)
- {
- this.game.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px';
- }
- else
- {
- this.game.canvas.style.marginLeft = '0px';
- }
- }
-
- if (this.pageAlignVertically)
- {
- if (this.height < window.innerHeight && this.incorrectOrientation == false)
- {
- this.game.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px';
- }
- else
- {
- this.game.canvas.style.marginTop = '0px';
- }
- }
-
- Phaser.Canvas.getOffset(this.game.canvas, this.game.stage.offset);
-
- this.aspectRatio = this.width / this.height;
-
- this.scaleFactor.x = this.game.width / this.width;
- this.scaleFactor.y = this.game.height / this.height;
-
- this.checkOrientationState();
-
- },
-
- /**
- * Sets this.width equal to window.innerWidth and this.height equal to window.innerHeight
- * @method Phaser.StageScaleMode#setMaximum
- */
- setMaximum: function () {
-
- this.width = window.innerWidth;
- this.height = window.innerHeight;
-
- },
-
- /**
- * Calculates the multiplier needed to scale the game proportionally.
- * @method Phaser.StageScaleMode#setShowAll
- */
- setShowAll: function () {
-
- var multiplier = Math.min((window.innerHeight / this.game.height), (window.innerWidth / this.game.width));
-
- this.width = Math.round(this.game.width * multiplier);
- this.height = Math.round(this.game.height * multiplier);
-
- },
-
- /**
- * Sets the width and height values of the canvas, no larger than the maxWidth/Height.
- * @method Phaser.StageScaleMode#setExactFit
- */
- setExactFit: function () {
-
- var availableWidth = window.innerWidth;
- var availableHeight = window.innerHeight;
-
- // console.log('available', availableWidth, availableHeight);
-
- if (this.maxWidth && availableWidth > this.maxWidth)
- {
- this.width = this.maxWidth;
- }
- else
- {
- this.width = availableWidth;
- }
-
- if (this.maxHeight && availableHeight > this.maxHeight)
- {
- this.height = this.maxHeight;
- }
- else
- {
- this.height = availableHeight;
- }
-
- }
-
-};
-
-/**
-* @name Phaser.StageScaleMode#isFullScreen
-* @property {boolean} isFullScreen - Returns true if the browser is in full screen mode, otherwise false.
-* @readonly
-*/
-Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", {
-
- get: function () {
-
- return (document['fullscreenElement'] || document['mozFullScreenElement'] || document['webkitFullscreenElement'])
-
- }
-
-});
-
-/**
-* @name Phaser.StageScaleMode#isPortrait
-* @property {boolean} isPortrait - Returns true if the browser dimensions match a portrait display.
-* @readonly
-*/
-Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", {
-
- get: function () {
- return this.orientation == 0 || this.orientation == 180;
- }
-
-});
-
-/**
-* @name Phaser.StageScaleMode#isLandscape
-* @property {boolean} isLandscape - Returns true if the browser dimensions match a landscape display.
-* @readonly
-*/
-Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", {
-
- get: function () {
- return this.orientation === 90 || this.orientation === -90;
- }
-
-});
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr
-*
-* @class Phaser.Device
-* @constructor
-*/
-
-Phaser.Device = function () {
-
- /**
- * An optional 'fix' for the horrendous Android stock browser bug https://code.google.com/p/android/issues/detail?id=39247
- * @property {boolean} patchAndroidClearRectBug - Description.
- * @default
- */
- this.patchAndroidClearRectBug = false;
-
- // Operating System
-
- /**
- * @property {boolean} desktop - Is running desktop?
- * @default
- */
- this.desktop = false;
-
- /**
- * @property {boolean} iOS - Is running on iOS?
- * @default
- */
- this.iOS = false;
-
- /**
- * @property {boolean} android - Is running on android?
- * @default
- */
- this.android = false;
-
- /**
- * @property {boolean} chromeOS - Is running on chromeOS?
- * @default
- */
- this.chromeOS = false;
-
- /**
- * @property {boolean} linux - Is running on linux?
- * @default
- */
- this.linux = false;
-
- /**
- * @property {boolean} macOS - Is running on macOS?
- * @default
- */
- this.macOS = false;
-
- /**
- * @property {boolean} windows - Is running on windows?
- * @default
- */
- this.windows = false;
-
- // Features
-
- /**
- * @property {boolean} canvas - Is canvas available?
- * @default
- */
- this.canvas = false;
-
- /**
- * @property {boolean} file - Is file available?
- * @default
- */
- this.file = false;
-
- /**
- * @property {boolean} fileSystem - Is fileSystem available?
- * @default
- */
- this.fileSystem = false;
-
- /**
- * @property {boolean} localStorage - Is localStorage available?
- * @default
- */
- this.localStorage = false;
-
- /**
- * @property {boolean} webGL - Is webGL available?
- * @default
- */
- this.webGL = false;
-
- /**
- * @property {boolean} worker - Is worker available?
- * @default
- */
- this.worker = false;
-
- /**
- * @property {boolean} touch - Is touch available?
- * @default
- */
- this.touch = false;
-
- /**
- * @property {boolean} mspointer - Is mspointer available?
- * @default
- */
- this.mspointer = false;
-
- /**
- * @property {boolean} css3D - Is css3D available?
- * @default
- */
- this.css3D = false;
-
- /**
- * @property {boolean} pointerLock - Is Pointer Lock available?
- * @default
- */
- this.pointerLock = false;
-
- // Browser
-
- /**
- * @property {boolean} arora - Is running in arora?
- * @default
- */
- this.arora = false;
-
- /**
- * @property {boolean} chrome - Is running in chrome?
- * @default
- */
- this.chrome = false;
-
- /**
- * @property {boolean} epiphany - Is running in epiphany?
- * @default
- */
- this.epiphany = false;
-
- /**
- * @property {boolean} firefox - Is running in firefox?
- * @default
- */
- this.firefox = false;
-
- /**
- * @property {boolean} ie - Is running in ie?
- * @default
- */
- this.ie = false;
-
- /**
- * @property {number} ieVersion - Version of ie?
- * @default
- */
- this.ieVersion = 0;
-
- /**
- * @property {boolean} mobileSafari - Is running in mobileSafari?
- * @default
- */
- this.mobileSafari = false;
-
- /**
- * @property {boolean} midori - Is running in midori?
- * @default
- */
- this.midori = false;
-
- /**
- * @property {boolean} opera - Is running in opera?
- * @default
- */
- this.opera = false;
-
- /**
- * @property {boolean} safari - Is running in safari?
- * @default
- */
- this.safari = false;
- this.webApp = false;
-
- // Audio
-
- /**
- * @property {boolean} audioData - Are Audio tags available?
- * @default
- */
- this.audioData = false;
-
- /**
- * @property {boolean} webAudio - Is the WebAudio API available?
- * @default
- */
- this.webAudio = false;
-
- /**
- * @property {boolean} ogg - Can this device play ogg files?
- * @default
- */
- this.ogg = false;
-
- /**
- * @property {boolean} opus - Can this device play opus files?
- * @default
- */
- this.opus = false;
-
- /**
- * @property {boolean} mp3 - Can this device play mp3 files?
- * @default
- */
- this.mp3 = false;
-
- /**
- * @property {boolean} wav - Can this device play wav files?
- * @default
- */
- this.wav = false;
- /**
- * Can this device play m4a files?
- * @property {boolean} m4a - True if this device can play m4a files.
- * @default
- */
- this.m4a = false;
-
- /**
- * @property {boolean} webm - Can this device play webm files?
- * @default
- */
- this.webm = false;
-
- // Device
-
- /**
- * @property {boolean} iPhone - Is running on iPhone?
- * @default
- */
- this.iPhone = false;
-
- /**
- * @property {boolean} iPhone4 - Is running on iPhone4?
- * @default
- */
- this.iPhone4 = false;
-
- /**
- * @property {boolean} iPad - Is running on iPad?
- * @default
- */
- this.iPad = false;
-
- /**
- * @property {number} pixelRatio - PixelRatio of the host device?
- * @default
- */
- this.pixelRatio = 0;
-
- // Run the checks
- this._checkAudio();
- this._checkBrowser();
- this._checkCSS3D();
- this._checkDevice();
- this._checkFeatures();
- this._checkOS();
-
-};
-
-Phaser.Device.prototype = {
-
- /**
- * Check which OS is game running on.
- * @method Phaser.Device#_checkOS
- * @private
- */
- _checkOS: function () {
-
- var ua = navigator.userAgent;
-
- if (/Android/.test(ua)) {
- this.android = true;
- } else if (/CrOS/.test(ua)) {
- this.chromeOS = true;
- } else if (/iP[ao]d|iPhone/i.test(ua)) {
- this.iOS = true;
- } else if (/Linux/.test(ua)) {
- this.linux = true;
- } else if (/Mac OS/.test(ua)) {
- this.macOS = true;
- } else if (/Windows/.test(ua)) {
- this.windows = true;
- }
-
- if (this.windows || this.macOS || this.linux) {
- this.desktop = true;
- }
-
- },
-
- /**
- * Check HTML5 features of the host environment.
- * @method Phaser.Device#_checkFeatures
- * @private
- */
- _checkFeatures: function () {
-
- this.canvas = !!window['CanvasRenderingContext2D'];
-
- try {
- this.localStorage = !!localStorage.getItem;
- } catch (error) {
- this.localStorage = false;
- }
-
- this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob'];
- this.fileSystem = !!window['requestFileSystem'];
- this.webGL = ( function () { try { var canvas = document.createElement( 'canvas' ); return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ); } catch( e ) { return false; } } )();
-
- if (this.webGL === null || this.webGL === false)
- {
- this.webGL = false;
- }
- else
- {
- this.webGL = true;
- }
-
- this.worker = !!window['Worker'];
-
- if ('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled) {
- this.touch = true;
- }
-
- if (window.navigator.msPointerEnabled) {
- this.mspointer = true;
- }
-
- this.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document;
-
- },
-
- /**
- * Check what browser is game running in.
- * @method Phaser.Device#_checkBrowser
- * @private
- */
- _checkBrowser: function () {
-
- var ua = navigator.userAgent;
-
- if (/Arora/.test(ua)) {
- this.arora = true;
- } else if (/Chrome/.test(ua)) {
- this.chrome = true;
- } else if (/Epiphany/.test(ua)) {
- this.epiphany = true;
- } else if (/Firefox/.test(ua)) {
- this.firefox = true;
- } else if (/Mobile Safari/.test(ua)) {
- this.mobileSafari = true;
- } else if (/MSIE (\d+\.\d+);/.test(ua)) {
- this.ie = true;
- this.ieVersion = parseInt(RegExp.$1);
- } else if (/Midori/.test(ua)) {
- this.midori = true;
- } else if (/Opera/.test(ua)) {
- this.opera = true;
- } else if (/Safari/.test(ua)) {
- this.safari = true;
- }
-
- // WebApp mode in iOS
- if (navigator['standalone']) {
- this.webApp = true;
- }
-
- },
-
- /**
- * Check audio support.
- * @method Phaser.Device#_checkAudio
- * @private
- */
- _checkAudio: function () {
-
- this.audioData = !!(window['Audio']);
- this.webAudio = !!(window['webkitAudioContext'] || window['AudioContext']);
- var audioElement = document.createElement('audio');
- var result = false;
-
- try {
- if (result = !!audioElement.canPlayType) {
-
- if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
- this.ogg = true;
- }
-
- if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '')) {
- this.opus = true;
- }
-
- if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) {
- this.mp3 = true;
- }
-
- // Mimetypes accepted:
- // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
- // bit.ly/iphoneoscodecs
- if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) {
- this.wav = true;
- }
-
- if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) {
- this.m4a = true;
- }
-
- if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) {
- this.webm = true;
- }
- }
- } catch (e) {
- }
-
- },
-
- /**
- * Check PixelRatio of devices.
- * @method Phaser.Device#_checkDevice
- * @private
- */
- _checkDevice: function () {
-
- this.pixelRatio = window['devicePixelRatio'] || 1;
- this.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') != -1;
- this.iPhone4 = (this.pixelRatio == 2 && this.iPhone);
- this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1;
-
- },
-
- /**
- * Check whether the host environment support 3D CSS.
- * @method Phaser.Device#_checkCSS3D
- * @private
- */
- _checkCSS3D: function () {
-
- var el = document.createElement('p');
- var has3d;
- var transforms = {
- 'webkitTransform': '-webkit-transform',
- 'OTransform': '-o-transform',
- 'msTransform': '-ms-transform',
- 'MozTransform': '-moz-transform',
- 'transform': 'transform'
- };
-
- // Add it to the body to get the computed style.
- document.body.insertBefore(el, null);
-
- for (var t in transforms) {
- if (el.style[t] !== undefined) {
- el.style[t] = "translate3d(1px,1px,1px)";
- has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
- }
- }
-
- document.body.removeChild(el);
- this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none");
-
- },
-
- /**
- * Check whether the host environment can play audio.
- * @method Phaser.Device#canPlayAudio
- * @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.
- * @return {boolean} True if the given file type is supported by the browser, otherwise false.
- */
- canPlayAudio: function (type) {
-
- if (type == 'mp3' && this.mp3)
- {
- return true;
- }
- else if (type == 'ogg' && (this.ogg || this.opus))
- {
- return true;
- }
- else if (type == 'm4a' && this.m4a)
- {
- return true;
- }
- else if (type == 'wav' && this.wav)
- {
- return true;
- }
- else if (type == 'webm' && this.webm)
- {
- return true;
- }
-
- return false;
-
- },
-
- /**
- * Check whether the console is open.
- * @method Phaser.Device#isConsoleOpen
- * @return {boolean} True if the browser dev console is open.
- */
- isConsoleOpen: function () {
-
- if (window.console && window.console['firebug'])
- {
- return true;
- }
-
- if (window.console)
- {
- console.profile();
- console.profileEnd();
-
- if (console.clear)
- {
- console.clear();
- }
-
- return console['profiles'].length > 0;
- }
-
- return false;
-
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Abstracts away the use of RAF or setTimeOut for the core game update loop.
-*
-* @class Phaser.RequestAnimationFrame
-* @constructor
-* @param {Phaser.Game} game - A reference to the currently running game.
-*/
-Phaser.RequestAnimationFrame = function(game) {
-
- /**
- * @property {Phaser.Game} game - The currently running game.
- */
- this.game = game;
-
- /**
- * @property {boolean} _isSetTimeOut - Description.
- * @private
- */
- this._isSetTimeOut = false;
-
- /**
- * @property {boolean} isRunning - Description.
- * @default
- */
- this.isRunning = false;
-
- var vendors = [
- 'ms',
- 'moz',
- 'webkit',
- 'o'
- ];
-
- for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++)
- {
- window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
- window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
- }
-
- /**
- * The function called by the update
- * @property _onLoop
- * @private
- */
- this._onLoop = null;
-
- /**
- * The callback ID used when calling cancel
- * @property _timeOutID
- * @private
- */
- this._timeOutID = null;
-
-};
-
-Phaser.RequestAnimationFrame.prototype = {
-
-
- /**
- * Starts the requestAnimatioFrame running or setTimeout if unavailable in browser
- * @method Phaser.RequestAnimationFrame#start
- */
- start: function () {
-
- this.isRunning = true;
-
- var _this = this;
-
- if (!window.requestAnimationFrame)
- {
- this._isSetTimeOut = true;
-
- this._onLoop = function () {
- return _this.updateSetTimeout();
- };
-
- this._timeOutID = window.setTimeout(this._onLoop, 0);
- }
- else
- {
- this._isSetTimeOut = false;
-
- this._onLoop = function (time) {
- return _this.updateRAF(time);
- };
-
- this._timeOutID = window.requestAnimationFrame(this._onLoop);
- }
-
- },
-
- /**
- * The update method for the requestAnimationFrame
- * @method Phaser.RequestAnimationFrame#updateRAF
- * @param {number} time - A timestamp, either from RAF or setTimeOut
- */
- updateRAF: function (time) {
-
- this.game.update(time);
-
- this._timeOutID = window.requestAnimationFrame(this._onLoop);
-
- },
-
- /**
- * The update method for the setTimeout.
- * @method Phaser.RequestAnimationFrame#updateSetTimeout
- */
- updateSetTimeout: function () {
-
- this.game.update(Date.now());
-
- this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall);
-
- },
-
- /**
- * Stops the requestAnimationFrame from running.
- * @method Phaser.RequestAnimationFrame#stop
- */
- stop: function () {
-
- if (this._isSetTimeOut)
- {
- clearTimeout(this._timeOutID);
- }
- else
- {
- window.cancelAnimationFrame(this._timeOutID);
- }
-
- this.isRunning = false;
-
- },
-
- /**
- * Is the browser using setTimeout?
- * @method Phaser.RequestAnimationFrame#isSetTimeOut
- * @return {boolean}
- */
- isSetTimeOut: function () {
- return this._isSetTimeOut;
- },
-
- /**
- * Is the browser using requestAnimationFrame?
- * @method Phaser.RequestAnimationFrame#isRAF
- * @return {boolean}
- */
- isRAF: function () {
- return (this._isSetTimeOut === false);
- }
-
-};
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* Phaser.RandomDataGenerator constructor.
-*
-* @class Phaser.RandomDataGenerator
-* @classdesc An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd
-* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense.
-* Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
-*
-* @constructor
-* @param {array} seeds
-*/
-Phaser.RandomDataGenerator = function (seeds) {
-
- if (typeof seeds === "undefined") { seeds = []; }
-
- this.sow(seeds);
-
-};
-
-Phaser.RandomDataGenerator.prototype = {
-
- /**
- * @property {number} c
- * @private
- */
- c: 1,
-
- /**
- * @property {number} s0
- * @private
- */
- s0: 0,
-
- /**
- * @property {number} s1
- * @private
- */
- s1: 0,
-
- /**
- * @property {number} s2
- * @private
- */
- s2: 0,
-
- /**
- * Private random helper.
- * @method Phaser.RandomDataGenerator#rnd
- * @private
- * @return {number} Description.
- */
- rnd: function () {
-
- var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32
-
- this.c = t | 0;
- this.s0 = this.s1;
- this.s1 = this.s2;
- this.s2 = t - this.c;
-
- return this.s2;
- },
-
- /**
- * Reset the seed of the random data generator.
- *
- * @method Phaser.RandomDataGenerator#sow
- * @param {array} seeds
- */
- sow: function (seeds) {
-
- if (typeof seeds === "undefined") { seeds = []; }
-
- this.s0 = this.hash(' ');
- this.s1 = this.hash(this.s0);
- this.s2 = this.hash(this.s1);
- this.c = 1;
-
- var seed;
-
- for (var i = 0; seed = seeds[i++]; )
- {
- this.s0 -= this.hash(seed);
- this.s0 += ~~(this.s0 < 0);
- this.s1 -= this.hash(seed);
- this.s1 += ~~(this.s1 < 0);
- this.s2 -= this.hash(seed);
- this.s2 += ~~(this.s2 < 0);
- }
-
- },
-
- /**
- * Description.
- * @method Phaser.RandomDataGenerator#hash
- * @param {Any} data
- * @private
- * @return {number} Description.
- */
- hash: function (data) {
-
- var h, i, n;
- n = 0xefc8249d;
- data = data.toString();
-
- for (i = 0; i < data.length; i++) {
- n += data.charCodeAt(i);
- h = 0.02519603282416938 * n;
- n = h >>> 0;
- h -= n;
- h *= n;
- n = h >>> 0;
- h -= n;
- n += h * 0x100000000;// 2^32
- }
-
- return (n >>> 0) * 2.3283064365386963e-10;// 2^-32
-
- },
-
- /**
- * Returns a random integer between 0 and 2^32.
- * @method Phaser.RandomDataGenerator#integer
- * @return {number}
- */
- integer: function() {
- return this.rnd.apply(this) * 0x100000000;// 2^32
- },
-
- /**
- * Returns a random real number between 0 and 1.
- * @method Phaser.RandomDataGenerator#frac
- * @return {number}
- */
- frac: function() {
- return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53
- },
-
- /**
- * Returns a random real number between 0 and 2^32.
- * @method Phaser.RandomDataGenerator#real
- * @return {number}
- */
- real: function() {
- return this.integer() + this.frac();
- },
-
- /**
- * Returns a random integer between min and max.
- * @method Phaser.RandomDataGenerator#integerInRange
- * @param {number} min
- * @param {number} max
- * @return {number}
- */
- integerInRange: function (min, max) {
- return Math.floor(this.realInRange(min, max));
- },
-
- /**
- * Returns a random real number between min and max.
- * @method Phaser.RandomDataGenerator#realInRange
- * @param {number} min
- * @param {number} max
- * @return {number}
- */
- realInRange: function (min, max) {
-
- return this.frac() * (max - min) + min;
-
- },
-
- /**
- * Returns a random real number between -1 and 1.
- * @method Phaser.RandomDataGenerator#normal
- * @return {number}
- */
- normal: function () {
- return 1 - 2 * this.frac();
- },
-
- /**
- * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368
- * @method Phaser.RandomDataGenerator#uuid
- * @return {string}
- */
- uuid: function () {
-
- var a, b;
-
- for (
- b=a='';
- a++<36;
- b+=~a%5|a*3&4?(a^15?8^this.frac()*(a^20?16:4):4).toString(16):'-'
- );
-
- return b;
-
- },
-
- /**
- * Returns a random member of `array`.
- * @method Phaser.RandomDataGenerator#pick
- * @param {Any} ary
- * @return {number}
- */
- pick: function (ary) {
- return ary[this.integerInRange(0, ary.length)];
- },
-
- /**
- * Returns a random member of `array`, favoring the earlier entries.
- * @method Phaser.RandomDataGenerator#weightedPick
- * @param {Any} ary
- * @return {number}
- */
- weightedPick: function (ary) {
- return ary[~~(Math.pow(this.frac(), 2) * ary.length)];
- },
-
- /**
- * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
- * @method Phaser.RandomDataGenerator#timestamp
- * @param {number} min
- * @param {number} max
- * @return {number}
- */
- timestamp: function (a, b) {
- return this.realInRange(a || 946684800000, b || 1577862000000);
- },
-
- /**
- * Returns a random angle between -180 and 180.
- * @method Phaser.RandomDataGenerator#angle
- * @return {number}
- */
- angle: function() {
- return this.integerInRange(-180, 180);
- }
-
-};
-
-/**
-* @author Richard Davey
-* @copyright 2013 Photon Storm Ltd.
-* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
-*/
-
-/**
-* A collection of mathematical methods.
-*
-* @class Phaser.Math
-*/
-Phaser.Math = {
-
- /**
- * = 2 π
- * @method Phaser.Math#PI2
- */
- PI2: Math.PI * 2,
-
- /**
- * Two number are fuzzyEqual if their difference is less than ε.
- * @method Phaser.Math#fuzzyEqual
- * @param {number} a
- * @param {number} b
- * @param {number} epsilon
- * @return {boolean} True if |a-b|<ε
- */
- fuzzyEqual: function (a, b, epsilon) {
- if (typeof epsilon === "undefined") { epsilon = 0.0001; }
- return Math.abs(a - b) < epsilon;
- },
-
- /**
- * a is fuzzyLessThan b if it is less than b + ε.
- * @method Phaser.Math#fuzzyEqual
- * @param {number} a
- * @param {number} b
- * @param {number} epsilon
- * @return {boolean} True if ab+ε
- */
- fuzzyGreaterThan: function (a, b, epsilon) {
- if (typeof epsilon === "undefined") { epsilon = 0.0001; }
- return a > b - epsilon;
- },
-
- /**
- * @method Phaser.Math#fuzzyCeil
- * @param {number} val
- * @param {number} epsilon
- * @return {boolean} ceiling(val-ε)
- */
- fuzzyCeil: function (val, epsilon) {
- if (typeof epsilon === "undefined") { epsilon = 0.0001; }
- return Math.ceil(val - epsilon);
- },
-
- /**
- * @method Phaser.Math#fuzzyFloor
- * @param {number} val
- * @param {number} epsilon
- * @return {boolean} floor(val-ε)
- */
- fuzzyFloor: function (val, epsilon) {
- if (typeof epsilon === "undefined") { epsilon = 0.0001; }
- return Math.floor(val + epsilon);
- },
-
- /**
- * Averages all values passed to the function and returns the result. You can pass as many parameters as you like.
- * @method Phaser.Math#average
- * @return {number} The average of all given values.
- */
- average: function () {
-
- var args = [];
-
- for (var _i = 0; _i < (arguments.length - 0); _i++) {
- args[_i] = arguments[_i + 0];
- }
-
- var avg = 0;
-
- for (var i = 0; i < args.length; i++) {
- avg += args[i];
- }
-
- return avg / args.length;
-
- },
-
- /**
- * @method Phaser.Math#truncate
- * @param {number} n
- * @return {number}
- */
- truncate: function (n) {
- return (n > 0) ? Math.floor(n) : Math.ceil(n);
- },
-
- /**
- * @method Phaser.Math#shear
- * @param {number} n
- * @return {number} n mod 1
- */
- shear: function (n) {
- return n % 1;
- },
-
- /**
- * Snap a value to nearest grid slice, using rounding.
- *
- * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15.
- *
- * @method Phaser.Math#snapTo
- * @param {number} input - The value to snap.
- * @param {number} gap - The interval gap of the grid.
- * @param {number} [start] - Optional starting offset for gap.
- * @return {number}
- */
- snapTo: function (input, gap, start) {
-
- if (typeof start === "undefined") { start = 0; }
-
- if (gap == 0) {
- return input;
- }
-
- input -= start;
- input = gap * Math.round(input / gap);
-
- return start + input;
-
- },
-
- /**
- * Snap a value to nearest grid slice, using floor.
- *
- * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15
- *
- * @method Phaser.Math#snapToFloor
- * @param {number} input - The value to snap.
- * @param {number} gap - The interval gap of the grid.
- * @param {number} [start] - Optional starting offset for gap.
- * @return {number}
- */
- snapToFloor: function (input, gap, start) {
-
- if (typeof start === "undefined") { start = 0; }
-
- if (gap == 0) {
- return input;
- }
-
- input -= start;
- input = gap * Math.floor(input / gap);
-
- return start + input;
-
- },
-
- /**
- * Snap a value to nearest grid slice, using ceil.
- *
- * Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20.
- *
- * @method Phaser.Math#snapToCeil
- * @param {number} input - The value to snap.
- * @param {number} gap - The interval gap of the grid.
- * @param {number} [start] - Optional starting offset for gap.
- * @return {number}
- */
- snapToCeil: function (input, gap, start) {
-
- if (typeof start === "undefined") { start = 0; }
-
- if (gap == 0) {
- return input;
- }
-
- input -= start;
- input = gap * Math.ceil(input / gap);
-
- return start + input;
-
- },
-
-
- /**
- * Snaps a value to the nearest value in an array.
- * @method Phaser.Math#snapToInArray
- * @param {number} input
- * @param {array} arr
- * @param {boolean} sort - True if the array needs to be sorted.
- * @return {number}
- */
- snapToInArray: function (input, arr, sort) {
-
- if (typeof sort === "undefined") { sort = true; }
-
- if (sort) {
- arr.sort();
- }
-
- if (input < arr[0]) {
- return arr[0];
- }
-
- var i = 1;
-
- while (arr[i] < input) {
- i++;
- }
-
- var low = arr[i - 1];
- var high = (i < arr.length) ? arr[i] : Number.POSITIVE_INFINITY;
-
- return ((high - input) <= (input - low)) ? high : low;
-
- },
-
- /**
- * Round to some place comparative to a 'base', default is 10 for decimal place.
- *
- * 'place' is represented by the power applied to 'base' to get that place
- * e.g.
- * 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011
- *
- * roundTo(2000/7,3) == 0
- * roundTo(2000/7,2) == 300
- * roundTo(2000/7,1) == 290
- * roundTo(2000/7,0) == 286
- * roundTo(2000/7,-1) == 285.7
- * roundTo(2000/7,-2) == 285.71
- * roundTo(2000/7,-3) == 285.714
- * roundTo(2000/7,-4) == 285.7143
- * roundTo(2000/7,-5) == 285.71429
- *
- * roundTo(2000/7,3,2) == 288 -- 100100000
- * roundTo(2000/7,2,2) == 284 -- 100011100
- * roundTo(2000/7,1,2) == 286 -- 100011110
- * roundTo(2000/7,0,2) == 286 -- 100011110
- * roundTo(2000/7,-1,2) == 285.5 -- 100011101.1
- * roundTo(2000/7,-2,2) == 285.75 -- 100011101.11
- * roundTo(2000/7,-3,2) == 285.75 -- 100011101.11
- * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011
- * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111
- *
- * Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
- * because we are rounding 100011.1011011011011011 which rounds up.
- *
- * @method Phaser.Math#roundTo
- * @param {number} value - The value to round.
- * @param {number} place - The place to round to.
- * @param {number} base - The base to round in... default is 10 for decimal.
- * @return {number}
- */
- roundTo: function (value, place, base) {
-
- if (typeof place === "undefined") { place = 0; }
- if (typeof base === "undefined") { base = 10; }
-
- var p = Math.pow(base, -place);
-
- return Math.round(value * p) / p;
-
- },
-
- /**
- * @method Phaser.Math#floorTo
- * @param {number} value - The value to round.
- * @param {number} place - The place to round to.
- * @param {number} base - The base to round in... default is 10 for decimal.
- * @return {number}
- */
- floorTo: function (value, place, base) {
-
- if (typeof place === "undefined") { place = 0; }
- if (typeof base === "undefined") { base = 10; }
-
- var p = Math.pow(base, -place);
-
- return Math.floor(value * p) / p;
-
- },
-
- /**
- * @method Phaser.Math#ceilTo
- * @param {number} value - The value to round.
- * @param {number} place - The place to round to.
- * @param {number} base - The base to round in... default is 10 for decimal.
- * @return {number}
- */
- ceilTo: function (value, place, base) {
-
- if (typeof place === "undefined") { place = 0; }
- if (typeof base === "undefined") { base = 10; }
-
- var p = Math.pow(base, -place);
-
- return Math.ceil(value * p) / p;
-
- },
-
- /**
- * A one dimensional linear interpolation of a value.
- * @method Phaser.Math#interpolateFloat
- * @param {number} a
- * @param {number} b
- * @param {number} weight
- * @return {number}
- */
- interpolateFloat: function (a, b, weight) {
- return (b - a) * weight + a;
- },
-
- /**
- * Find the angle of a segment from (x1, y1) -> (x2, y2 ).
- * @method Phaser.Math#angleBetween
- * @param {number} x1
- * @param {number} y1
- * @param {number} x2
- * @param {number} y2
- * @return {number}
- */
- angleBetween: function (x1, y1, x2, y2) {
- return Math.atan2(y2 - y1, x2 - x1);
- },
-
- /**
- * Set an angle within the bounds of -π toπ.
- * @method Phaser.Math#normalizeAngle
- * @param {number} angle
- * @param {boolean} radians - True if angle size is expressed in radians.
- * @return {number}
- */
- normalizeAngle: function (angle, radians) {
-
- if (typeof radians === "undefined") { radians = true; }
-
- var rd = (radians) ? GameMath.PI : 180;
- return this.wrap(angle, rd, -rd);
-
- },
-
- /**
- * Closest angle between two angles from a1 to a2
- * absolute value the return for exact angle
- * @method Phaser.Math#nearestAngleBetween
- * @param {number} a1
- * @param {number} a2
- * @param {boolean} radians - True if angle sizes are expressed in radians.
- * @return {number}
- */
- nearestAngleBetween: function (a1, a2, radians) {
-
- if (typeof radians === "undefined") { radians = true; }
-
- var rd = (radians) ? Math.PI : 180;
- a1 = this.normalizeAngle(a1, radians);
- a2 = this.normalizeAngle(a2, radians);
-
- if (a1 < -rd / 2 && a2 > rd / 2)
- {
- a1 += rd * 2;
- }
-
- if (a2 < -rd / 2 && a1 > rd / 2)
- {
- a2 += rd * 2;
- }
-
- return a2 - a1;
-
- },
-
- /**
- * Interpolate across the shortest arc between two angles.
- * @method Phaser.Math#interpolateAngles
- * @param {number} a1 - Description.
- * @param {number} a2 - Description.
- * @param {number} weight - Description.
- * @param {boolean} radians - True if angle sizes are expressed in radians.
- * @param {Description} ease - Description.
- * @return {number}
- */
- interpolateAngles: function (a1, a2, weight, radians, ease) {
-
- if (typeof radians === "undefined") { radians = true; }
- if (typeof ease === "undefined") { ease = null; }
-
- a1 = this.normalizeAngle(a1, radians);
- a2 = this.normalizeAngleToAnother(a2, a1, radians);
-
- return (typeof ease === 'function') ? ease(weight, a1, a2 - a1, 1) : this.interpolateFloat(a1, a2, weight);
-
- },
-
- /**
- * Generate a random bool result based on the chance value.
- *
- * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance
- * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.
- *
- * @method Phaser.Math#chanceRoll
- * @param {number} chance - The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%).
- * @return {boolean} True if the roll passed, or false otherwise.
- */
- chanceRoll: function (chance) {
-
- if (typeof chance === "undefined") { chance = 50; }
-
- if (chance <= 0)
- {
- return false;
- }
- else if (chance >= 100)
- {
- return true;
- }
- else
- {
- if (Math.random() * 100 >= chance)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- },
-
- /**
- * Returns an Array containing the numbers from min to max (inclusive).
- *
- * @method Phaser.Math#numberArray
- * @param {number} min - The minimum value the array starts with.
- * @param {number} max - The maximum value the array contains.
- * @return {array} The array of number values.
- */
- numberArray: function (min, max) {
-
- var result = [];
-
- for (var i = min; i <= max; i++)
- {
- result.push(i);
- }
-
- return result;
-
- },
-
- /**
- * Adds the given amount to the value, but never lets the value go over the specified maximum.
- *
- * @method Phaser.Math#maxAdd
- * @param {number} value - The value to add the amount to.
- * @param {number} amount - The amount to add to the value.
- * @param {number} max- The maximum the value is allowed to be.
- * @return {number}
- */
- maxAdd: function (value, amount, max) {
-
- value += amount;
-
- if (value > max)
- {
- value = max;
- }
-
- return value;
-
- },
-
- /**
- * Subtracts the given amount from the value, but never lets the value go below the specified minimum.
- *
- * @method Phaser.Math#minSub
- * @param {number} value - The base value.
- * @param {number} amount - The amount to subtract from the base value.
- * @param {number} min - The minimum the value is allowed to be.
- * @return {number} The new value.
- */
- minSub: function (value, amount, min) {
-
- value -= amount;
-
- if (value < min)
- {
- value = min;
- }
-
- return value;
-
- },
-
- /**
- * Ensures that the value always stays between min and max, by wrapping the value around.
- *
max should be larger than min, or the function will return 0
- *
- * @method Phaser.Math#wrap
- * @param value The value to wrap
- * @param min The minimum the value is allowed to be
- * @param max The maximum the value is allowed to be
- * @return {number} The wrapped value
- */
- wrap: function (value, min, max) {
-
- var range = max - min;
-
- if (range <= 0)
- {
- return 0;
- }
-
- var result = (value - min) % range;
-
- if (result < 0)
- {
- result += range;
- }
-
- return result + min;
-
- },
-
- /**
- * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
- *
Values must be positive integers, and are passed through Math.abs
- *
- * @method Phaser.Math#wrapValue
- * @param {number} value - The value to add the amount to.
- * @param {number} amount - The amount to add to the value.
- * @param {number} max - The maximum the value is allowed to be.
- * @return {number} The wrapped value.
- */
- wrapValue: function (value, amount, max) {
-
- var diff;
- value = Math.abs(value);
- amount = Math.abs(amount);
- max = Math.abs(max);
- diff = (value + amount) % max;
-
- return diff;
-
- },
-
- /**
- * Randomly returns either a 1 or -1.
- *
- * @method Phaser.Math#randomSign
- * @return {number} 1 or -1
- */
- randomSign: function () {
- return (Math.random() > 0.5) ? 1 : -1;
- },
-
- /**
- * Returns true if the number given is odd.
- *
- * @method Phaser.Math#isOdd
- * @param {number} n - The number to check.
- * @return {boolean} True if the given number is odd. False if the given number is even.
- */
- isOdd: function (n) {
-
- return (n & 1);
-
- },
-
- /**
- * Returns true if the number given is even.
- *
- * @method Phaser.Math#isEven
- * @param {number} n - The number to check.
- * @return {boolean} True if the given number is even. False if the given number is odd.
- */
- isEven: function (n) {
-
- if (n & 1)
- {
- return false;
- }
- else
- {
- return true;
- }
-
- },
-
- /**
- * Significantly faster version of Math.max
- * See http://jsperf.com/math-s-min-max-vs-homemade/5
- *
- * @method Phaser.Math#max
- * @return {number} The highest value from those given.
- */
- max: function () {
-
- for (var i = 1, max = 0, len = arguments.length; i < len; i++)
- {
- if (arguments[max] < arguments[i])
- {
- max = i;
- }
- }
-
- return arguments[max];
-
- },
-
- /**
- * Significantly faster version of Math.min
- * See http://jsperf.com/math-s-min-max-vs-homemade/5
- *
- * @method Phaser.Math#min
- * @return {number} The lowest value from those given.
- */
- min: function () {
-
- for (var i =1 , min = 0, len = arguments.length; i < len; i++)
- {
- if (arguments[i] < arguments[min])
- {
- min = i;
- }
- }
-
- return arguments[min];
-
- },
-
- /**
- * Keeps an angle value between -180 and +180
- * Should be called whenever the angle is updated on the Sprite to stop it from going insane.
- *
- * @method Phaser.Math#wrapAngle
- * @param {number} angle - The angle value to check
- * @return {number} The new angle value, returns the same as the input angle if it was within bounds.
- */
- wrapAngle: function (angle) {
-
- var result = angle;
-
- // Nothing needs to change
- if (angle >= -180 && angle <= 180)
- {
- return angle;
- }
-
- // Else normalise it to -180, 180
- result = (angle + 180) % 360;
-
- if (result < 0)
- {
- result += 360;
- }
-
- return result - 180;
-
- },
-
- /**
- * Keeps an angle value between the given min and max values.
- *
- * @method Phaser.Math#angleLimit
- * @param {number} angle - The angle value to check. Must be between -180 and +180.
- * @param {number} min - The minimum angle that is allowed (must be -180 or greater).
- * @param {number} max - The maximum angle that is allowed (must be 180 or less).
- *
- * @return {number} The new angle value, returns the same as the input angle if it was within bounds
- */
- angleLimit: function (angle, min, max) {
-
- var result = angle;
-
- if (angle > max)
- {
- result = max;
- }
- else if (angle < min)
- {
- result = min;
- }
-
- return result;
-
- },
-
- /**
- * Description.
- * @method Phaser.Math#linearInterpolation
- * @param {number} v
- * @param {number} k
- * @return {number}
- */
- linearInterpolation: function (v, k) {
-
- var m = v.length - 1;
- var f = m * k;
- var i = Math.floor(f);
-
- if (k < 0)
- {
- return this.linear(v[0], v[1], f);
- }
-
- if (k > 1)
- {
- return this.linear(v[m], v[m - 1], m - f);
- }
-
- return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i);
-
- },
-
- /**
- * Description.
- * @method Phaser.Math#bezierInterpolation
- * @param {number} v
- * @param {number} k
- * @return {number}
- */
- bezierInterpolation: function (v, k) {
-
- var b = 0;
- var n = v.length - 1;
-
- for (var i = 0; i <= n; i++)
- {
- b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i);
- }
-
- return b;
-
- },
-
- /**
- * Description.
- * @method Phaser.Math#catmullRomInterpolation
- * @param {number} v
- * @param {number} k
- * @return {number}
- */
- catmullRomInterpolation: function (v, k) {
-
- var m = v.length - 1;
- var f = m * k;
- var i = Math.floor(f);
-
- if (v[0] === v[m])
- {
- if (k < 0)
- {
- i = Math.floor(f = m * (1 + k));
- }
-
- return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
-
- }
- else
- {
- if (k < 0)
- {
- return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]);
- }
-
- if (k > 1)
- {
- return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
- }
-
- return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
- }
-
- },
-
- /**
- * Description.
- * @method Phaser.Math#Linear
- * @param {number} p0
- * @param {number} p1
- * @param {number} t
- * @return {number}
- */
- linear: function (p0, p1, t) {
- return (p1 - p0) * t + p0;
- },
-
- /**
- * @method Phaser.Math#bernstein
- * @param {number} n
- * @param {number} i
- * @return {number}
- */
- bernstein: function (n, i) {
- return this.factorial(n) / this.factorial(i) / this.factorial(n - i);
- },
-
- /**
- * Description.
- * @method Phaser.Math#catmullRom
- * @param {number} p0
- * @param {number} p1
- * @param {number} p2
- * @param {number} p3
- * @param {number} t
- * @return {number}
- */
- catmullRom: function (p0, p1, p2, p3, t) {
-
- var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2;
-
- return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
-
- },
-
- /**
- * @method Phaser.Math#difference
- * @param {number} a
- * @param {number} b
- * @return {number}
- */
- difference: function (a, b) {
- return Math.abs(a - b);
- },
-
- /**
- * Fetch a random entry from the given array.
- * Will return null if random selection is missing, or array has no entries.
- *
- * @method Phaser.Math#getRandom
- * @param {array} objects - An array of objects.
- * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array.
- * @param {number} length - Optional restriction on the number of values you want to randomly select from.
- * @return {object} The random object that was selected.
- */
- getRandom: function (objects, startIndex, length) {
-
- if (typeof startIndex === "undefined") { startIndex = 0; }
- if (typeof length === "undefined") { length = 0; }
-
- if (objects != null) {
-
- var l = length;
-
- if ((l == 0) || (l > objects.length - startIndex))
- {
- l = objects.length - startIndex;
- }
-
- if (l > 0)
- {
- return objects[startIndex + Math.floor(Math.random() * l)];
- }
- }
-
- return null;
-
- },
-
- /**
- * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.
- *
- * @method Phaser.Math#floor
- * @param {number} Value Any number.
- * @return {number} The rounded value of that number.
- */
- floor: function (value) {
-
- var n = value | 0;
-
- return (value > 0) ? (n) : ((n != value) ? (n - 1) : (n));
-
- },
-
- /**
- * Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.
- *
- * @method Phaser.Math#ceil
- * @param {number} value - Any number.
- * @return {number} The rounded value of that number.
- */
- ceil: function (value) {
- var n = value | 0;
- return (value > 0) ? ((n != value) ? (n + 1) : (n)) : (n);
- },
-
- /**
- * Generate a sine and cosine table simultaneously and extremely quickly. Based on research by Franky of scene.at
- *
- * The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function
- * you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time.
- *