diff --git a/README.md b/README.md index c403ab76..7f50bc05 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Version 1.1 What's New: -* JSDoc is go! We've added jsdoc3 blocks to every property and function, in every file. +* JSDoc is go! We've added jsdoc3 blocks to every property and function, in every file and published the API docs to the docs folder. * Brand new Example system (no more php!) and over 150 examples to learn from too. * New TypeScript definitions file generated (in the build folder - thanks to TomTom1229 for manually enhancing this). * New Grunt based build system added (thanks to Florent Cailhol) diff --git a/build/phaser.js b/build/phaser.js index fe82308e..e8cf02ca 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -1,3 +1,12 @@ +!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. @@ -9,7 +18,7 @@ * * Phaser - http://www.phaser.io * -* v1.1.0 - Built at: Wed, 23 Oct 2013 13:05:12 +0100 +* v1.1.0 - Built at: Fri Oct 25 2013 18:25:28 * * By Richard Davey http://www.photonstorm.com @photonstorm * @@ -27,15 +36,7 @@ * "If you want them to be more intelligent, read them more fairy tales." * -- Albert Einstein */ -(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 (b) { + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -54,10 +55,10 @@ var PIXI = PIXI || {}; /** * @namespace Phaser */ -var Phaser = Phaser || { +var Phaser = Phaser || { - VERSION: '1.1.0', - GAMES: [], + VERSION: '1.1.0', + GAMES: [], AUTO: 0, CANVAS: 1, WEBGL: 2, @@ -87,6 +88,7 @@ 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. @@ -9329,6 +9331,18 @@ Phaser.Stage = function (game, width, height) { */ 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 = { @@ -9361,6 +9375,24 @@ Phaser.Stage.prototype = { 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; + } + + } + }, /** @@ -9465,15 +9497,18 @@ Phaser.Group = function (game, parent, name, useStage) { 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(); } } @@ -9521,6 +9556,8 @@ Phaser.Group.prototype = { } this._container.addChild(child); + + child.updateTransform(); } return child; @@ -9548,6 +9585,8 @@ Phaser.Group.prototype = { } this._container.addChildAt(child, index); + + child.updateTransform(); } return child; @@ -9597,6 +9636,8 @@ Phaser.Group.prototype = { } this._container.addChild(child); + + child.updateTransform(); return child; @@ -9632,6 +9673,8 @@ Phaser.Group.prototype = { } this._container.addChild(child); + child.updateTransform(); + } }, @@ -9823,6 +9866,7 @@ Phaser.Group.prototype = { this._container.removeChild(oldChild); this._container.addChildAt(newChild, index); newChild.events.onAddedToGroup.dispatch(newChild, this); + newChild.updateTransform(); } }, @@ -10951,7 +10995,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant if (typeof transparent == 'undefined') { transparent = false; } if (typeof antialias == 'undefined') { antialias = true; } - + /** * @property {number} id - Phaser Game ID (for when Pixi supports multiple instances). */ @@ -11170,7 +11214,7 @@ Phaser.Game.prototype = { /** * Initialize engine sub modules and start the game. - * + * * @method Phaser.Game#boot * @protected */ @@ -11234,10 +11278,13 @@ Phaser.Game.prototype = { console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to WebGL', 'color: #ffff33; background: #000000'); } - if (Phaser.VERSION.substr(-5) == '-beta') - { - console.warn('You are using a beta version of Phaser. Some things may not work.'); - } + var pos = Phaser.VERSION.indexOf('-'); + var versionQualifier = (pos >= 0) ? Phaser.VERSION.substr(pos + 1) : null; + if (versionQualifier) + { + var article = ['a', 'e', 'i', 'o', 'u', 'y'].indexOf(versionQualifier.charAt(0)) >= 0 ? 'an' : 'a'; + console.warn('You are using %s %s version of Phaser. Some things may not work.', article, versionQualifier); + } this.isRunning = true; this._loadComplete = false; @@ -11248,10 +11295,10 @@ Phaser.Game.prototype = { } }, - + /** * 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 */ @@ -11288,7 +11335,7 @@ Phaser.Game.prototype = { /** * Called when the load has finished, after preload was run. - * + * * @method Phaser.Game#loadComplete * @protected */ @@ -11302,7 +11349,7 @@ Phaser.Game.prototype = { /** * The core game loop. - * + * * @method Phaser.Game#update * @protected * @param {number} time - The current time as provided by RequestAnimationFrame. @@ -11316,6 +11363,7 @@ Phaser.Game.prototype = { this.plugins.preUpdate(); this.physics.preUpdate(); + this.stage.update(); this.input.update(); this.tweens.update(); this.sound.update(); @@ -11337,11 +11385,15 @@ Phaser.Game.prototype = { /** * Nuke the entire game from orbit - * + * * @method Phaser.Game#destroy */ destroy: function () { + this.raf.stop(); + + this.input.destroy(); + this.state.destroy(); this.state = null; @@ -11794,6 +11846,19 @@ Phaser.Input.prototype = { 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(); + }, /** @@ -12080,28 +12145,6 @@ Phaser.Input.prototype = { return null; - }, - - /** - * Get the distance between two Pointer objects. - * @method Phaser.Input#getDistance - * @param {Pointer} pointer1 - * @param {Pointer} pointer2 - * @return {Description} Description. - */ - getDistance: function (pointer1, pointer2) { - // return Phaser.Vec2Utils.distance(pointer1.position, pointer2.position); - }, - - /** - * Get the angle between two Pointer objects. - * @method Phaser.Input#getAngle - * @param {Pointer} pointer1 - * @param {Pointer} pointer2 - * @return {Description} Description. - */ - getAngle: function (pointer1, pointer2) { - // return Phaser.Vec2Utils.angle(pointer1.position, pointer2.position); } }; @@ -13610,7 +13653,7 @@ Phaser.Pointer.prototype = { 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.position.setTo(this.x, this.y); - this.game.input.onDown.dispatch(this); + this.game.input.onDown.dispatch(this, event); this.game.input.resetSpeed(this.x, this.y); } @@ -13835,7 +13878,7 @@ Phaser.Pointer.prototype = { 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); + this.game.input.onUp.dispatch(this, event); // Was it a tap? if (this.duration >= 0 && this.duration <= this.game.input.tapRate) @@ -14659,10 +14702,13 @@ Phaser.InputHandler.prototype = { if (this.enabled) { + this.enabled = false; + + this.game.input.interactiveItems.remove(this); + this.stop(); - // Null everything + this.sprite = null; - // etc } }, @@ -14834,24 +14880,15 @@ Phaser.InputHandler.prototype = { { this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y); - // Check against bounds first (move these to private vars) - var x1 = -(this.sprite.texture.frame.width) * this.sprite.anchor.x; - var y1; - - if (this._tempPoint.x > x1 && this._tempPoint.x < x1 + this.sprite.texture.frame.width) + if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.currentFrame.height) { - y1 = -(this.sprite.texture.frame.height) * this.sprite.anchor.y; - - if (this._tempPoint.y > y1 && this._tempPoint.y < y1 + this.sprite.texture.frame.height) + if (this.pixelPerfect) { - if (this.pixelPerfect) - { - return this.checkPixel(this._tempPoint.x, this._tempPoint.y); - } - else - { - return true; - } + return this.checkPixel(this._tempPoint.x, this._tempPoint.y); + } + else + { + return true; } } } @@ -14869,16 +14906,16 @@ Phaser.InputHandler.prototype = { */ checkPixel: function (x, y) { - x += (this.sprite.texture.frame.width * this.sprite.anchor.x); - y += (this.sprite.texture.frame.height * this.sprite.anchor.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); // This will fail if the image is part of a texture atlas - need to modify the x/y values here + + 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); @@ -14968,7 +15005,10 @@ Phaser.InputHandler.prototype = { this.game.stage.canvas.style.cursor = "default"; } - this.sprite.events.onInputOut.dispatch(this.sprite, pointer); + if (this.sprite && this.sprite.events) + { + this.sprite.events.onInputOut.dispatch(this.sprite, pointer); + } }, @@ -15408,7 +15448,6 @@ Phaser.InputHandler.prototype = { * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.Events */ @@ -15477,11 +15516,10 @@ Phaser.Events.prototype = { * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.GameObjectFactory */ /** -* Description. +* 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 @@ -15504,22 +15542,10 @@ Phaser.GameObjectFactory = function (game) { Phaser.GameObjectFactory.prototype = { /** - * @property {Phaser.Game} game - A reference to the currently running Game. - * @default - */ - game: null, - - /** - * @property {Phaser.World} world - A reference to the game world. - * @default - */ - world: null, - - /** - * Description. - * @method existing. - * @param {object} - Description. - * @return {boolean} Description. + * 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) { @@ -15530,12 +15556,12 @@ Phaser.GameObjectFactory.prototype = { /** * Create a new Sprite with specific position and sprite sheet key. * - * @method sprite + * @method Phaser.GameObjectFactory#sprite * @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|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 {Description} Description. + * @returns {Phaser.Sprite} the newly created sprite object. */ sprite: function (x, y, key, frame) { @@ -15546,13 +15572,13 @@ Phaser.GameObjectFactory.prototype = { /** * Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent. * - * @method child + * @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 {Description} Description. + * @returns {Phaser.Sprite} the newly created sprite object. */ child: function (group, x, y, key, frame) { @@ -15563,9 +15589,9 @@ Phaser.GameObjectFactory.prototype = { /** * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. * - * @method tween + * @method Phaser.GameObjectFactory#tween * @param {object} obj - Object the tween will be run on. - * @return {Description} Description. + * @return {Phaser.Tween} Description. */ tween: function (obj) { @@ -15574,12 +15600,12 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. * - * @method group - * @param {Description} parent - Description. - * @param {Description} name - Description. - * @return {Description} Description. + * @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) { @@ -15588,13 +15614,13 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * Creates a new instance of the Sound class. * - * @method audio - * @param {Description} key - Description. - * @param {Description} volume - Description. - * @param {Description} loop - Description. - * @return {Description} Description. + * @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) { @@ -15603,16 +15629,16 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * Creates a new TileSprite. * - * @method tileSprite - * @param {Description} x - Description. - * @param {Description} y - Description. - * @param {Description} width - Description. - * @param {Description} height - Description. - * @param {Description} key - Description. - * @param {Description} frame - Description. - * @return {Description} Description. + * @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) { @@ -15621,13 +15647,14 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * Creates a new Text. * - * @method text - * @param {Description} x - Description. - * @param {Description} y - Description. - * @param {Description} text - Description. - * @param {Description} style - Description. + * @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) { @@ -15636,17 +15663,18 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * Creates a new Button object. * - * @method button - * @param {Description} x - Description. - * @param {Description} y - Description. - * @param {Description} callback - Description. - * @param {Description} callbackContext - Description. - * @param {Description} overFrame - Description. - * @param {Description} outFrame - Description. - * @param {Description} downFrame - Description. - * @return {Description} Description. + * @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) { @@ -15655,12 +15683,12 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * Creates a new Graphics object. * - * @method graphics - * @param {Description} x - Description. - * @param {Description} y - Description. - * @return {Description} Description. + * @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) { @@ -15669,13 +15697,15 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * 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 emitter - * @param {Description} x - Description. - * @param {Description} y - Description. - * @param {Description} maxParticles - Description. - * @return {Description} Description. + * @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) { @@ -15684,14 +15714,14 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * * Create a new BitmapText. * - * @method bitmapText - * @param {Description} x - Description. - * @param {Description} y - Description. - * @param {Description} text - Description. - * @param {Description} style - Description. - * @return {Description} Description. + * @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) { @@ -15700,11 +15730,11 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * Creates a new Tilemap object. * - * @method tilemap - * @param {Description} key - Description. - * @return {Description} Description. + * @method Phaser.GameObjectFactory#tilemap + * @param {string} key - Asset key for the JSON file. + * @return {Phaser.Tilemap} The newly created tilemap object. */ tilemap: function (key) { @@ -15713,11 +15743,11 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * Creates a new Tileset object. * - * @method tilemap - * @param {Description} key - Description. - * @return {Description} Description. + * @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) { @@ -15726,17 +15756,15 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. - * - * @method tileSprite - * @param {Description} x - Description. - * @param {Description} y - Description. - * @param {Description} width - Description. - * @param {Description} height - Description. - * @param {Description} key - Description. - * @param {Description} frame - Description. - * @return {Description} Description. - */ + * 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)); @@ -15744,13 +15772,13 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Description. + * A dynamic initially blank canvas to which images can be drawn. * - * @method renderTexture - * @param {Description} key - Description. - * @param {Description} width - Description. - * @param {Description} height - Description. - * @return {Description} Description. + * @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) { @@ -15760,26 +15788,28 @@ Phaser.GameObjectFactory.prototype = { return texture; - }, + } }; /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.Sprite */ /** -* Create a new Sprite. +* 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 -* @classdesc Description of class. * @constructor -* @param {Phaser.Game} game - Current game instance. -* @param {Description} x - Description. -* @param {Description} y - Description. -* @param {string} key - Description. -* @param {Description} frame - Description. +* @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) { @@ -15806,8 +15836,7 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.alive = true; /** - * @property {Description} group - Description. - * @default + * @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent. */ this.group = null; @@ -15818,12 +15847,13 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.name = ''; /** - * @property {Description} type - Description. + * @property {number} type - The const type of this object. + * @default */ this.type = Phaser.SPRITE; /** - * @property {number} renderOrderID - Description. + * @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order. * @default */ this.renderOrderID = -1; @@ -15831,18 +15861,18 @@ Phaser.Sprite = function (game, x, y, key, frame) { /** * 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 + * @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed. * @default */ this.lifespan = 0; /** - * @property {Events} events - The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components + * @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) + * @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); @@ -15852,10 +15882,15 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.input = new Phaser.InputHandler(this); /** - * @property {Description} key - Description. + * @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); @@ -15873,6 +15908,7 @@ Phaser.Sprite = function (game, x, y, key, frame) { if (key == null || this.game.cache.checkImageKey(key) == false) { key = '__default'; + this.key = key; } PIXI.Sprite.call(this, PIXI.TextureCache[key]); @@ -15905,59 +15941,37 @@ Phaser.Sprite = function (game, x, y, key, frame) { * 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 + * @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place. */ this.anchor = new Phaser.Point(); /** - * @property {Description} _cropUUID - Description. - * @private - * @default - */ - this._cropUUID = null; - - /** - * @property {Description} _cropUUID - Description. - * @private - * @default - */ - this._cropRect = null; - - /** - * @property {number} x - Description. + * @property {number} x - The x coordinate (in world space) of this Sprite. */ this.x = x; /** - * @property {number} y - Description. + * @property {number} y - The y coordinate (in world space) of this Sprite. */ this.y = y; - /** - * @property {Description} position - Description. - */ this.position.x = x; this.position.y = y; /** * Should this Sprite be automatically culled if out of range of the camera? - * A culled sprite has its visible property set to 'false'. - * Note that this check doesn't look at this Sprites children, which may still be in camera range. - * So you should set autoCull to false if the Sprite will have children likely to still be in camera range. + * A culled sprite has its renderable property set to 'false'. * - * @property {boolean} autoCull + * @property {boolean} autoCull - A flag indicating if the Sprite should be automatically camera culled or not. * @default */ this.autoCull = false; /** - * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. + * @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); - // console.log(this.worldTransform); - // this.worldTransform = []; - /** * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values. * @private @@ -15981,59 +15995,72 @@ Phaser.Sprite = function (game, x, y, key, frame) { // The actual scale values based on the worldTransform scaleX: 1, scaleY: 1, + // cache scale check + realScaleX: 1, realScaleY: 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: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, + frameID: -1, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, boundsX: 0, boundsY: 0, // If this sprite visible to the camera (regardless of being set to visible or not) - cameraVisible: true + cameraVisible: true, + + // Crop cache + cropX: 0, cropY: 0, cropWidth: this.currentFrame.sourceSizeW, cropHeight: this.currentFrame.sourceSizeH }; /** - * @property {Phaser.Point} offset - Corner point defaults. + * @property {Phaser.Point} offset - Corner point defaults. Should not typically be modified. */ this.offset = new Phaser.Point; /** - * @property {Phaser.Point} center - Description. + * @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 - Description. + * @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 - Description. + * @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 - Description. + * @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 - Description. + * @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); /** - * @property {Phaser.Rectangle} bounds - Description. + * 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 - Set-up the physics body. + * @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); @@ -16043,24 +16070,24 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.health = 1; /** - * @property {Description} inWorld - World bounds check. + * @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 - World bounds check. + * @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 - Kills this sprite as soon as it goes outside of the World bounds. + * @property {boolean} outOfBoundsKill - If true the Sprite is killed as soon as Sprite.inWorld is false. * @default */ this.outOfBoundsKill = false; /** - * @property {boolean} _outOfBoundsFired - Description. + * @property {boolean} _outOfBoundsFired - Internal flag. * @private * @default */ @@ -16073,6 +16100,20 @@ Phaser.Sprite = function (game, x, y, key, frame) { */ this.fixedToCamera = false; + /** + * 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; + }; // Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly) @@ -16080,8 +16121,10 @@ Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype); Phaser.Sprite.prototype.constructor = Phaser.Sprite; /** -* Automatically called by World.preUpdate. You can create your own update in Objects that extend Phaser.Sprite. -* @method Phaser.Sprite.prototype.preUpdate +* 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() { @@ -16120,9 +16163,16 @@ Phaser.Sprite.prototype.preUpdate = function() { this.updateCache(); this.updateAnimation(); + if (this.cropEnabled) + { + this.updateCrop(); + } + // Re-run the camera visibility check if (this._cache.dirty) { + this.updateBounds(); + this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0); if (this.autoCull == true) @@ -16145,6 +16195,12 @@ Phaser.Sprite.prototype.preUpdate = function() { } +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateCache +* @memberof Phaser.Sprite +*/ Phaser.Sprite.prototype.updateCache = function() { // |a c tx| @@ -16179,6 +16235,12 @@ Phaser.Sprite.prototype.updateCache = function() { } +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateAnimation +* @memberof Phaser.Sprite +*/ Phaser.Sprite.prototype.updateAnimation = function() { if (this.currentFrame && this.currentFrame.uuid != this._cache.frameID) @@ -16191,244 +16253,41 @@ Phaser.Sprite.prototype.updateAnimation = function() { if (this._cache.dirty && this.currentFrame) { - this._cache.width = Math.floor(this.currentFrame.sourceSizeW * this._cache.scaleX); - this._cache.height = Math.floor(this.currentFrame.sourceSizeH * this._cache.scaleY); + 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.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.updateBounds(); - } - -} - -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.x; - this._cache.y = this.game.camera.view.y + this.y; - } - else - { - 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; - } - } - -} - -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 == null || this.game.cache.checkImageKey(key) == false) - { - key = '__default'; - } - - 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); - } - } - - this.updateAnimation(); - -} - -Phaser.Sprite.prototype.deltaAbsX = function () { - return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); -} - -Phaser.Sprite.prototype.deltaAbsY = function () { - return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); -} - -Phaser.Sprite.prototype.deltaX = function () { - return this.x - this.prevX; -} - -Phaser.Sprite.prototype.deltaY = function () { - return this.y - this.prevY; -} - -/** -* Moves the sprite so its center is located on the given x and y coordinates. -* Doesn't change the origin of the sprite. -* -* @method Phaser.Sprite.prototype.centerOn -* @param {number} x - Description. -* @param {number} y - Description. -*/ -Phaser.Sprite.prototype.centerOn = function(x, y) { - - this.x = x + (this.x - this.center.x); - this.y = y + (this.y - this.center.y); - -} - -/** -* Description. -* -* @method Phaser.Sprite.prototype.revive -*/ -Phaser.Sprite.prototype.revive = function(health) { - - if (typeof health === 'undefined') { health = 1; } - - this.alive = true; - this.exists = true; - this.visible = true; - this.health = health; - - this.events.onRevived.dispatch(this); - -} - -/** -* Description. -* -* @method Phaser.Sprite.prototype.kill -*/ -Phaser.Sprite.prototype.kill = function() { - - this.alive = false; - this.exists = false; - this.visible = false; - - if (this.events) - { - this.events.onKilled.dispatch(this); } } /** -* Description. -* -* @method Phaser.Sprite.prototype.destroy -*/ -Phaser.Sprite.prototype.destroy = function() { - - if (this.group) - { - this.group.remove(this); - } - - this.input.destroy(); - this.events.destroy(); - this.animations.destroy(); - - this.alive = false; - this.exists = false; - this.visible = false; - - this.game = null; - -} - -/** -* Description. -* -* @method Phaser.Sprite.prototype.kill -*/ -Phaser.Sprite.prototype.damage = function(amount) { - - if (this.alive) - { - this.health -= amount; - - if (this.health < 0) - { - this.kill(); - } - } - -} - -/** -* Description. -* -* @method Phaser.Sprite.prototype.reset -*/ -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(); - } - -} - -/** -* Description. -* -* @method Phaser.Sprite.prototype.updateBounds +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateBounds +* @memberof Phaser.Sprite */ Phaser.Sprite.prototype.updateBounds = function() { - // Update the edge points + var sx = 1; + var sy = 1; - this.offset.setTo(this._cache.a02 - (this.anchor.x * this._cache.width), this._cache.a12 - (this.anchor.y * this._cache.height)); + if (this.worldTransform[3] !== 0 || this.worldTransform[1] !== 0) + { + sx = this.scale.x; + sy = this.scale.y; + } - this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight); - this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y); - this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y); - this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height); - this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height); + 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), sx, sy); + this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y, sx, sy); + this.getLocalPosition(this.topRight, this.offset.x + this.width, this.offset.y, sx, sy); + this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this.height, sx, sy); + this.getLocalPosition(this.bottomRight, this.offset.x + this.width, this.offset.y + this.height, sx, sy); 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); @@ -16440,6 +16299,8 @@ Phaser.Sprite.prototype.updateBounds = function() { // This is the coordinate the Sprite was at when the last bounds was created this._cache.boundsX = this._cache.x; this._cache.boundsY = this._cache.y; + + this.updateFrame = true; if (this.inWorld == false) { @@ -16472,45 +16333,407 @@ Phaser.Sprite.prototype.updateBounds = function() { } /** -* Description. +* Gets the local position of a coordinate relative to the Sprite, factoring in rotation and scale. +* Mostly only used internally. * -* @method Phaser.Sprite.prototype.getLocalPosition -* @param {Description} p - Description. -* @param {number} x - Description. -* @param {number} y - Description. -* @return {Description} Description. +* @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) { +Phaser.Sprite.prototype.getLocalPosition = function(p, x, y, sx, sy) { - 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._cache.scaleX) + 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._cache.scaleY) + this._cache.a12; + 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) * sx) + 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) * sy) + this._cache.a12; return p; } /** -* Description. +* 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.prototype.getLocalUnmodifiedPosition -* @param {Description} p - Description. -* @param {number} x - Description. -* @param {number} y - Description. -* @return {Description} Description. +* @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, x, y) { +Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, gx, gy) { - p.x = this._cache.a11 * this._cache.idi * x + -this._cache.i01 * this._cache.idi * y + (this._cache.a12 * this._cache.i01 - this._cache.a02 * this._cache.a11) * this._cache.idi; - p.y = this._cache.a00 * this._cache.idi * y + -this._cache.i10 * this._cache.idi * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.i10) * this._cache.idi; + var a00 = this.worldTransform[0], a01 = this.worldTransform[1], a02 = this.worldTransform[2], + a10 = this.worldTransform[3], a11 = this.worldTransform[4], a12 = this.worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10), + x = a11 * id * gx + -a01 * id * gy + (a12 * a01 - a02 * a11) * id, + y = a00 * id * gy + -a10 * id * gx + (-a12 * a00 + a02 * a10) * id; + + p.x = x + (this.anchor.x * this._cache.width); + p.y = y + (this.anchor.y * this._cache.height); return p; } /** -* Description. +* 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.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); + } + +} + +/** +* 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.x; + this._cache.y = this.game.camera.view.y + this.y; + } + else + { + 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; + } + } + +} + +/** +* 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]); + } + } + +} + +/** +* Returns the absolute delta x value. +* +* @method Phaser.Sprite#deltaAbsX +* @memberof Phaser.Sprite +* @return {number} The absolute delta value. +*/ +Phaser.Sprite.prototype.deltaAbsX = function () { + return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); +} + +/** +* Returns the absolute delta y value. +* +* @method Phaser.Sprite#deltaAbsY +* @memberof Phaser.Sprite +* @return {number} The absolute delta value. +*/ +Phaser.Sprite.prototype.deltaAbsY = function () { + return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); +} + +/** +* Returns the delta x value. +* +* @method Phaser.Sprite#deltaX +* @memberof Phaser.Sprite +* @return {number} The delta value. +*/ +Phaser.Sprite.prototype.deltaX = function () { + return this.x - this.prevX; +} + +/** +* Returns the delta y value. +* +* @method Phaser.Sprite#deltaY +* @memberof Phaser.Sprite +* @return {number} The delta value. +*/ +Phaser.Sprite.prototype.deltaY = function () { + return this.y - this.prevY; +} + +/** +* 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.prototype.bringToTop +* @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() { @@ -16523,16 +16746,19 @@ Phaser.Sprite.prototype.bringToTop = function() { 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 play -* @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. +* @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. */ @@ -16540,7 +16766,7 @@ Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete) if (this.animations) { - this.animations.play(name, frameRate, loop, killOnComplete); + return this.animations.play(name, frameRate, loop, killOnComplete); } } @@ -16565,11 +16791,8 @@ Object.defineProperty(Phaser.Sprite.prototype, 'angle', { }); /** -* Get the animation frame number. -* @returns {Description} -*//** -* Set the animation frame by frame number. -* @param {Description} value - Description +* @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", { @@ -16584,11 +16807,8 @@ Object.defineProperty(Phaser.Sprite.prototype, "frame", { }); /** -* Get the animation frame name. -* @returns {Description} -*//** -* Set the animation frame by frame name. -* @param {Description} value - Description +* @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", { @@ -16603,8 +16823,9 @@ Object.defineProperty(Phaser.Sprite.prototype, "frameName", { }); /** -* Is this sprite visible to the camera or not? -* @returns {boolean} +* @name Phaser.Sprite#inCamera +* @property {boolean} inCamera - Is this sprite visible to the camera or not? +* @readonly */ Object.defineProperty(Phaser.Sprite.prototype, "inCamera", { @@ -16615,66 +16836,57 @@ Object.defineProperty(Phaser.Sprite.prototype, "inCamera", { }); /** -* Get the input enabled state of this Sprite. -* @returns {Description} -*//** -* Set the ability for this sprite to receive input events. -* @param {Description} value - Description +* 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, "crop", { - - get: function () { - - return this._cropRect; +Object.defineProperty(Phaser.Sprite.prototype, 'width', { + get: function() { + return this.scale.x * this.currentFrame.width; }, - set: function (value) { + set: function(value) { - if (value instanceof Phaser.Rectangle) - { - if (this._cropUUID == null) - { - this._cropUUID = this.game.rnd.uuid(); + this.scale.x = value / this.currentFrame.width; + this._cache.scaleX = value / this.currentFrame.width; + this._width = value; - PIXI.TextureCache[this._cropUUID] = new PIXI.Texture(PIXI.BaseTextureCache[this.key], { - x: Math.floor(value.x), - y: Math.floor(value.y), - width: Math.floor(value.width), - height: Math.floor(value.height) - }); - } - else - { - PIXI.TextureCache[this._cropUUID].frame = value; - } - - this._cropRect = value; - this.setTexture(PIXI.TextureCache[this._cropUUID]); - } - else - { - this._cropRect = null; - - if (this.animations.isLoaded) - { - this.animations.refreshFrame(); - } - else - { - this.setTexture(PIXI.TextureCache[this.key]); - } - } } }); /** -* Get the input enabled state of this Sprite. -* @returns {Description} -*//** -* Set the ability for this sprite to receive input events. -* @param {Description} value - Description +* 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", { @@ -16709,21 +16921,19 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.TileSprite */ /** * Create a new TileSprite. * @class Phaser.Tilemap -* @classdesc Class description. * @constructor * @param {Phaser.Game} game - Current game instance. -* @param {object} x - Description. -* @param {object} y - Description. -* @param {number} width - Description. -* @param {number} height - Description. -* @param {string} key - Description. -* @param {Description} frame - Description. +* @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) { @@ -16769,19 +16979,17 @@ Phaser.TileSprite.prototype.constructor = Phaser.TileSprite; * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.Text */ /** * Create a new Text. * @class Phaser.Text -* @classdesc Description of class. * @constructor * @param {Phaser.Game} game - Current game instance. -* @param {Description} x - Description. -* @param {Description} y - Description. -* @param {string} text - Description. -* @param {string} style - Description. +* @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) { @@ -16993,20 +17201,17 @@ Object.defineProperty(Phaser.Text.prototype, 'font', { * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.BitmapText */ /** -* 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. -* +* Creates a new BitmapText. * @class Phaser.BitmapText * @constructor * @param {Phaser.Game} game - A reference to the currently running game. -* @param {number} x - X position of Description. -* @param {number} y - Y position of Description. -* @param {string} text - Description. -* @param {string} style - Description. +* @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) { @@ -17223,7 +17428,6 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'y', { * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.Button */ @@ -17545,18 +17749,17 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) { * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.Graphics */ /** -* Description. +* Creates a new Graphics object. * * @class Phaser.Graphics * @constructor * * @param {Phaser.Game} game Current game instance. -* @param {number} [x] X position of Description. -* @param {number} [y] Y position of Description. +* @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) { @@ -17634,18 +17837,16 @@ Object.defineProperty(Phaser.Graphics.prototype, 'y', { * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.RenderTexture */ /** -* Description of constructor. +* A dynamic initially blank canvas to which images can be drawn * @class Phaser.RenderTexture -* @classdesc Description of class. * @constructor * @param {Phaser.Game} game - Current game instance. -* @param {string} key - Description. -* @param {number} width - Description. -* @param {number} height - Description. +* @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) { @@ -17655,19 +17856,19 @@ Phaser.RenderTexture = function (game, key, width, height) { this.game = game; /** - * @property {Description} name - Description. + * @property {string} name - the name of the object. */ this.name = key; PIXI.EventTarget.call( this ); /** - * @property {number} width - Description. + * @property {number} width - the width. */ this.width = width || 100; /** - * @property {number} height - Description. + * @property {number} height - the height. */ this.height = height || 100; @@ -18857,6 +19058,16 @@ Phaser.Device.prototype = { 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; + } + else + { + this.webGL = true; + } + this.worker = !!window['Worker']; if ('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled) { @@ -21875,6 +22086,19 @@ Phaser.Rectangle.prototype = { }, + /** + * Runs Math.floor() on the x, y, width and height values of this Rectangle. + * @method Phaser.Rectangle#floorAll + **/ + floorAll: function () { + + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + this.width = Math.floor(this.width); + this.height = Math.floor(this.height); + + }, + /** * Copies the x, y, width and height properties from any given object to this Rectangle. * @method Phaser.Rectangle#copyFrom @@ -22278,7 +22502,7 @@ Phaser.Rectangle.inflate = function (a, dx, dy) { * @return {Phaser.Rectangle} The Rectangle object. */ Phaser.Rectangle.inflatePoint = function (a, point) { - return Phaser.Phaser.Rectangle.inflate(a, point.x, point.y); + return Phaser.Rectangle.inflate(a, point.x, point.y); }; /** @@ -22317,6 +22541,10 @@ Phaser.Rectangle.contains = function (a, x, y) { return (x >= a.x && x <= a.right && y >= a.y && y <= a.bottom); }; +Phaser.Rectangle.containsRaw = function (rx, ry, rw, rh, x, y) { + return (x >= rx && x <= (rx + rw) && y >= ry && y <= (ry + rh)); +}; + /** * 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 Phaser.Rectangle.containsPoint @@ -22325,7 +22553,7 @@ Phaser.Rectangle.contains = function (a, x, y) { * @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ Phaser.Rectangle.containsPoint = function (a, point) { - return Phaser.Phaser.Rectangle.contains(a, point.x, point.y); + return Phaser.Rectangle.contains(a, point.x, point.y); }; /** @@ -24169,6 +24397,12 @@ Phaser.Time.prototype = { this.lastTime = time + this.timeToCall; this.physicsElapsed = 1.0 * (this.elapsed / 1000); + // Clamp the delta + if (this.physicsElapsed > 1) + { + this.physicsElapsed = 1; + } + // Paused? if (this.game.paused) { @@ -25044,33 +25278,55 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { * * @method Phaser.Animation.generateFrameNames * @param {string} prefix - The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'. -* @param {number} min - The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the min is 1. -* @param {number} max - The number to count up to. If your frames are named 'explosion_0001' to 'explosion_0034' the max is 34. +* @param {number} start - The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1. +* @param {number} stop - The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34. * @param {string} [suffix=''] - The end of the filename. If the filename was 'explosion_0001-large' the prefix would be '-large'. * @param {number} [zeroPad=0] - The number of zeroes to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4. */ -Phaser.Animation.generateFrameNames = function (prefix, min, max, suffix, zeroPad) { +Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zeroPad) { if (typeof suffix == 'undefined') { suffix = ''; } var output = []; var frame = ''; - for (var i = min; i <= max; i++) + if (start < stop) { - if (typeof zeroPad == 'number') + for (var i = start; i <= stop; i++) { - // str, len, pad, dir - frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1); + if (typeof zeroPad == 'number') + { + // str, len, pad, dir + frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1); + } + else + { + frame = i.toString(); + } + + frame = prefix + frame + suffix; + + output.push(frame); } - else + } + else + { + for (var i = start; i >= stop; i--) { - frame = i.toString(); + if (typeof zeroPad == 'number') + { + // str, len, pad, dir + frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1); + } + else + { + frame = i.toString(); + } + + frame = prefix + frame + suffix; + + output.push(frame); } - - frame = prefix + frame + suffix; - - output.push(frame); } return output; @@ -26060,7 +26316,8 @@ Phaser.Cache.prototype = { addImage: function (key, url, data) { this._images[key] = { url: url, data: data, spriteSheet: false }; - this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, '', ''); + + this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, key, this.game.rnd.uuid()); PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); @@ -26755,6 +27012,7 @@ Phaser.Loader.prototype = { } sprite.crop = this.preloadSprite.crop; + sprite.cropEnabled = true; }, @@ -27529,7 +27787,7 @@ Phaser.Loader.prototype = { break; case 'text': - file.data = this._xhr.response; + file.data = this._xhr.responseText; this.game.cache.addText(file.key, file.url, file.data); break; } @@ -27549,7 +27807,7 @@ Phaser.Loader.prototype = { */ jsonLoadComplete: function (key) { - var data = JSON.parse(this._xhr.response); + var data = JSON.parse(this._xhr.responseText); var file = this._fileList[key]; if (file.type == 'tilemap') @@ -27573,7 +27831,7 @@ Phaser.Loader.prototype = { */ csvLoadComplete: function (key) { - var data = this._xhr.response; + var data = this._xhr.responseText; var file = this._fileList[key]; this.game.cache.addTilemap(file.key, file.url, data, file.format); @@ -27608,7 +27866,7 @@ Phaser.Loader.prototype = { */ xmlLoadComplete: function (key) { - var data = this._xhr.response; + var data = this._xhr.responseText; var xml; try @@ -27902,8 +28160,7 @@ Phaser.Sound = function (game, key, volume, loop) { /** * Description. - * @property {number} autoplay - * @default + * @property {number} stopTime */ this.stopTime = 0; @@ -27914,6 +28171,18 @@ Phaser.Sound = function (game, key, volume, loop) { */ this.paused = false; + /** + * Description. + * @property {number} pausedPosition + */ + this.pausedPosition = 0; + + /** + * Description. + * @property {number} pausedTime + */ + this.pausedTime = 0; + /** * Description. * @property {boolean} isPlaying @@ -28411,10 +28680,13 @@ Phaser.Sound.prototype = { this.stop(); this.isPlaying = false; this.paused = true; + this.pausedPosition = this.currentTime; + this.pausedTime = this.game.time.now; this.onPause.dispatch(this); } }, + /** * Resumes the sound * @method Phaser.Sound#resume @@ -28425,14 +28697,20 @@ Phaser.Sound.prototype = { { if (this.usingWebAudio) { + var p = this.position + (this.pausedPosition / 1000); + + this._sound = this.context.createBufferSource(); + this._sound.buffer = this._buffer; + this._sound.connect(this.gainNode); + if (typeof this._sound.start === 'undefined') { - this._sound.noteGrainOn(0, this.position, this.duration); + this._sound.noteGrainOn(0, p, this.duration); //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it } else { - this._sound.start(0, this.position, this.duration); + this._sound.start(0, p, this.duration); } } else @@ -28442,6 +28720,7 @@ Phaser.Sound.prototype = { this.isPlaying = true; this.paused = false; + this.startTime += (this.game.time.now - this.pausedTime); this.onResume.dispatch(this); } @@ -29241,14 +29520,16 @@ Phaser.Utils.Debug.prototype = { showText = showText || false; showBounds = showBounds || false; - color = color || 'rgb(255,0,255)'; + color = color || 'rgb(255,255,255)'; this.start(0, 0, color); if (showBounds) { - this.context.strokeStyle = 'rgba(255,0,255,0.5)'; + this.context.beginPath(); + this.context.strokeStyle = 'rgba(0, 255, 0, 0.7)'; this.context.strokeRect(sprite.bounds.x, sprite.bounds.y, sprite.bounds.width, sprite.bounds.height); + this.context.closePath(); this.context.stroke(); } @@ -29258,7 +29539,7 @@ Phaser.Utils.Debug.prototype = { this.context.lineTo(sprite.bottomRight.x, sprite.bottomRight.y); this.context.lineTo(sprite.bottomLeft.x, sprite.bottomLeft.y); this.context.closePath(); - this.context.strokeStyle = 'rgba(0,0,255,0.8)'; + this.context.strokeStyle = 'rgba(255, 0, 255, 0.7)'; this.context.stroke(); this.renderPoint(sprite.center); @@ -30238,55 +30519,175 @@ Phaser.Color = { }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @class Phaser.Physics +*/ Phaser.Physics = {}; +/** +* Arcade Physics constructor. +* +* @class Phaser.Physics.Arcade +* @classdesc Arcade Physics Constructor +* @constructor +* @param {Phaser.Game} game reference to the current game instance. +*/ Phaser.Physics.Arcade = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + /** + * @property {Phaser.Point} gravity - The World gravity setting. Defaults to x: 0, y: 0, or no gravity. + */ this.gravity = new Phaser.Point; + + /** + * @property {Phaser.Rectangle} bounds - The bounds inside of which the physics world exists. Defaults to match the world bounds. + */ this.bounds = new Phaser.Rectangle(0, 0, game.world.width, game.world.height); /** - * Used by the QuadTree to set the maximum number of objects - * @type {number} + * @property {number} maxObjects - Used by the QuadTree to set the maximum number of objects per quad. */ this.maxObjects = 10; /** - * Used by the QuadTree to set the maximum number of levels - * @type {number} + * @property {number} maxLevels - Used by the QuadTree to set the maximum number of iteration levels. */ this.maxLevels = 4; + /** + * @property {number} OVERLAP_BIAS - A value added to the delta values during collision checks. + */ this.OVERLAP_BIAS = 4; - this.TILE_OVERLAP = false; + /** + * @property {Phaser.QuadTree} quadTree - The world QuadTree. + */ this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels); + + /** + * @property {number} quadTreeID - The QuadTree ID. + */ this.quadTreeID = 0; // Avoid gc spikes by caching these values for re-use + + /** + * @property {Phaser.Rectangle} _bounds1 - Internal cache var. + * @private + */ this._bounds1 = new Phaser.Rectangle; + + /** + * @property {Phaser.Rectangle} _bounds2 - Internal cache var. + * @private + */ this._bounds2 = new Phaser.Rectangle; + + /** + * @property {number} _overlap - Internal cache var. + * @private + */ this._overlap = 0; + + /** + * @property {number} _maxOverlap - Internal cache var. + * @private + */ this._maxOverlap = 0; + + /** + * @property {number} _velocity1 - Internal cache var. + * @private + */ this._velocity1 = 0; + + /** + * @property {number} _velocity2 - Internal cache var. + * @private + */ this._velocity2 = 0; + + /** + * @property {number} _newVelocity1 - Internal cache var. + * @private + */ this._newVelocity1 = 0; + + /** + * @property {number} _newVelocity2 - Internal cache var. + * @private + */ this._newVelocity2 = 0; + + /** + * @property {number} _average - Internal cache var. + * @private + */ this._average = 0; + + /** + * @property {Array} _mapData - Internal cache var. + * @private + */ this._mapData = []; + + /** + * @property {number} _mapTiles - Internal cache var. + * @private + */ this._mapTiles = 0; + + /** + * @property {boolean} _result - Internal cache var. + * @private + */ this._result = false; + + /** + * @property {number} _total - Internal cache var. + * @private + */ this._total = 0; + + /** + * @property {number} _angle - Internal cache var. + * @private + */ this._angle = 0; + + /** + * @property {number} _dx - Internal cache var. + * @private + */ this._dx = 0; + + /** + * @property {number} _dy - Internal cache var. + * @private + */ this._dy = 0; }; Phaser.Physics.Arcade.prototype = { + /** + * Called automatically by a Physics body, it updates all motion related values on the Body. + * + * @method Phaser.Physics.Arcade#updateMotion + * @param {Phaser.Physics.Arcade.Body} The Body object to be updated. + */ updateMotion: function (body) { // If you're wondering why the velocity is halved and applied twice, read this: http://www.niksula.hut.fi/~hkankaan/Homepages/gravity.html @@ -30314,11 +30715,13 @@ Phaser.Physics.Arcade.prototype = { /** * 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. - * + * @method Phaser.Physics.Arcade#computeVelocity + * @param {number} axis - 1 for horizontal, 2 for vertical. + * @param {Phaser.Physics.Arcade.Body} body - The Body object to be updated. + * @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} mMax - An absolute value cap for the velocity. * @return {number} The altered Velocity value. */ computeVelocity: function (axis, body, velocity, acceleration, drag, max) { @@ -30369,6 +30772,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * Called automatically by the core game loop. + * + * @method Phaser.Physics.Arcade#preUpdate + * @protected + */ preUpdate: function () { // Clear the tree @@ -30380,6 +30789,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * Called automatically by the core game loop. + * + * @method Phaser.Physics.Arcade#postUpdate + * @protected + */ postUpdate: function () { // Clear the tree ready for the next update @@ -30388,12 +30803,13 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Checks if two Sprite objects intersect. + * Checks if two Sprite objects overlap. * - * @param object1 The first object to check. Can be an instance of Phaser.Sprite or anything that extends it. - * @param object2 The second object to check. Can be an instance of Phaser.Sprite or anything that extends it. + * @method Phaser.Physics.Arcade#overlap + * @param {Phaser.Sprite} object1 - The first object to check. Can be an instance of Phaser.Sprite or anything that extends it. + * @param {Phaser.Sprite} object2 - The second object to check. Can be an instance of Phaser.Sprite or anything that extends it. * @returns {boolean} true if the two objects overlap. - **/ + */ overlap: function (object1, object2) { // Only test valid objects @@ -30409,14 +30825,16 @@ Phaser.Physics.Arcade.prototype = { /** * Checks for collision between two game objects. The objects can be Sprites, Groups, Emitters or Tilemaps. * You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap or Group vs. Tilemap collisions. + * The objects are also automatically separated. * - * @param object1 The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap - * @param object2 The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap - * @param collideCallback An optional 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 collideCallback will only be called if processCallback returns true. - * @param callbackContext The context in which to run the callbacks. - * @returns {boolean} true if any collisions were detected, otherwise false. - **/ + * @method Phaser.Physics.Arcade#collide + * @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object1 - The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap + * @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object2 - The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap + * @param {function} [collideCallback=null] - An optional 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 {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collideCallback will only be called if processCallback returns true. + * @param {object} [callbackContext] - The context in which to run the callbacks. + * @returns {number} The number of collisions that were processed. + */ collide: function (object1, object2, collideCallback, processCallback, callbackContext) { collideCallback = collideCallback || null; @@ -30497,6 +30915,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideSpriteVsTilemapLayer + * @private + */ collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext) { this._mapData = tilemapLayer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true); @@ -30537,6 +30961,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideGroupVsTilemapLayer + * @private + */ collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext) { if (group.length == 0) @@ -30561,6 +30991,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideSpriteVsSprite + * @private + */ collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext) { this.separate(sprite1.body, sprite2.body); @@ -30593,6 +31029,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideSpriteVsGroup + * @private + */ collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext) { if (group.length == 0) @@ -30629,6 +31071,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideGroupVsGroup + * @private + */ collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext) { if (group1.length == 0 || group2.length == 0) @@ -30653,12 +31101,13 @@ Phaser.Physics.Arcade.prototype = { }, - /** - * The core separation function to separate two physics bodies. - * @param body1 The first Sprite.Body to separate - * @param body2 The second Sprite.Body to separate - * @returns {boolean} Returns true if the bodies were separated, otherwise false. - */ + /** + * The core separation function to separate two physics bodies. + * @method Phaser.Physics.Arcade#separate + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separate: function (body1, body2) { this._result = (this.separateX(body1, body2) || this.separateY(body1, body2)); @@ -30666,11 +31115,12 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Separates the two physics bodies on their X axis - * @param body1 The first Sprite.Body to separate - * @param body2 The second Sprite.Body to separate - * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. - */ + * The core separation function to separate two physics bodies on the x axis. + * @method Phaser.Physics.Arcade#separateX + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separateX: function (body1, body2) { // Can't separate two immovable bodies @@ -30773,11 +31223,12 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Separates the two physics bodies on their Y axis - * @param body1 The first Sprite.Body to separate - * @param body2 The second Sprite.Body to separate - * @returns {boolean} Whether the bodys in fact touched and were separated along the Y axis. - */ + * The core separation function to separate two physics bodies on the y axis. + * @method Phaser.Physics.Arcade#separateY + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separateY: function (body1, body2) { // Can't separate two immovable or non-existing bodys @@ -30892,12 +31343,13 @@ Phaser.Physics.Arcade.prototype = { }, - /** - * The core Collision separation function used by Collision.overlap. - * @param object1 The first GameObject to separate - * @param object2 The second GameObject to separate - * @returns {boolean} Returns true if the objects were separated, otherwise false. - */ + /** + * The core separation function to separate a physics body and a tile. + * @method Phaser.Physics.Arcade#separateTile + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Tile} tile - The tile to collide against. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separateTile: function (body, tile) { this._result = (this.separateTileX(body, tile, true) || this.separateTileY(body, tile, true)); @@ -30905,11 +31357,12 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Separates the two objects on their x axis - * @param object The GameObject to separate - * @param tile The Tile to separate - * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. - */ + * The core separation function to separate a physics body and a tile on the x axis. + * @method Phaser.Physics.Arcade#separateTileX + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Tile} tile - The tile to collide against. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separateTileX: function (body, tile, separate) { // Can't separate two immovable objects (tiles are always immovable) @@ -30988,11 +31441,12 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Separates the two objects on their x axis - * @param object The GameObject to separate - * @param tile The Tile to separate - * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. - */ + * The core separation function to separate a physics body and a tile on the x axis. + * @method Phaser.Physics.Arcade#separateTileY + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Tile} tile - The tile to collide against. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separateTileY: function (body, tile, separate) { // Can't separate two immovable objects (tiles are always immovable) @@ -31436,87 +31890,321 @@ Phaser.Physics.Arcade.prototype = { }; +/** +* @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. All physics operations should be performed against the body rather than +* the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body. +* +* @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} x - The x position of the physics body. + * @readonly + */ this.x = sprite.x; + + /** + * @property {number} y - The y position of the physics body. + * @readonly + */ this.y = sprite.y; + + /** + * @property {number} preX - The previous x position of the physics body. + * @readonly + */ this.preX = sprite.x; + + /** + * @property {number} preY - The previous y position of the physics body. + * @readonly + */ this.preY = sprite.y; + + /** + * @property {number} preRotation - The previous rotation of the physics body. + * @readonly + */ this.preRotation = sprite.angle; + + /** + * @property {number} screenX - The x position of the physics body translated to screen space. + * @readonly + */ this.screenX = sprite.x; + + /** + * @property {number} screenY - The y position of the physics body translated to screen space. + * @readonly + */ this.screenY = sprite.y; - // un-scaled original size + /** + * @property {number} sourceWidth - The un-scaled original size. + * @readonly + */ this.sourceWidth = sprite.currentFrame.sourceSizeW; + + /** + * @property {number} sourceHeight - The un-scaled original size. + * @readonly + */ this.sourceHeight = sprite.currentFrame.sourceSizeH; - // calculated (scaled) size + /** + * @property {number} width - The calculated width of the physics body. + */ this.width = sprite.currentFrame.sourceSizeW; + + /** + * @property .numInternal ID cache + */ this.height = sprite.currentFrame.sourceSizeH; + + /** + * @property {number} halfWidth - The calculated width / 2 of the physics body. + */ this.halfWidth = Math.floor(sprite.currentFrame.sourceSizeW / 2); + + /** + * @property {number} halfHeight - The calculated height / 2 of the physics body. + */ this.halfHeight = Math.floor(sprite.currentFrame.sourceSizeH / 2); - // Scale value cache + /** + * @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 {Phaser.Point} velocity - The velocity in pixels per second sq. of the Body. + */ this.velocity = new Phaser.Point; + + /** + * @property {Phaser.Point} acceleration - The velocity in pixels per second sq. of the Body. + */ this.acceleration = new Phaser.Point; + + /** + * @property {Phaser.Point} drag - The drag applied to the motion of the Body. + */ this.drag = new Phaser.Point; + + /** + * @property {Phaser.Point} gravity - A private Gravity setting for the Body. + */ this.gravity = new Phaser.Point; + + /** + * @property {Phaser.Point} bounce - The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity. + */ this.bounce = new Phaser.Point; + + /** + * @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach. + * @default + */ this.maxVelocity = new Phaser.Point(10000, 10000); + /** + * @property {number} angularVelocity - The angular velocity in pixels per second sq. of the Body. + * @default + */ this.angularVelocity = 0; + + /** + * @property {number} angularAcceleration - The angular acceleration in pixels per second sq. of the Body. + * @default + */ this.angularAcceleration = 0; + + /** + * @property {number} angularDrag - The angular drag applied to the rotation of the Body. + * @default + */ this.angularDrag = 0; + + /** + * @property {number} maxAngular - The maximum angular velocity in pixels per second sq. that the Body can reach. + * @default + */ this.maxAngular = 1000; + + /** + * @property {number} mass - The mass of the Body. + * @default + */ this.mass = 1; + /** + * @property {boolean} skipQuadTree - If the Body is an irregular shape you can set this to true to avoid it being added to the World quad tree. + * @default + */ this.skipQuadTree = false; + + /** + * @property {Array} quadTreeIDs - Internal ID cache. + * @protected + */ this.quadTreeIDs = []; + + /** + * @property {number} quadTreeIndex - Internal ID cache. + * @protected + */ this.quadTreeIndex = -1; // Allow collision + + /** + * Set the allowCollision properties to control which directions collision is processed for this Body. + * For example allowCollision.up = false means it won't collide when the collision happened while moving up. + * @property {object} allowCollision - An object containing allowed collision. + */ this.allowCollision = { 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 previous touching values from the bodies previous collision. + * @property {object} wasTouching - An object containing previous touching results. + */ this.wasTouching = { none: true, 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} immovable - An immovable Body will not receive any impacts from other bodies. + * @default + */ this.immovable = false; + + /** + * @property {boolean} moves - Set to true to allow the Physics system to move this Body, other false to move it manually. + * @default + */ this.moves = true; + + /** + * @property {number} rotation - The amount the Body is rotated. + * @default + */ this.rotation = 0; + + /** + * @property {boolean} allowRotation - Allow this Body to be rotated? (via angularVelocity, etc) + * @default + */ this.allowRotation = true; + + /** + * @property {boolean} allowGravity - Allow this Body to be influenced by the global Gravity? + * @default + */ this.allowGravity = true; - // These two flags allow you to disable the custom separation that takes place - // Used in combination with your own collision processHandler you can create whatever - // type of collision response you need. + /** + * This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate. + * Used in combination with your own collision processHandler you can create whatever type of collision response you need. + * @property {boolean} customSeparateX - Use a custom separation system or the built-in one? + * @default + */ this.customSeparateX = false; + + /** + * This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate. + * Used in combination with your own collision processHandler you can create whatever type of collision response you need. + * @property {boolean} customSeparateY - Use a custom separation system or the built-in one? + * @default + */ this.customSeparateY = false; - // When this body collides with another the amount of overlap is stored in here - // These values are useful if you want to provide your own custom separation logic. + /** + * When this body collides with another, the amount of overlap is stored here. + * @property {number} overlapX - The amount of horizontal overlap during the collision. + */ this.overlapX = 0; + + /** + * When this body collides with another, the amount of overlap is stored here. + * @property {number} overlapY - The amount of vertical overlap during the collision. + */ this.overlapY = 0; + /** + * @property {Phaser.Rectangle} hullX - The dynamically calculated hull used during collision. + */ this.hullX = new Phaser.Rectangle(); + + /** + * @property {Phaser.Rectangle} hullY - The dynamically calculated hull used during collision. + */ this.hullY = new Phaser.Rectangle(); - // If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true + /** + * If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true. + * @property {boolean} embedded - Body embed value. + */ this.embedded = false; + /** + * 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; }; Phaser.Physics.Arcade.Body.prototype = { + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#updateBounds + * @protected + */ updateBounds: function (centerX, centerY, scaleX, scaleY) { if (scaleX != this._sx || scaleY != this._sy) @@ -31531,6 +32219,12 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#preUpdate + * @protected + */ preUpdate: function () { // Store and reset collision flags @@ -31551,9 +32245,6 @@ Phaser.Physics.Arcade.Body.prototype = { this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; - // this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; - // this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; - this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; @@ -31572,8 +32263,7 @@ Phaser.Physics.Arcade.Body.prototype = { this.checkWorldBounds(); } - this.updateHulls(); - } + this.updateHulls();Array } if (this.skipQuadTree == false && this.allowCollision.none == false && this.sprite.visible && this.sprite.alive) { @@ -31584,6 +32274,12 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#postUpdate + * @protected + */ postUpdate: function () { // Calculate forward-facing edge @@ -31624,6 +32320,12 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#updateHulls + * @protected + */ updateHulls: function () { this.hullX.setTo(this.x, this.preY, this.width, this.height); @@ -31631,6 +32333,12 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#checkWorldBounds + * @protected + */ checkWorldBounds: function () { if (this.x < this.game.world.bounds.x) @@ -31657,6 +32365,17 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * You can modify the size of the physics Body to be any dimension you need. + * So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which + * is the position of the Body relative to the top-left of the Sprite. + * + * @method Phaser.Physics.Arcade#setSize + * @param {number} width - The width of the Body. + * @param {number} height - The height of the Body. + * @param {number} offsetX - The X offset of the Body from the Sprite position. + * @param {number} offsetY - The Y offset of the Body from the Sprite position. + */ setSize: function (width, height, offsetX, offsetY) { offsetX = offsetX || this.offset.x; @@ -31672,6 +32391,11 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * Resets all Body values (velocity, acceleration, rotation, etc) + * + * @method Phaser.Physics.Arcade#reset + */ reset: function () { this.velocity.setTo(0, 0); @@ -31679,11 +32403,8 @@ Phaser.Physics.Arcade.Body.prototype = { this.angularVelocity = 0; this.angularAcceleration = 0; - this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; - // this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; - // this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; this.preRotation = this.sprite.angle; this.x = this.preX; @@ -31692,18 +32413,42 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * Returns the absolute delta x value. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsX + * @return {number} The absolute delta value. + */ deltaAbsX: function () { return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); }, + /** + * Returns the absolute delta y value. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsY + * @return {number} The absolute delta value. + */ deltaAbsY: function () { return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); }, + /** + * Returns the delta x value. + * + * @method Phaser.Physics.Arcade.Body#deltaX + * @return {number} The delta value. + */ deltaX: function () { return this.x - this.preX; }, + /** + * Returns the delta y value. + * + * @method Phaser.Physics.Arcade.Body#deltaY + * @return {number} The delta value. + */ deltaY: function () { return this.y - this.preY; }, @@ -31714,6 +32459,10 @@ Phaser.Physics.Arcade.Body.prototype = { }; +/** +* @name Phaser.Physics.Arcade.Body#bottom +* @property {number} bottom - The bottom value of this Body (same as Body.y + Body.height) +*/ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { /** @@ -31745,6 +32494,10 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { }); +/** +* @name Phaser.Physics.Arcade.Body#right +* @property {number} right - The right value of this Body (same as Body.x + Body.width) +*/ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { /** @@ -34289,7 +35042,5 @@ PIXI.WebGLBatch.prototype.update = function() displayObject = displayObject.__next; } } - - - return Phaser; -})); \ No newline at end of file + return Phaser; +}); \ No newline at end of file diff --git a/build/phaser.min.js b/build/phaser.min.js index 197bc293..07445092 100644 --- a/build/phaser.min.js +++ b/build/phaser.min.js @@ -1 +1,10 @@ -var PIXI=PIXI||{};var Phaser=Phaser||{VERSION:"1.0.5",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};PIXI.InteractionManager=function(b){};Phaser.Utils={pad:function(g,b,f,c){if(typeof(b)=="undefined"){var b=0}if(typeof(f)=="undefined"){var f=" "}if(typeof(c)=="undefined"){var c=3}if(b+1>=g.length){switch(c){case 1:g=Array(b+1-g.length).join(f)+g;break;case 3:var d=Math.ceil((padlen=b-g.length)/2);var e=padlen-d;g=Array(e+1).join(f)+g+Array(d+1).join(f);break;default:g=g+Array(b+1-g.length).join(f);break}}return g},isPlainObject:function(c){if(typeof(c)!=="object"||c.nodeType||c===c.window){return false}try{if(c.constructor&&!hasOwn.call(c.constructor.prototype,"isPrototypeOf")){return false}}catch(b){return false}return true},extend:function(){var l,d,b,c,h,j,g=arguments[0]||{},f=1,e=arguments.length,k=false;if(typeof g==="boolean"){k=g;g=arguments[1]||{};f=2}if(e===f){g=this;--f}for(;f>16&255)/255,(b>>8&255)/255,(b&255)/255]}if(typeof Function.prototype.bind!="function"){Function.prototype.bind=(function(){var b=Array.prototype.slice;return function(c){var f=this,g=b.call(arguments,1);if(typeof f!="function"){throw new TypeError()}function d(){var h=g.concat(b.call(arguments));f.apply(this instanceof d?this:c,h)}d.prototype=(function e(h){h&&(e.prototype=h);if(!(this instanceof e)){return new e}})(f.prototype);return d}})()}function determineMatrixArrayType(){PIXI.Matrix=(typeof Float32Array!=="undefined")?Float32Array:Array;return PIXI.Matrix}determineMatrixArrayType();PIXI.mat3={};PIXI.mat3.create=function(){var b=new PIXI.Matrix(9);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat3.identity=function(b){b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat4={};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat3.multiply=function(q,h,i){if(!i){i=q}var v=q[0],u=q[1],t=q[2],g=q[3],f=q[4],e=q[5],o=q[6],n=q[7],m=q[8],l=h[0],k=h[1],j=h[2],s=h[3],r=h[4],p=h[5],d=h[6],c=h[7],b=h[8];i[0]=l*v+k*g+j*o;i[1]=l*u+k*f+j*n;i[2]=l*t+k*e+j*m;i[3]=s*v+r*g+p*o;i[4]=s*u+r*f+p*n;i[5]=s*t+r*e+p*m;i[6]=d*v+c*g+b*o;i[7]=d*u+c*f+b*n;i[8]=d*t+c*e+b*m;return i};PIXI.mat3.clone=function(c){var b=new PIXI.Matrix(9);b[0]=c[0];b[1]=c[1];b[2]=c[2];b[3]=c[3];b[4]=c[4];b[5]=c[5];b[6]=c[6];b[7]=c[7];b[8]=c[8];return b};PIXI.mat3.transpose=function(d,c){if(!c||d===c){var f=d[1],e=d[2],b=d[5];d[1]=d[3];d[2]=d[6];d[3]=f;d[5]=d[7];d[6]=e;d[7]=b;return d}c[0]=d[0];c[1]=d[3];c[2]=d[6];c[3]=d[1];c[4]=d[4];c[5]=d[7];c[6]=d[2];c[7]=d[5];c[8]=d[8];return c};PIXI.mat3.toMat4=function(c,b){if(!b){b=PIXI.mat4.create()}b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=c[8];b[9]=c[7];b[8]=c[6];b[7]=0;b[6]=c[5];b[5]=c[4];b[4]=c[3];b[3]=0;b[2]=c[2];b[1]=c[1];b[0]=c[0];return b};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat4.transpose=function(e,d){if(!d||e===d){var i=e[1],g=e[2],f=e[3],b=e[6],h=e[7],c=e[11];e[1]=e[4];e[2]=e[8];e[3]=e[12];e[4]=i;e[6]=e[9];e[7]=e[13];e[8]=g;e[9]=b;e[11]=e[14];e[12]=f;e[13]=h;e[14]=c;return e}d[0]=e[0];d[1]=e[4];d[2]=e[8];d[3]=e[12];d[4]=e[1];d[5]=e[5];d[6]=e[9];d[7]=e[13];d[8]=e[2];d[9]=e[6];d[10]=e[10];d[11]=e[14];d[12]=e[3];d[13]=e[7];d[14]=e[11];d[15]=e[15];return d};PIXI.mat4.multiply=function(p,i,k){if(!k){k=p}var v=p[0],u=p[1],s=p[2],q=p[3];var h=p[4],f=p[5],d=p[6],b=p[7];var o=p[8],n=p[9],m=p[10],l=p[11];var z=p[12],w=p[13],t=p[14],r=p[15];var j=i[0],g=i[1],e=i[2],c=i[3];k[0]=j*v+g*h+e*o+c*z;k[1]=j*u+g*f+e*n+c*w;k[2]=j*s+g*d+e*m+c*t;k[3]=j*q+g*b+e*l+c*r;j=i[4];g=i[5];e=i[6];c=i[7];k[4]=j*v+g*h+e*o+c*z;k[5]=j*u+g*f+e*n+c*w;k[6]=j*s+g*d+e*m+c*t;k[7]=j*q+g*b+e*l+c*r;j=i[8];g=i[9];e=i[10];c=i[11];k[8]=j*v+g*h+e*o+c*z;k[9]=j*u+g*f+e*n+c*w;k[10]=j*s+g*d+e*m+c*t;k[11]=j*q+g*b+e*l+c*r;j=i[12];g=i[13];e=i[14];c=i[15];k[12]=j*v+g*h+e*o+c*z;k[13]=j*u+g*f+e*n+c*w;k[14]=j*s+g*d+e*m+c*t;k[15]=j*q+g*b+e*l+c*r;return k};PIXI.Point=function(b,c){this.x=b||0;this.y=c||0};PIXI.Point.prototype.clone=function(){return new PIXI.Point(this.x,this.y)};PIXI.Point.prototype.constructor=PIXI.Point;PIXI.Rectangle=function(c,e,d,b){this.x=c||0;this.y=e||0;this.width=d||0;this.height=b||0};PIXI.Rectangle.prototype.clone=function(){return new PIXI.Rectangle(this.x,this.y,this.width,this.height)};PIXI.Rectangle.prototype.contains=function(b,e){if(this.width<=0||this.height<=0){return false}var c=this.x;if(b>=c&&b<=c+this.width){var d=this.y;if(e>=d&&e<=d+this.height){return true}}return false};PIXI.Rectangle.prototype.constructor=PIXI.Rectangle;PIXI.DisplayObject=function(){this.last=this;this.first=this;this.position=new PIXI.Point();this.scale=new PIXI.Point(1,1);this.pivot=new PIXI.Point(0,0);this.rotation=0;this.alpha=1;this.visible=true;this.hitArea=null;this.buttonMode=false;this.renderable=false;this.parent=null;this.stage=null;this.worldAlpha=1;this._interactive=false;this.worldTransform=PIXI.mat3.create();this.localTransform=PIXI.mat3.create();this.color=[];this.dynamic=true;this._sr=0;this._cr=1};PIXI.DisplayObject.prototype.constructor=PIXI.DisplayObject;PIXI.DisplayObject.prototype.setInteractive=function(b){this.interactive=b};Object.defineProperty(PIXI.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(b){this._interactive=b;if(this.stage){this.stage.dirty=true}}});Object.defineProperty(PIXI.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(b){this._mask=b;if(b){this.addFilter(b)}else{this.removeFilter()}}});PIXI.DisplayObject.prototype.addFilter=function(j){if(this.filter){return}this.filter=true;var b=new PIXI.FilterBlock();var e=new PIXI.FilterBlock();b.mask=j;e.mask=j;b.first=b.last=this;e.first=e.last=this;b.open=true;var d=b;var f=b;var i;var h;h=this.first._iPrev;if(h){i=h._iNext;d._iPrev=h;h._iNext=d}else{i=this}if(i){i._iPrev=f;f._iNext=i}var d=e;var f=e;var i=null;var h=null;h=this.last;i=h._iNext;if(i){i._iPrev=f;f._iNext=i}d._iPrev=h;h._iNext=d;var c=this;var g=this.last;while(c){if(c.last==g){c.last=e}c=c.parent}this.first=b;if(this.__renderGroup){this.__renderGroup.addFilterBlocks(b,e)}j.renderable=false};PIXI.DisplayObject.prototype.removeFilter=function(){if(!this.filter){return}this.filter=false;var d=this.first;var g=d._iNext;var h=d._iPrev;if(g){g._iPrev=h}if(h){h._iNext=g}this.first=d._iNext;var e=this.last;var g=e._iNext;var h=e._iPrev;if(g){g._iPrev=h}h._iNext=g;var f=e._iPrev;var c=this;while(c.last==e){c.last=f;c=c.parent;if(!c){break}}var b=d.mask;b.renderable=true;if(this.__renderGroup){this.__renderGroup.removeFilterBlocks(d,e)}};PIXI.DisplayObject.prototype.updateTransform=function(){if(this.rotation!==this.rotationCache){this.rotationCache=this.rotation;this._sr=Math.sin(this.rotation);this._cr=Math.cos(this.rotation)}var r=this.localTransform;var f=this.parent.worldTransform;var b=this.worldTransform;r[0]=this._cr*this.scale.x;r[1]=-this._sr*this.scale.y;r[3]=this._sr*this.scale.x;r[4]=this._cr*this.scale.y;var n=this.pivot.x;var m=this.pivot.y;var i=r[0],h=r[1],g=this.position.x-r[0]*n-m*r[1],q=r[3],p=r[4],o=this.position.y-r[4]*m-n*r[3],l=f[0],k=f[1],j=f[2],e=f[3],d=f[4],c=f[5];r[2]=g;r[5]=o;b[0]=l*i+k*q;b[1]=l*h+k*p;b[2]=l*g+k*o+j;b[3]=e*i+d*q;b[4]=e*h+d*p;b[5]=e*g+d*o+c;this.worldAlpha=this.alpha*this.parent.worldAlpha;this.vcount=PIXI.visibleCount};PIXI.visibleCount=0;PIXI.DisplayObjectContainer=function(){PIXI.DisplayObject.call(this);this.children=[]};PIXI.DisplayObjectContainer.prototype=Object.create(PIXI.DisplayObject.prototype);PIXI.DisplayObjectContainer.prototype.constructor=PIXI.DisplayObjectContainer;PIXI.DisplayObjectContainer.prototype.addChild=function(i){if(i.parent!=undefined){i.parent.removeChild(i)}i.parent=this;this.children.push(i);if(this.stage){var f=i;do{if(f.interactive){this.stage.dirty=true}f.stage=this.stage;f=f._iNext}while(f)}var e=i.first;var d=i.last;var g;var h;if(this.filter){h=this.last._iPrev}else{h=this.last}g=h._iNext;var c=this;var b=h;while(c){if(c.last==b){c.last=i.last}c=c.parent}if(g){g._iPrev=d;d._iNext=g}e._iPrev=h;h._iNext=e;if(this.__renderGroup){if(i.__renderGroup){i.__renderGroup.removeDisplayObjectAndChildren(i)}this.__renderGroup.addDisplayObjectAndChildren(i)}};PIXI.DisplayObjectContainer.prototype.addChildAt=function(c,f){if(f>=0&&f<=this.children.length){if(c.parent!=undefined){c.parent.removeChild(c)}c.parent=this;if(this.stage){var e=c;do{if(e.interactive){this.stage.dirty=true}e.stage=this.stage;e=e._iNext}while(e)}var d=c.first;var g=c.last;var j;var i;if(f==this.children.length){i=this.last;var b=this;var h=this.last;while(b){if(b.last==h){b.last=c.last}b=b.parent}}else{if(f==0){i=this}else{i=this.children[f-1].last}}j=i._iNext;if(j){j._iPrev=g;g._iNext=j}d._iPrev=i;i._iNext=d;this.children.splice(f,0,c);if(this.__renderGroup){if(c.__renderGroup){c.__renderGroup.removeDisplayObjectAndChildren(c)}this.__renderGroup.addDisplayObjectAndChildren(c)}}else{throw new Error(c+" The index "+f+" supplied is out of bounds "+this.children.length)}};PIXI.DisplayObjectContainer.prototype.swapChildren=function(c,b){return};PIXI.DisplayObjectContainer.prototype.getChildAt=function(b){if(b>=0&&b1){h=1}var d=Math.sqrt(c.x*c.x+c.y*c.y);var f=this.texture.height/2;c.x/=d;c.y/=d;c.x*=f;c.y*=f;b[g]=m.x+c.x;b[g+1]=m.y+c.y;b[g+2]=m.x-c.x;b[g+3]=m.y-c.y;l=m}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.Rope.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite=function(d,c,b){PIXI.DisplayObjectContainer.call(this);this.texture=d;this.width=c;this.height=b;this.tileScale=new PIXI.Point(1,1);this.tilePosition=new PIXI.Point(0,0);this.renderable=true;this.blendMode=PIXI.blendModes.NORMAL};PIXI.TilingSprite.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.TilingSprite.prototype.constructor=PIXI.TilingSprite;PIXI.TilingSprite.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite.prototype.onTextureUpdate=function(b){this.updateFrame=true};PIXI.FilterBlock=function(b){this.graphics=b;this.visible=true;this.renderable=true};PIXI.MaskFilter=function(b){this.graphics};PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.Graphics.prototype.constructor=PIXI.Graphics;PIXI.Graphics.prototype.lineStyle=function(b,c,d){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.lineWidth=b||0;this.lineColor=c||0;this.lineAlpha=(d==undefined)?1:d;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)};PIXI.Graphics.prototype.moveTo=function(b,c){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(b,c);this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.lineTo=function(b,c){this.currentPath.points.push(b,c);this.dirty=true};PIXI.Graphics.prototype.beginFill=function(b,c){this.filling=true;this.fillColor=b||0;this.fillAlpha=(c==undefined)?1:c};PIXI.Graphics.prototype.endFill=function(){this.filling=false;this.fillColor=null;this.fillAlpha=1};PIXI.Graphics.prototype.drawRect=function(c,e,d,b){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:[c,e,d,b],type:PIXI.Graphics.RECT};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawCircle=function(c,d,b){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:[c,d,b,b],type:PIXI.Graphics.CIRC};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawElipse=function(c,e,d,b){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:[c,e,d,b],type:PIXI.Graphics.ELIP};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.clear=function(){this.lineWidth=0;this.filling=false;this.dirty=true;this.clearDirty=true;this.graphicsData=[]};PIXI.Graphics.POLY=0;PIXI.Graphics.RECT=1;PIXI.Graphics.CIRC=2;PIXI.Graphics.ELIP=3;PIXI.CanvasGraphics=function(){};PIXI.CanvasGraphics.renderGraphics=function(u,c){var p=u.worldAlpha;for(var s=0;s1){t=1;console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object")}for(var s=0;s<1;s++){var A=v.graphicsData[s];var r=A.points;if(A.type==PIXI.Graphics.POLY){c.beginPath();c.moveTo(r[0],r[1]);for(var q=1;q0){PIXI.Texture.frameUpdates=[]}};PIXI.CanvasRenderer.prototype.resize=function(c,b){this.width=c;this.height=b;this.view.width=c;this.view.height=b};PIXI.CanvasRenderer.prototype.renderDisplayObject=function(h){var e;var f=this.context;f.globalCompositeOperation="source-over";var d=h.last._iNext;h=h.first;do{e=h.worldTransform;if(!h.visible){h=h.last._iNext;continue}if(!h.renderable){h=h._iNext;continue}if(h instanceof PIXI.Sprite){var g=h.texture.frame;if(g){f.globalAlpha=h.worldAlpha;f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);f.drawImage(h.texture.baseTexture.source,g.x,g.y,g.width,g.height,(h.anchor.x)*-g.width,(h.anchor.y)*-g.height,g.width,g.height)}}else{if(h instanceof PIXI.Strip){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderStrip(h)}else{if(h instanceof PIXI.TilingSprite){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderTilingSprite(h)}else{if(h instanceof PIXI.CustomRenderable){h.renderCanvas(this)}else{if(h instanceof PIXI.Graphics){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);PIXI.CanvasGraphics.renderGraphics(h,f)}else{if(h instanceof PIXI.FilterBlock){if(h.open){f.save();var c=h.mask.alpha;var b=h.mask.worldTransform;f.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]);h.mask.worldAlpha=0.5;f.worldAlpha=0;PIXI.CanvasGraphics.renderGraphicsMask(h.mask,f);f.clip();h.mask.worldAlpha=c}else{f.restore()}}}}}}}h=h._iNext}while(h!=d)};PIXI.CanvasRenderer.prototype.renderStripFlat=function(d){var e=this.context;var f=d.verticies;var j=d.uvs;var g=f.length/2;this.count++;e.beginPath();for(var k=1;k3){PIXI.WebGLGraphics.buildPoly(d,b._webGL)}}if(d.lineWidth>0){PIXI.WebGLGraphics.buildLine(d,b._webGL)}}else{if(d.type==PIXI.Graphics.RECT){PIXI.WebGLGraphics.buildRectangle(d,b._webGL)}else{if(d.type==PIXI.Graphics.CIRC||d.type==PIXI.Graphics.ELIP){PIXI.WebGLGraphics.buildCircle(d,b._webGL)}}}}b._webGL.lastIndex=b.graphicsData.length;var e=PIXI.gl;b._webGL.glPoints=new Float32Array(b._webGL.points);e.bindBuffer(e.ARRAY_BUFFER,b._webGL.buffer);e.bufferData(e.ARRAY_BUFFER,b._webGL.glPoints,e.STATIC_DRAW);b._webGL.glIndicies=new Uint16Array(b._webGL.indices);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,b._webGL.indexBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,b._webGL.glIndicies,e.STATIC_DRAW)};PIXI.WebGLGraphics.buildRectangle=function(s,i){var f=s.points;var n=f[0];var m=f[1];var d=f[2];var q=f[3];if(s.fill){var h=HEXtoRGB(s.fillColor);var e=s.fillAlpha;var c=h[0]*e;var j=h[1]*e;var l=h[2]*e;var o=i.points;var p=i.indices;var k=o.length/6;o.push(n,m);o.push(c,j,l,e);o.push(n+d,m);o.push(c,j,l,e);o.push(n,m+q);o.push(c,j,l,e);o.push(n+d,m+q);o.push(c,j,l,e);p.push(k,k,k+1,k+2,k+3,k+3)}if(s.lineWidth){s.points=[n,m,n+d,m,n+d,m+q,n,m+q,n,m];PIXI.WebGLGraphics.buildLine(s,i)}};PIXI.WebGLGraphics.buildCircle=function(k,w){var f=k.points;var j=f[0];var h=f[1];var o=f[2];var n=f[3];var l=40;var t=(Math.PI*2)/l;if(k.fill){var p=HEXtoRGB(k.fillColor);var d=k.fillAlpha;var m=p[0]*d;var s=p[1]*d;var u=p[2]*d;var v=w.points;var e=w.indices;var c=v.length/6;e.push(c);for(var q=0;q140*140){h=L-z;f=K-w;m=Math.sqrt(h*h+f*f);h/=m;f/=m;h*=c;f*=c;S.push(B-h,A-f);S.push(M,T,W,Q);S.push(B+h,A+f);S.push(M,T,W,Q);S.push(B-h,A-f);S.push(M,T,W,Q);q++}else{S.push(px,py);S.push(M,T,W,Q);S.push(B-(px-B),A-(py-A));S.push(M,T,W,Q)}}J=H[(u-2)*2];I=H[(u-2)*2+1];B=H[(u-1)*2];A=H[(u-1)*2+1];L=-(I-A);K=J-B;m=Math.sqrt(L*L+K*K);L/=m;K/=m;L*=c;K*=c;S.push(B-L,A-K);S.push(M,T,W,Q);S.push(B+L,A+K);S.push(M,T,W,Q);l.push(U);for(var R=0;R>16&255)/255,(b>>8&255)/255,(b&255)/255]}PIXI._defaultFrame=new PIXI.Rectangle(0,0,1,1);PIXI.gl;PIXI.WebGLRenderer=function(g,b,d,j,c){this.transparent=!!j;this.width=g||800;this.height=b||600;this.view=d||document.createElement("canvas");this.view.width=this.width;this.view.height=this.height;var f=this;this.view.addEventListener("webglcontextlost",function(e){f.handleContextLost(e)},false);this.view.addEventListener("webglcontextrestored",function(e){f.handleContextRestored(e)},false);this.batchs=[];try{PIXI.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!c,premultipliedAlpha:false,stencil:true})}catch(h){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}PIXI.initPrimitiveShader();PIXI.initDefaultShader();PIXI.initDefaultStripShader();PIXI.activateDefaultShader();var i=this.gl;PIXI.WebGLRenderer.gl=i;this.batch=new PIXI.WebGLBatch(i);i.disable(i.DEPTH_TEST);i.disable(i.CULL_FACE);i.enable(i.BLEND);i.colorMask(true,true,true,this.transparent);PIXI.projection=new PIXI.Point(400,300);this.resize(this.width,this.height);this.contextLost=false;this.stageRenderGroup=new PIXI.WebGLRenderGroup(this.gl)};PIXI.WebGLRenderer.prototype.constructor=PIXI.WebGLRenderer;PIXI.WebGLRenderer.getBatch=function(){if(PIXI._batchs.length==0){return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl)}else{return PIXI._batchs.pop()}};PIXI.WebGLRenderer.returnBatch=function(b){b.clean();PIXI._batchs.push(b)};PIXI.WebGLRenderer.prototype.render=function(b){if(this.contextLost){return}if(this.__stage!==b){this.__stage=b;this.stageRenderGroup.setRenderable(b)}PIXI.WebGLRenderer.updateTextures();PIXI.visibleCount++;b.updateTransform();var d=this.gl;d.colorMask(true,true,true,this.transparent);d.viewport(0,0,this.width,this.height);d.bindFramebuffer(d.FRAMEBUFFER,null);d.clearColor(b.backgroundColorSplit[0],b.backgroundColorSplit[1],b.backgroundColorSplit[2],!this.transparent);d.clear(d.COLOR_BUFFER_BIT);this.stageRenderGroup.backgroundColor=b.backgroundColorSplit;this.stageRenderGroup.render(PIXI.projection);if(b.interactive){if(!b._interactiveEventsAdded){b._interactiveEventsAdded=true;b.interactionManager.setTarget(this)}}if(PIXI.Texture.frameUpdates.length>0){for(var c=0;c0){n=n.children[n.children.length-1];if(n.renderable){b=n}}if(b instanceof PIXI.Sprite){c=b.batch;var l=c.head;if(l==b){h=0}else{h=1;while(l.__next!=b){h++;l=l.__next}}}else{c=b}if(m==c){if(m instanceof PIXI.WebGLBatch){m.render(p,h+1)}else{this.renderSpecial(m,j)}return}d=this.batchs.indexOf(m);q=this.batchs.indexOf(c);if(m instanceof PIXI.WebGLBatch){m.render(p)}else{this.renderSpecial(m,j)}for(var e=d+1;e=2?parseInt(b[b.length-2],10):PIXI.BitmapText.fonts[this.fontName].size;this.dirty=true};PIXI.BitmapText.prototype.updateText=function(){var h=PIXI.BitmapText.fonts[this.fontName];var m=new PIXI.Point();var j=null;var l=[];var q=0;var e=[];var p=0;var f=this.fontSize/h.size;for(var g=0;g0){this.removeChild(this.getChildAt(0))}this.updateText();this.dirty=false}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.BitmapText.fonts={};PIXI.Text=function(c,b){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");PIXI.Sprite.call(this,PIXI.Texture.fromCanvas(this.canvas));this.setText(c);this.setStyle(b);this.updateText();this.dirty=false};PIXI.Text.prototype=Object.create(PIXI.Sprite.prototype);PIXI.Text.prototype.constructor=PIXI.Text;PIXI.Text.prototype.setStyle=function(b){b=b||{};b.font=b.font||"bold 20pt Arial";b.fill=b.fill||"black";b.align=b.align||"left";b.stroke=b.stroke||"black";b.strokeThickness=b.strokeThickness||0;b.wordWrap=b.wordWrap||false;b.wordWrapWidth=b.wordWrapWidth||100;this.style=b;this.dirty=true};PIXI.Sprite.prototype.setText=function(b){this.text=b.toString()||" ";this.dirty=true};PIXI.Text.prototype.updateText=function(){this.context.font=this.style.font;var g=this.text;if(this.style.wordWrap){g=this.wordWrap(this.text)}var f=g.split(/(?:\r\n|\r|\n)/);var d=[];var c=0;for(var h=0;hj){return k}else{return arguments.callee(i,l,k,h,j)}}else{return arguments.callee(i,l,m,k,j)}};var f=function(h,j,i){if(h.measureText(j).width<=i||j.length<1){return j}var k=e(h,j,0,j.length,i);return j.substring(0,k)+"\n"+arguments.callee(h,j.substring(k),i)};var b="";var c=g.split("\n");for(var d=0;dthis.baseTexture.width||b.y+b.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)};PIXI.Texture.fromImage=function(c,b){var d=PIXI.TextureCache[c];if(!d){d=new PIXI.Texture(PIXI.BaseTexture.fromImage(c,b));PIXI.TextureCache[c]=d}return d};PIXI.Texture.fromFrame=function(c){var b=PIXI.TextureCache[c];if(!b){throw new Error("The frameId '"+c+"' does not exist in the texture cache "+this)}return b};PIXI.Texture.fromCanvas=function(b){var c=new PIXI.BaseTexture(b);return new PIXI.Texture(c)};PIXI.Texture.addTextureToCache=function(b,c){PIXI.TextureCache[c]=b};PIXI.Texture.removeTextureFromCache=function(c){var b=PIXI.TextureCache[c];PIXI.TextureCache[c]=null;return b};PIXI.Texture.frameUpdates=[];PIXI.RenderTexture=function(c,b){PIXI.EventTarget.call(this);this.width=c||100;this.height=b||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;PIXI.RenderTexture.prototype.initWebGL=function(){var b=PIXI.gl;this.glFramebuffer=b.createFramebuffer();b.bindFramebuffer(b.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=b.createTexture();b.bindTexture(b.TEXTURE_2D,this.baseTexture._glTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,this.width,this.height,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);this.baseTexture.isRender=true;b.bindFramebuffer(b.FRAMEBUFFER,this.glFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,this.baseTexture._glTexture,0);this.projection=new PIXI.Point(this.width/2,this.height/2);this.render=this.renderWebGL};PIXI.RenderTexture.prototype.resize=function(c,b){this.width=c;this.height=b;if(PIXI.gl){this.projection.x=this.width/2;this.projection.y=this.height/2;var d=PIXI.gl;d.bindTexture(d.TEXTURE_2D,this.baseTexture._glTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,this.width,this.height,0,d.RGBA,d.UNSIGNED_BYTE,null)}else{this.frame.width=this.width;this.frame.height=this.height;this.renderer.resize(this.width,this.height)}};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};PIXI.RenderTexture.prototype.renderWebGL=function(k,g,h){var f=PIXI.gl;f.colorMask(true,true,true,true);f.viewport(0,0,this.width,this.height);f.bindFramebuffer(f.FRAMEBUFFER,this.glFramebuffer);if(h){f.clearColor(0,0,0,0);f.clear(f.COLOR_BUFFER_BIT)}var c=k.children;var b=k.worldTransform;k.worldTransform=PIXI.mat3.create();k.worldTransform[4]=-1;k.worldTransform[5]=this.projection.y*2;if(g){k.worldTransform[2]=g.x;k.worldTransform[5]-=g.y}PIXI.visibleCount++;k.vcount=PIXI.visibleCount;for(var e=0,d=c.length;e>1;if(k<3){return[]}var u=[];var g=[];for(var s=0;s3){var q=g[(s+0)%o];var m=g[(s+1)%o];var l=g[(s+2)%o];var f=h[2*q],d=h[2*q+1];var v=h[2*m],t=h[2*m+1];var c=h[2*l],b=h[2*l+1];var e=false;if(PIXI.PolyK._convex(f,d,v,t,c,b,z)){e=true;for(var r=0;r3*o){if(z){var u=[];g=[];for(var s=0;s=0)&&(m>=0)&&(n+m<1)};PIXI.PolyK._convex=function(e,d,g,f,b,h,c){return((d-f)*(b-g)+(g-e)*(h-f)>=0)==c};Phaser.Camera=function(d,g,c,f,e,b){this.game=d;this.world=d.world;this.id=0;this.view=new Phaser.Rectangle(c,f,e,b);this.screenView=new Phaser.Rectangle(c,f,e,b);this.deadzone=null;this.visible=true;this.atLimit={x:false,y:false};this.target=null;this._edge=0};Phaser.Camera.FOLLOW_LOCKON=0;Phaser.Camera.FOLLOW_PLATFORMER=1;Phaser.Camera.FOLLOW_TOPDOWN=2;Phaser.Camera.FOLLOW_TOPDOWN_TIGHT=3;Phaser.Camera.prototype={follow:function(f,d){if(typeof d==="undefined"){d=Phaser.Camera.FOLLOW_LOCKON}this.target=f;var e;switch(d){case Phaser.Camera.FOLLOW_PLATFORMER:var b=this.width/8;var c=this.height/3;this.deadzone=new Phaser.Rectangle((this.width-b)/2,(this.height-c)/2-c*0.25,b,c);break;case Phaser.Camera.FOLLOW_TOPDOWN:e=Math.max(this.width,this.height)/4;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT:e=Math.max(this.width,this.height)/8;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_LOCKON:default:this.deadzone=null;break}},focusOnXY:function(b,c){this.view.x=Math.round(b-this.view.halfWidth);this.view.y=Math.round(c-this.view.halfHeight)},update:function(){if(this.target!==null){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.xthis._edge){this.view.y=this._edge}this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height;if(this.view.ythis.world.bounds.right-this.width){this.atLimit.x=true;this.view.x=(this.world.bounds.right-this.width)+1}if(this.view.ythis.world.bounds.bottom-this.height){this.atLimit.y=true;this.view.y=(this.world.bounds.bottom-this.height)+1}this.view.floor()},setPosition:function(b,c){this.view.x=b;this.view.y=c;this.checkWorldBounds()},setSize:function(c,b){this.view.width=c;this.view.height=b}};Object.defineProperty(Phaser.Camera.prototype,"x",{get:function(){return this.view.x},set:function(b){this.view.x=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"y",{get:function(){return this.view.y},set:function(b){this.view.y=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"width",{get:function(){return this.view.width},set:function(b){this.view.width=b}});Object.defineProperty(Phaser.Camera.prototype,"height",{get:function(){return this.view.height},set:function(b){this.view.height=b}});Phaser.State=function(){this.game=null;this.add=null;this.camera=null;this.cache=null;this.input=null;this.load=null;this.math=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.particles=null;this.physics=null};Phaser.State.prototype={preload:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}};Phaser.StateManager=function(c,b){this.game=c;this.states={};if(b!==null){this._pendingState=b}};Phaser.StateManager.prototype={game:null,_pendingState:null,_created:false,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){if(this._pendingState!==null){if(typeof this._pendingState==="string"){this.start(this._pendingState,false,false)}else{this.add("default",this._pendingState,true)}}},add:function(c,d,b){if(typeof b==="undefined"){b=false}var e;if(d instanceof Phaser.State){e=d}else{if(typeof d==="object"){e=d;e.game=this.game}else{if(typeof d==="function"){e=new d(this.game)}}}this.states[c]=e;if(b){if(this.game.isBooted){this.start(c)}else{this._pendingState=c}}return e},remove:function(b){if(this.current==b){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[b]},start:function(c,b,d){if(typeof b==="undefined"){b=true}if(typeof d==="undefined"){d=false}if(this.game.isBooted==false){this._pendingState=c;return}if(this.checkState(c)==false){return}else{if(this.current){this.onShutDownCallback.call(this.callbackContext)}if(b){this.game.world.destroy();if(d==true){this.game.cache.destroy()}}this.setCurrentState(c)}if(this.onPreloadCallback){this.game.load.reset();this.onPreloadCallback.call(this.callbackContext);if(this.game.load.queueSize==0){this.game.loadComplete()}else{this.game.load.start()}}else{this.game.loadComplete()}},dummy:function(){},checkState:function(b){if(this.states[b]){var c=false;if(this.states[b]["preload"]){c=true}if(c==false&&this.states[b]["loadRender"]){c=true}if(c==false&&this.states[b]["loadUpdate"]){c=true}if(c==false&&this.states[b]["create"]){c=true}if(c==false&&this.states[b]["update"]){c=true}if(c==false&&this.states[b]["preRender"]){c=true}if(c==false&&this.states[b]["render"]){c=true}if(c==false&&this.states[b]["paused"]){c=true}if(c==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: "+b);return false}},link:function(b){this.states[b].game=this.game;this.states[b].add=this.game.add;this.states[b].camera=this.game.camera;this.states[b].cache=this.game.cache;this.states[b].input=this.game.input;this.states[b].load=this.game.load;this.states[b].math=this.game.math;this.states[b].sound=this.game.sound;this.states[b].stage=this.game.stage;this.states[b].time=this.game.time;this.states[b].tweens=this.game.tweens;this.states[b].world=this.game.world;this.states[b].particles=this.game.particles;this.states[b].physics=this.game.physics;this.states[b].rnd=this.game.rnd},setCurrentState:function(b){this.callbackContext=this.states[b];this.link(b);this.onInitCallback=this.states[b]["init"]||this.dummy;this.onPreloadCallback=this.states[b]["preload"]||null;this.onLoadRenderCallback=this.states[b]["loadRender"]||null;this.onLoadUpdateCallback=this.states[b]["loadUpdate"]||null;this.onCreateCallback=this.states[b]["create"]||null;this.onUpdateCallback=this.states[b]["update"]||null;this.onPreRenderCallback=this.states[b]["preRender"]||null;this.onRenderCallback=this.states[b]["render"]||null;this.onPausedCallback=this.states[b]["paused"]||null;this.onShutDownCallback=this.states[b]["shutdown"]||this.dummy;this.current=b;this._created=false;this.onInitCallback.call(this.callbackContext)},loadComplete:function(){if(this._created==false&&this.onCreateCallback){this.onCreateCallback.call(this.callbackContext)}this._created=true},update:function(){if(this._created&&this.onUpdateCallback){this.onUpdateCallback.call(this.callbackContext)}else{if(this.onLoadUpdateCallback){this.onLoadUpdateCallback.call(this.callbackContext)}}},preRender:function(){if(this.onPreRenderCallback){this.onPreRenderCallback.call(this.callbackContext)}},render:function(){if(this._created&&this.onRenderCallback){this.onRenderCallback.call(this.callbackContext)}else{if(this.onLoadRenderCallback){this.onLoadRenderCallback.call(this.callbackContext)}}},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}};Phaser.LinkedList=function(){this.next=null;this.prev=null;this.first=null;this.last=null;this.total=0};Phaser.LinkedList.prototype={add:function(b){if(this.total==0&&this.first==null&&this.last==null){this.first=b;this.last=b;this.next=b;b.prev=this;this.total++;return}this.last.next=b;b.prev=this.last;this.last=b;this.total++;return b},remove:function(c){if(this.first==null&&this.last==null){return}this.total--;if(this.first==c&&this.last==c){this.first=null;this.last=null;this.next=null;c.next=null;c.prev=null;return}var b=c.prev;if(c.next){c.next.prev=c.prev}b.next=c.next},callAll:function(c){if(!this.first||!this.last){return}var b=this.first;do{if(b&&b[c]){b[c].call(b)}b=b.next}while(b!=this.last.next)},dump:function(){var j=20;var e="\n"+Phaser.Utils.pad("Node",j)+"|"+Phaser.Utils.pad("Next",j)+"|"+Phaser.Utils.pad("Previous",j)+"|"+Phaser.Utils.pad("First",j)+"|"+Phaser.Utils.pad("Last",j);console.log(e);var e=Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j);console.log(e);var g=this;var c=g.last.next;g=g.first;do{var d=g.sprite.name||"*";var f="-";var b="-";var h="-";var i="-";if(g.next){f=g.next.sprite.name}if(g.prev){b=g.prev.sprite.name}if(g.first){h=g.first.sprite.name}if(g.last){i=g.last.sprite.name}if(typeof f==="undefined"){f="-"}if(typeof b==="undefined"){b="-"}if(typeof h==="undefined"){h="-"}if(typeof i==="undefined"){i="-"}var e=Phaser.Utils.pad(d,j)+"|"+Phaser.Utils.pad(f,j)+"|"+Phaser.Utils.pad(b,j)+"|"+Phaser.Utils.pad(h,j)+"|"+Phaser.Utils.pad(i,j);console.log(e);g=g.next}while(g!=c)}};Phaser.Signal=function(){this._bindings=[];this._prevParams=null;var b=this;this.dispatch=function(){Phaser.Signal.prototype.dispatch.apply(b,arguments)}};Phaser.Signal.prototype={memorize:false,_shouldPropagate:true,active:true,validateListener:function(b,c){if(typeof b!=="function"){throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",c))}},_registerListener:function(f,d,e,c){var b=this._indexOfListener(f,e),g;if(b!==-1){g=this._bindings[b];if(g.isOnce()!==d){throw new Error("You cannot add"+(d?"":"Once")+"() then add"+(!d?"":"Once")+"() the same listener without removing the relationship first.")}}else{g=new Phaser.SignalBinding(this,f,d,e,c);this._addBinding(g)}if(this.memorize&&this._prevParams){g.execute(this._prevParams)}return g},_addBinding:function(b){var c=this._bindings.length;do{--c}while(this._bindings[c]&&b._priority<=this._bindings[c]._priority);this._bindings.splice(c+1,0,b)},_indexOfListener:function(c,b){var e=this._bindings.length,d;while(e--){d=this._bindings[e];if(d._listener===c&&d.context===b){return e}}return -1},has:function(c,b){return this._indexOfListener(c,b)!==-1},add:function(d,c,b){this.validateListener(d,"add");return this._registerListener(d,false,c,b)},addOnce:function(d,c,b){this.validateListener(d,"addOnce");return this._registerListener(d,true,c,b)},remove:function(d,c){this.validateListener(d,"remove");var b=this._indexOfListener(d,c);if(b!==-1){this._bindings[b]._destroy();this._bindings.splice(b,1)}return d},removeAll:function(){var b=this._bindings.length;while(b--){this._bindings[b]._destroy()}this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=false},dispatch:function(c){if(!this.active){return}var b=Array.prototype.slice.call(arguments),e=this._bindings.length,d;if(this.memorize){this._prevParams=b}if(!e){return}d=this._bindings.slice();this._shouldPropagate=true;do{e--}while(d[e]&&this._shouldPropagate&&d[e].execute(b)!==false)},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};Phaser.SignalBinding=function(f,e,c,d,b){this._listener=e;this._isOnce=c;this.context=d;this._signal=f;this._priority=b||0};Phaser.SignalBinding.prototype={active:true,params:null,execute:function(b){var d,c;if(this.active&&!!this._listener){c=this.params?this.params.concat(b):b;d=this._listener.apply(this.context,c);if(this._isOnce){this.detach()}}return d},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return(!!this._signal&&!!this._listener)},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};Phaser.Plugin=function(b,c){this.game=b;this.parent=c;this.active=false;this.visible=false;this.hasPreUpdate=false;this.hasUpdate=false;this.hasRender=false;this.hasPostRender=false};Phaser.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null;this.parent=null;this.active=false;this.visible=false}};Phaser.PluginManager=function(b,c){this.game=b;this._parent=c;this.plugins=[];this._pluginsLength=0};Phaser.PluginManager.prototype={add:function(c){var b=false;if(typeof c==="function"){c=new c(this.game,this._parent)}else{c.game=this.game;c.parent=this._parent}if(typeof c.preUpdate==="function"){c.hasPreUpdate=true;b=true}if(typeof c.update==="function"){c.hasUpdate=true;b=true}if(typeof c.render==="function"){c.hasRender=true;b=true}if(typeof c.postRender==="function"){c.hasPostRender=true;b=true}if(b){if(c.hasPreUpdate||c.hasUpdate){c.active=true}if(c.hasRender||c.hasPostRender){c.visible=true}this._pluginsLength=this.plugins.push(c);return c}else{return null}},remove:function(b){this._pluginsLength--},preUpdate:function(){if(this._pluginsLength==0){return}for(this._p=0;this._p0&&this._container.first._iNext){var d=this._container.first._iNext;do{if((c==false||(c&&d.alive))&&(g==false||(g&&d.visible))){this.setProperty(d,e,f,b)}d=d._iNext}while(d!=this._container.last._iNext)}},addAll:function(c,d,b,e){this.setAll(c,d,b,e,1)},subAll:function(c,d,b,e){this.setAll(c,d,b,e,2)},multiplyAll:function(c,d,b,e){this.setAll(c,d,b,e,3)},divideAll:function(c,d,b,e){this.setAll(c,d,b,e,4)},callAllExists:function(f,b,e){var c=Array.prototype.splice.call(arguments,3);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do{if(d.exists==e&&d[f]){d[f].apply(d,c)}d=d._iNext}while(d!=this._container.last._iNext)}},callAll:function(e,b){var c=Array.prototype.splice.call(arguments,2);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do{if(d[e]){d[e].apply(d,c)}d=d._iNext}while(d!=this._container.last._iNext)}},forEach:function(e,b,d){if(typeof d=="undefined"){d=false}if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do{if(d==false||(d&&c.exists)){e.call(b,c)}c=c._iNext}while(c!=this._container.last._iNext)}},forEachAlive:function(d,b){if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do{if(c.alive){d.call(b,c)}c=c._iNext}while(c!=this._container.last._iNext)}},forEachDead:function(d,b){if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do{if(c.alive==false){d.call(b,c)}c=c._iNext}while(c!=this._container.last._iNext)}},getFirstExists:function(c){if(typeof c!=="boolean"){c=true}if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.exists===c){return b}b=b._iNext}while(b!=this._container.last._iNext)}return null},getFirstAlive:function(){if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.alive){return b}b=b._iNext}while(b!=this._container.last._iNext)}return null},getFirstDead:function(){if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(!b.alive){return b}b=b._iNext}while(b!=this._container.last._iNext)}return null},countLiving:function(){var c=-1;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.alive){c++}b=b._iNext}while(b!=this._container.last._iNext)}return c},countDead:function(){var c=-1;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(!b.alive){c++}b=b._iNext}while(b!=this._container.last._iNext)}return c},getRandom:function(c,b){if(this._container.children.length==0){return null}c=c||0;b=b||this._container.children.length;return this.game.math.getRandom(this._container.children,c,b)},remove:function(b){b.events.onRemovedFromGroup.dispatch(b,this);this._container.removeChild(b);b.group=null},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)},removeBetween:function(d,c){if(this._container.children.length==0){return}if(d>c||d<0||c>this._container.children.length){return false}for(var b=d;b=this.game.width){this.bounds.width=c}if(b>=this.game.height){this.bounds.height=b}},destroy:function(){this.camera.x=0;this.camera.y=0;this.game.input.reset(true);this.group.removeAll()}};Object.defineProperty(Phaser.World.prototype,"width",{get:function(){return this.bounds.width},set:function(b){this.bounds.width=b}});Object.defineProperty(Phaser.World.prototype,"height",{get:function(){return this.bounds.height},set:function(b){this.bounds.height=b}});Object.defineProperty(Phaser.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}});Object.defineProperty(Phaser.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}});Object.defineProperty(Phaser.World.prototype,"randomX",{get:function(){return Math.round(Math.random()*this.bounds.width)}});Object.defineProperty(Phaser.World.prototype,"randomY",{get:function(){return Math.round(Math.random()*this.bounds.height)}});Phaser.Game=function(e,b,g,d,f,h,c){e=e||800;b=b||600;g=g||Phaser.AUTO;d=d||"";f=f||null;h=h||false;c=c||true;this.id=Phaser.GAMES.push(this)-1;this.parent=d;this.width=e;this.height=b;this.transparent=h;this.antialias=c;this.renderer=null;this.state=new Phaser.StateManager(this,f);this._paused=false;this.renderType=g;this._loadComplete=false;this.isBooted=false;this.isRunning=false;this.raf=null;this.add=null;this.cache=null;this.input=null;this.load=null;this.math=null;this.net=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.physics=null;this.rnd=null;this.device=null;this.camera=null;this.canvas=null;this.context=null;this.debug=null;this.particles=null;var i=this;this._onBoot=function(){return i.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={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.load.onLoadComplete.add(this.loadComplete,this);this.stage.boot();this.world.boot();this.input.boot();this.sound.boot();this.state.boot();if(this.renderType==Phaser.CANVAS){console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to Canvas","color: #ffff33; background: #000000")}else{console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to WebGL","color: #ffff33; background: #000000")}this.isRunning=true;this._loadComplete=false;this.raf=new Phaser.RequestAnimationFrame(this);this.raf.start()}},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{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)},loadComplete:function(){this._loadComplete=true;this.state.loadComplete()},update:function(b){this.time.update(b);if(!this._paused){this.plugins.preUpdate();this.physics.preUpdate();this.input.update();this.tweens.update();this.sound.update();this.world.update();this.particles.update();this.state.update();this.plugins.update();this.renderer.render(this.stage._stage);this.plugins.render();this.state.render();this.plugins.postRender()}},destroy:function(){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}};Object.defineProperty(Phaser.Game.prototype,"paused",{get:function(){return this._paused},set:function(b){if(b===true){if(this._paused==false){this._paused=true;this.onPause.dispatch(this)}}else{if(this._paused){this._paused=false;this.onResume.dispatch(this)}}}});Phaser.Input=function(b){this.game=b;this.hitCanvas=null;this.hitContext=null};Phaser.Input.MOUSE_OVERRIDES_TOUCH=0;Phaser.Input.TOUCH_OVERRIDES_MOUSE=1;Phaser.Input.MOUSE_TOUCH_COMBINE=2;Phaser.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:false,multiInputOverride:Phaser.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2000,justPressedRate:200,justReleasedRate:200,recordPointerHistory:false,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new Phaser.LinkedList(),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},addPointer:function(){var c=0;for(var b=10;b>0;b--){if(this["pointer"+b]===null){c=b}}if(c==0){console.warn("You can only have 10 Pointer objects");return null}else{this["pointer"+c]=new Phaser.Pointer(this.game,c);return this["pointer"+c]}},update:function(){if(this.pollRate>0&&this._pollCounter0&&this._pollCounter=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}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()}}}},move:function(c){if(this.game.input.pollLocked){return}if(c.button){this.button=c.button}this.clientX=c.clientX;this.clientY=c.clientY;this.pageX=c.pageX;this.pageY=c.pageY;this.screenX=c.screenX;this.screenY=c.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(this.game.paused){return this}if(this.targetObject!==null&&this.targetObject.isDragged==true){if(this.targetObject.update(this)==false){this.targetObject=null}return this}this._highestRenderOrderID=-1;this._highestRenderObject=null;this._highestInputPriorityID=-1;if(this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do{if(b.priorityID>this._highestInputPriorityID||(b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)){if(b.checkPointerOver(this)){this._highestRenderOrderID=b.sprite.renderOrderID;this._highestInputPriorityID=b.priorityID;this._highestRenderObject=b}}b=b.next}while(b!=null)}if(this._highestRenderObject==null){if(this.targetObject){this.targetObject._pointerOutHandler(this);this.targetObject=null}}else{if(this.targetObject==null){this.targetObject=this._highestRenderObject;this._highestRenderObject._pointerOverHandler(this)}else{if(this.targetObject==this._highestRenderObject){if(this._highestRenderObject.update(this)==false){this.targetObject=null}}else{this.targetObject._pointerOutHandler(this);this.targetObject=this._highestRenderObject;this.targetObject._pointerOverHandler(this)}}}return this},leave:function(b){this.withinGame=false;this.move(b)},stop:function(c){if(this._stateReset){c.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);if(this.duration>=0&&this.duration<=this.game.input.tapRate){if(this.timeUp-this.previousTapTime0){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 b=this.game.input.interactiveItems.next;do{if(b){b._releasedHandler(this)}b=b.next}while(b!=null)}if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null;return this},justPressed:function(b){b=b||this.game.input.justPressedRate;return(this.isDown===true&&(this.timeDown+b)>this.game.time.now)},justReleased:function(b){b=b||this.game.input.justReleasedRate;return(this.isUp===true&&(this.timeUp+b)>this.game.time.now)},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},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+")}]"}};Object.defineProperty(Phaser.Pointer.prototype,"duration",{get:function(){if(this.isUp){return -1}return this.game.time.now-this.timeDown}});Object.defineProperty(Phaser.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}});Object.defineProperty(Phaser.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}});Phaser.Touch=function(b){this.game=b;this.callbackContext=this.game;this.touchStartCallback=null;this.touchMoveCallback=null;this.touchEndCallback=null;this.touchEnterCallback=null;this.touchLeaveCallback=null;this.touchCancelCallback=null;this.preventDefault=true};Phaser.Touch.prototype={game:null,disabled:false,_onTouchStart:null,_onTouchMove:null,_onTouchEnd:null,_onTouchEnter:null,_onTouchLeave:null,_onTouchCancel:null,_onTouchMove:null,start:function(){var b=this;if(this.game.device.touch){this._onTouchStart=function(c){return b.onTouchStart(c)};this._onTouchMove=function(c){return b.onTouchMove(c)};this._onTouchEnd=function(c){return b.onTouchEnd(c)};this._onTouchEnter=function(c){return b.onTouchEnter(c)};this._onTouchLeave=function(c){return b.onTouchLeave(c)};this._onTouchCancel=function(c){return b.onTouchCancel(c)};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)}},consumeDocumentTouches:function(){this._documentTouchMove=function(b){b.preventDefault()};document.addEventListener("touchmove",this._documentTouchMove,false)},onTouchStart:function(c){if(this.touchStartCallback){this.touchStartCallback.call(this.callbackContext,c)}if(this.game.input.disabled||this.disabled){return}if(this.preventDefault){c.preventDefault()}for(var b=0;bb&&this._tempPoint.xc&&this._tempPoint.y=this.pixelPerfectAlpha){return true}}return false},update:function(b){if(this.enabled==false||this.sprite.visible==false){this._pointerOutHandler(b);return false}if(this.draggable&&this._draggedPointerID==b.id){return this.updateDrag(b)}else{if(this._pointerData[b.id].isOver==true){if(this.checkPointerOver(b)){this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;return true}else{this._pointerOutHandler(b);return false}}}},_pointerOverHandler:function(b){if(this._pointerData[b.id].isOver==false){this._pointerData[b.id].isOver=true;this._pointerData[b.id].isOut=false;this._pointerData[b.id].timeOver=this.game.time.now;this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="pointer"}this.sprite.events.onInputOver.dispatch(this.sprite,b)}},_pointerOutHandler:function(b){this._pointerData[b.id].isOver=false;this._pointerData[b.id].isOut=true;this._pointerData[b.id].timeOut=this.game.time.now;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="default"}this.sprite.events.onInputOut.dispatch(this.sprite,b)},_touchedHandler:function(b){if(this._pointerData[b.id].isDown==false&&this._pointerData[b.id].isOver==true){this._pointerData[b.id].isDown=true;this._pointerData[b.id].isUp=false;this._pointerData[b.id].timeDown=this.game.time.now;this.sprite.events.onInputDown.dispatch(this.sprite,b);if(this.draggable&&this.isDragged==false){this.startDrag(b)}if(this.bringToTop){this.sprite.bringToTop()}}return this.consumePointerEvent},_releasedHandler:function(b){if(this._pointerData[b.id].isDown&&b.isUp){this._pointerData[b.id].isDown=false;this._pointerData[b.id].isUp=true;this._pointerData[b.id].timeUp=this.game.time.now;this._pointerData[b.id].downDuration=this._pointerData[b.id].timeUp-this._pointerData[b.id].timeDown;if(this.checkPointerOver(b)){this.sprite.events.onInputUp.dispatch(this.sprite,b)}else{if(this.useHandCursor){this.game.stage.canvas.style.cursor="default"}}if(this.draggable&&this.isDragged&&this._draggedPointerID==b.id){this.stopDrag(b)}}},updateDrag:function(b){if(b.isUp){this.stopDrag(b);return false}if(this.allowHorizontalDrag){this.sprite.x=b.x+this._dragPoint.x+this.dragOffset.x}if(this.allowVerticalDrag){this.sprite.y=b.y+this._dragPoint.y+this.dragOffset.y}if(this.boundsRect){this.checkBoundsRect()}if(this.boundsSprite){this.checkBoundsSprite()}if(this.snapOnDrag){this.sprite.x=Math.floor(this.sprite.x/this.snapX)*this.snapX;this.sprite.y=Math.floor(this.sprite.y/this.snapY)*this.snapY}return true},justOver:function(c,b){c=c||0;b=b||500;return(this._pointerData[c].isOver&&this.overDuration(c)this.boundsRect.right){this.sprite.x=this.boundsRect.right-this.sprite.width}}if(this.sprite.ythis.boundsRect.bottom){this.sprite.y=this.boundsRect.bottom-this.sprite.height}}},checkBoundsSprite:function(){if(this.sprite.x(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.boundsSprite.height)){this.sprite.y=(this.boundsSprite.y+this.boundsSprite.height)-this.sprite.height}}}};Phaser.Events=function(b){this.parent=b;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.GameObjectFactory=function(b){this.game=b;this.world=this.game.world};Phaser.GameObjectFactory.prototype={game:null,world:null,existing:function(b){return this.world.group.add(b)},sprite:function(b,e,c,d){return this.world.group.add(new Phaser.Sprite(this.game,b,e,c,d))},child:function(d,b,g,c,e){var f=this.world.group.add(new Phaser.Sprite(this.game,b,g,c,e));d.addChild(f);return f},tween:function(b){return this.game.tweens.create(b)},group:function(c,b){return new Phaser.Group(this.game,c,b)},audio:function(c,d,b){return this.game.sound.add(c,d,b)},tileSprite:function(c,g,e,b,d,f){return this.world.group.add(new Phaser.TileSprite(this.game,c,g,e,b,d,f))},text:function(b,e,d,c){return this.world.group.add(new Phaser.Text(this.game,b,e,d,c))},button:function(b,i,g,h,e,d,f,c){return this.world.group.add(new Phaser.Button(this.game,b,i,g,h,e,d,f,c))},graphics:function(b,c){return this.world.group.add(new Phaser.Graphics(this.game,b,c))},emitter:function(b,d,c){return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game,b,d,c))},bitmapText:function(b,e,d,c){return this.world.group.add(new Phaser.BitmapText(this.game,b,e,d,c))},tilemap:function(b,g,d,e,f,c){return this.world.group.add(new Phaser.Tilemap(this.game,d,b,g,e,f,c))},renderTexture:function(c,d,b){var e=new Phaser.RenderTexture(this.game,c,d,b);this.game.cache.addRenderTexture(c,e);return e}};Phaser.Sprite=function(c,b,f,d,e){b=b||0;f=f||0;d=d||null;e=e||null;this.game=c;this.exists=true;this.alive=true;this.group=null;this.name="";this.type=Phaser.SPRITE;this.renderOrderID=-1;this.lifespan=0;this.events=new Phaser.Events(this);this.animations=new Phaser.AnimationManager(this);this.input=new Phaser.InputHandler(this);this.key=d;if(d instanceof Phaser.RenderTexture){PIXI.Sprite.call(this,d);this.currentFrame=this.game.cache.getTextureFrame(d.name)}else{if(d==null||this.game.cache.checkImageKey(d)==false){d="__default"}PIXI.Sprite.call(this,PIXI.TextureCache[d]);if(this.game.cache.isSpriteSheet(d)){this.animations.loadFrameData(this.game.cache.getFrameData(d));if(e!==null){if(typeof e==="string"){this.frameName=e}else{this.frame=e}}}else{this.currentFrame=this.game.cache.getFrame(d)}}this.anchor=new Phaser.Point();this._cropUUID=null;this._cropRect=null;this.x=b;this.y=f;this.position.x=b;this.position.y=f;this.autoCull=false;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,i01:0,i10:0,idi:1,left:null,right:null,top:null,bottom:null,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),frameID:this.currentFrame.uuid,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,boundsX:0,boundsY:0,cameraVisible:true};this.offset=new Phaser.Point;this.center=new Phaser.Point(b+Math.floor(this._cache.width/2),f+Math.floor(this._cache.height/2));this.topLeft=new Phaser.Point(b,f);this.topRight=new Phaser.Point(b+this._cache.width,f);this.bottomRight=new Phaser.Point(b+this._cache.width,f+this._cache.height);this.bottomLeft=new Phaser.Point(b,f+this._cache.height);this.bounds=new Phaser.Rectangle(b,f,this._cache.width,this._cache.height);this.body=new Phaser.Physics.Arcade.Body(this);this.velocity=this.body.velocity;this.acceleration=this.body.acceleration;this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds);this.inWorldThreshold=0;this._outOfBoundsFired=false};Phaser.Sprite.prototype=Object.create(PIXI.Sprite.prototype);Phaser.Sprite.prototype.constructor=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.animations.update()){this._cache.dirty=true}this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.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}if(this.visible){this.renderOrderID=this.game.world.currentRenderOrderID++}if(this.worldTransform[0]!=this._cache.a00||this.worldTransform[1]!=this._cache.a01){this._cache.a00=this.worldTransform[0];this._cache.a01=this.worldTransform[1];this._cache.i01=this.worldTransform[1];this._cache.scaleX=Math.sqrt((this._cache.a00*this._cache.a00)+(this._cache.a01*this._cache.a01));this._cache.a01*=-1;this._cache.dirty=true}if(this.worldTransform[3]!=this._cache.a10||this.worldTransform[4]!=this._cache.a11){this._cache.a10=this.worldTransform[3];this._cache.i10=this.worldTransform[3];this._cache.a11=this.worldTransform[4];this._cache.scaleY=Math.sqrt((this._cache.a10*this._cache.a10)+(this._cache.a11*this._cache.a11));this._cache.a10*=-1;this._cache.dirty=true}if(this.worldTransform[2]!=this._cache.a02||this.worldTransform[5]!=this._cache.a12){this._cache.a02=this.worldTransform[2];this._cache.a12=this.worldTransform[5];this._cache.dirty=true}if(this.currentFrame.uuid!=this._cache.frameID){this._cache.frameWidth=this.texture.frame.width;this._cache.frameHeight=this.texture.frame.height;this._cache.frameID=this.currentFrame.uuid;this._cache.dirty=true}if(this._cache.dirty){this._cache.width=Math.floor(this.currentFrame.sourceSizeW*this._cache.scaleX);this._cache.height=Math.floor(this.currentFrame.sourceSizeH*this._cache.scaleY);this._cache.halfWidth=Math.floor(this._cache.width/2);this._cache.halfHeight=Math.floor(this._cache.height/2);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.updateBounds()}if(this._cache.dirty){this._cache.cameraVisible=Phaser.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0);if(this.autoCull==true){this.renderable=this._cache.cameraVisible}this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)}this.body.update()};Phaser.Sprite.prototype.postUpdate=function(){if(this.exists){this.body.postUpdate()}};Phaser.Sprite.prototype.centerOn=function(b,c){this.x=b+(this.x-this.center.x);this.y=c+(this.y-this.center.y)};Phaser.Sprite.prototype.revive=function(){this.alive=true;this.exists=true;this.visible=true;this.events.onRevived.dispatch(this)};Phaser.Sprite.prototype.kill=function(){this.alive=false;this.exists=false;this.visible=false;this.events.onKilled.dispatch(this)};Phaser.Sprite.prototype.reset=function(b,c){this.x=b;this.y=c;this.position.x=b;this.position.y=c;this.alive=true;this.exists=true;this.visible=true;this._outOfBoundsFired=false;this.body.reset()};Phaser.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-(this.anchor.x*this._cache.width),this._cache.a12-(this.anchor.y*this._cache.height));this.getLocalPosition(this.center,this.offset.x+this._cache.halfWidth,this.offset.y+this._cache.halfHeight);this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y);this.getLocalPosition(this.topRight,this.offset.x+this._cache.width,this.offset.y);this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this._cache.height);this.getLocalPosition(this.bottomRight,this.offset.x+this._cache.width,this.offset.y+this._cache.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._cache.boundsX=this._cache.x;this._cache.boundsY=this._cache.y;if(this.inWorld==false){this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold);if(this.inWorld){this._outOfBoundsFired=false}}else{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}}};Phaser.Sprite.prototype.getLocalPosition=function(c,b,d){c.x=((this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*d+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this._cache.scaleX)+this._cache.a02;c.y=((this._cache.a00*this._cache.id*d+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this._cache.scaleY)+this._cache.a12;return c};Phaser.Sprite.prototype.getLocalUnmodifiedPosition=function(c,b,d){c.x=this._cache.a11*this._cache.idi*b+-this._cache.i01*this._cache.idi*d+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi;c.y=this._cache.a00*this._cache.idi*d+-this._cache.i10*this._cache.idi*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi;return c};Phaser.Sprite.prototype.bringToTop=function(){if(this.group){this.group.bringToTop(this)}else{this.game.world.bringToTop(this)}};Phaser.Sprite.prototype.getBounds=function(d){d=d||new Phaser.Rectangle;var f=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var c=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var e=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);var b=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);d.x=f;d.y=e;d.width=c-f;d.height=b-e;return d};Object.defineProperty(Phaser.Sprite.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(b){this.animations.frame=b}});Object.defineProperty(Phaser.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(b){this.animations.frameName=b}});Object.defineProperty(Phaser.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}});Object.defineProperty(Phaser.Sprite.prototype,"crop",{get:function(){return this._cropRect},set:function(b){if(b instanceof Phaser.Rectangle){if(this._cropUUID==null){this._cropUUID=this.game.rnd.uuid();PIXI.TextureCache[this._cropUUID]=new PIXI.Texture(PIXI.BaseTextureCache[this.key],{x:b.x,y:b.y,width:b.width,height:b.height})}else{PIXI.TextureCache[this._cropUUID].frame=b}this._cropRect=b;this.setTexture(PIXI.TextureCache[this._cropUUID])}}});Object.defineProperty(Phaser.Sprite.prototype,"inputEnabled",{get:function(){return(this.input.enabled)},set:function(b){if(b){if(this.input.enabled==false){this.input.start()}}else{if(this.input.enabled){this.input.stop()}}}});Phaser.TileSprite=function(d,c,h,f,b,e,g){c=c||0;h=h||0;f=f||256;b=b||256;e=e||null;g=g||null;Phaser.Sprite.call(this,d,c,h,e,g);this.texture=PIXI.TextureCache[e];PIXI.TilingSprite.call(this,this.texture,f,b);this.type=Phaser.TILESPRITE;this.tileScale=new Phaser.Point(1,1);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;Phaser.Text=function(c,b,f,e,d){b=b||0;f=f||0;e=e||"";d=d||"";this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;this._text=e;this._style=d;PIXI.Text.call(this,e,d);this.type=Phaser.TEXT;this.position.x=this.x=b;this.position.y=this.y=f;this.anchor=new Phaser.Point();this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true};Phaser.Text.prototype=Object.create(PIXI.Text.prototype);Phaser.Text.prototype.constructor=Phaser.Text;Phaser.Text.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.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}};Object.defineProperty(Phaser.Text.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Text.prototype,"text",{get:function(){return this._text},set:function(b){if(b!==this._text){this._text=b;this.dirty=true}}});Object.defineProperty(Phaser.Text.prototype,"style",{get:function(){return this._style},set:function(b){if(b!==this._style){this._style=b;this.dirty=true}}});Phaser.BitmapText=function(c,b,f,e,d){b=b||0;f=f||0;e=e||"";d=d||"";this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;PIXI.BitmapText.call(this,e,d);this.type=Phaser.BITMAPTEXT;this.position.x=b;this.position.y=f;this.anchor=new Phaser.Point();this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true};Phaser.BitmapText.prototype=Object.create(PIXI.BitmapText.prototype);Phaser.BitmapText.prototype.constructor=Phaser.BitmapText;Phaser.BitmapText.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.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}};Object.defineProperty(Phaser.BitmapText.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(b){this.position.x=b}});Object.defineProperty(Phaser.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(b){this.position.y=b}});Phaser.Button=function(j,g,f,h,i,c,d,b,e){g=g||0;f=f||0;h=h||null;i=i||null;c=c||this;Phaser.Sprite.call(this,j,g,f,h,b);this.type=Phaser.BUTTON;this._onOverFrameName=null;this._onOutFrameName=null;this._onDownFrameName=null;this._onUpFrameName=null;this._onOverFrameID=null;this._onOutFrameID=null;this._onDownFrameID=null;this._onUpFrameID=null;this.onInputOver=new Phaser.Signal;this.onInputOut=new Phaser.Signal;this.onInputDown=new Phaser.Signal;this.onInputUp=new Phaser.Signal;this.setFrames(d,b,e);if(i!==null){this.onInputUp.add(i,c)}this.input.start(0,false,true);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=Phaser.Utils.extend(true,Phaser.Sprite.prototype,PIXI.Sprite.prototype);Phaser.Button.prototype.constructor=Phaser.Button;Phaser.Button.prototype.setFrames=function(c,d,b){if(c!==null){if(typeof c==="string"){this._onOverFrameName=c}else{this._onOverFrameID=c}}if(d!==null){if(typeof d==="string"){this._onOutFrameName=d;this._onUpFrameName=d}else{this._onOutFrameID=d;this._onUpFrameID=d}}if(b!==null){if(typeof b==="string"){this._onDownFrameName=b}else{this._onDownFrameID=b}}};Phaser.Button.prototype.onInputOverHandler=function(b){if(this._onOverFrameName!=null){this.frameName=this._onOverFrameName}else{if(this._onOverFrameID!=null){this.frame=this._onOverFrameID}}if(this.onInputOver){this.onInputOver.dispatch(this,b)}};Phaser.Button.prototype.onInputOutHandler=function(b){if(this._onOutFrameName!=null){this.frameName=this._onOutFrameName}else{if(this._onOutFrameID!=null){this.frame=this._onOutFrameID}}if(this.onInputOut){this.onInputOut.dispatch(this,b)}};Phaser.Button.prototype.onInputDownHandler=function(b){if(this._onDownFrameName!=null){this.frameName=this._onDownFrameName}else{if(this._onDownFrameID!=null){this.frame=this._onDownFrameID}}if(this.onInputDown){this.onInputDown.dispatch(this,b)}};Phaser.Button.prototype.onInputUpHandler=function(b){if(this._onUpFrameName!=null){this.frameName=this._onUpFrameName}else{if(this._onUpFrameID!=null){this.frame=this._onUpFrameID}}if(this.onInputUp){this.onInputUp.dispatch(this,b)}};Phaser.Graphics=function(c,b,d){this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;PIXI.DisplayObjectContainer.call(this);this.type=Phaser.GRAPHICS;this.position.x=b;this.position.y=d;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:d,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};Phaser.Graphics.prototype=Phaser.Utils.extend(true,PIXI.Graphics.prototype,PIXI.DisplayObjectContainer.prototype,Phaser.Sprite.prototype);Phaser.Graphics.prototype.constructor=Phaser.Graphics;Phaser.Graphics.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.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}};Object.defineProperty(Phaser.Graphics.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Graphics.prototype,"x",{get:function(){return this.position.x},set:function(b){this.position.x=b}});Object.defineProperty(Phaser.Graphics.prototype,"y",{get:function(){return this.position.y},set:function(b){this.position.y=b}});Phaser.RenderTexture=function(c,d,e,b){this.game=c;this.name=d;PIXI.EventTarget.call(this);this.width=e||100;this.height=b||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);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;Phaser.Canvas={create:function(d,b){d=d||256;b=b||256;var c=document.createElement("canvas");c.width=d;c.height=b;c.style.display="block";return c},getOffset:function(c,b){b=b||new Phaser.Point;var d=c.getBoundingClientRect();var h=c.clientTop||document.body.clientTop||0;var g=c.clientLeft||document.body.clientLeft||0;var e=window.pageYOffset||c.scrollTop||document.body.scrollTop;var f=window.pageXOffset||c.scrollLeft||document.body.scrollLeft;b.x=d.left+f-g;b.y=d.top+e-h;return b},getAspectRatio:function(b){return b.width/b.height},setBackgroundColor:function(c,b){b=b||"rgb(0,0,0)";c.style.backgroundColor=b;return c},setTouchAction:function(b,c){c=c||"none";b.style.msTouchAction=c;b.style["ms-touch-action"]=c;b.style["touch-action"]=c;return b},addToDOM:function(b,c,d){c=c||"";if(typeof d==="undefined"){d=true}if(c!==""){if(document.getElementById(c)){document.getElementById(c).appendChild(b);if(d){document.getElementById(c).style.overflow="hidden"}}else{document.body.appendChild(b)}}else{document.body.appendChild(b)}return b},setTransform:function(f,h,g,d,b,e,c){f.setTransform(d,e,c,b,h,g);return f},setSmoothingEnabled:function(b,c){b.imageSmoothingEnabled=c;b.mozImageSmoothingEnabled=c;b.oImageSmoothingEnabled=c;b.webkitImageSmoothingEnabled=c;b.msImageSmoothingEnabled=c;return b},setImageRenderingCrisp:function(b){b.style["image-rendering"]="crisp-edges";b.style["image-rendering"]="-moz-crisp-edges";b.style["image-rendering"]="-webkit-optimize-contrast";b.style.msInterpolationMode="nearest-neighbor";return b},setImageRenderingBicubic:function(b){b.style["image-rendering"]="auto";b.style.msInterpolationMode="bicubic";return b}};Phaser.StageScaleMode=function(c,d,b){this._startHeight=0;this.forceLandscape=false;this.forcePortrait=false;this.incorrectOrientation=false;this.pageAlignHorizontally=false;this.pageAlignVeritcally=false;this.minWidth=null;this.maxWidth=null;this.minHeight=null;this.maxHeight=null;this.width=0;this.height=0;this.maxIterations=5;this.game=c;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.Point(1,1);this.aspectRatio=0;var e=this;window.addEventListener("orientationchange",function(f){return e.checkOrientation(f)},false);window.addEventListener("resize",function(f){return e.checkResize(f)},false)};Phaser.StageScaleMode.EXACT_FIT=0;Phaser.StageScaleMode.NO_SCALE=1;Phaser.StageScaleMode.SHOW_ALL=2;Phaser.StageScaleMode.prototype={startFullScreen:function(){if(this.isFullScreen){return}var b=this.game.canvas;if(b.requestFullScreen){b.requestFullScreen()}else{if(b.mozRequestFullScreen){b.mozRequestFullScreen()}else{if(b.webkitRequestFullScreen){b.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}}}this.game.stage.canvas.style.width="100%";this.game.stage.canvas.style.height="100%"},stopFullScreen:function(){if(document.cancelFullScreen){document.cancelFullScreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}}}},checkOrientationState:function(){if(this.incorrectOrientation){if((this.forceLandscape&&window.innerWidth>window.innerHeight)||(this.forcePortrait&&window.innerHeight>window.innerWidth)){this.game.paused=false;this.incorrectOrientation=false;this.refresh()}}else{if((this.forceLandscape&&window.innerWidthwindow.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()}},refresh:function(){var b=this;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)}}if(this._check==null&&this.maxIterations>0){this._iterations=this.maxIterations;this._check=window.setInterval(function(){return b.setScreenSize()},10);this.setScreenSize()}},setScreenSize:function(b){if(typeof b=="undefined"){b=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(b||window.innerHeight>this._startHeight||this._iterations<0){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}},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.widththis.maxWidth){this.width=this.maxWidth}else{this.width=b}if(this.maxHeight&&c>this.maxHeight){this.height=this.maxHeight}else{this.height=c}console.log("setExactFit",this.width,this.height,this.game.stage.offset)}};Object.defineProperty(Phaser.StageScaleMode.prototype,"isFullScreen",{get:function(){if(document.fullscreenElement===null||document.mozFullScreenElement===null||document.webkitFullscreenElement===null){return false}return true}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isPortrait",{get:function(){return this.orientation==0||this.orientation==180}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isLandscape",{get:function(){return this.orientation===90||this.orientation===-90}});Phaser.Device=function(){this.patchAndroidClearRectBug=false;this.desktop=false;this.iOS=false;this.android=false;this.chromeOS=false;this.linux=false;this.macOS=false;this.windows=false;this.canvas=false;this.file=false;this.fileSystem=false;this.localStorage=false;this.webGL=false;this.worker=false;this.touch=false;this.mspointer=false;this.css3D=false;this.pointerLock=false;this.arora=false;this.chrome=false;this.epiphany=false;this.firefox=false;this.ie=false;this.ieVersion=0;this.mobileSafari=false;this.midori=false;this.opera=false;this.safari=false;this.webApp=false;this.audioData=false;this.webAudio=false;this.ogg=false;this.opus=false;this.mp3=false;this.wav=false;this.m4a=false;this.webm=false;this.iPhone=false;this.iPhone4=false;this.iPad=false;this.pixelRatio=0;this._checkAudio();this._checkBrowser();this._checkCSS3D();this._checkDevice();this._checkFeatures();this._checkOS()};Phaser.Device.prototype={_checkOS:function(){var b=navigator.userAgent;if(/Android/.test(b)){this.android=true}else{if(/CrOS/.test(b)){this.chromeOS=true}else{if(/iP[ao]d|iPhone/i.test(b)){this.iOS=true}else{if(/Linux/.test(b)){this.linux=true}else{if(/Mac OS/.test(b)){this.macOS=true}else{if(/Windows/.test(b)){this.windows=true}}}}}}if(this.windows||this.macOS||this.linux){this.desktop=true}},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(b){this.localStorage=false}this.file=!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob;this.fileSystem=!!window.requestFileSystem;this.webGL=(function(){try{return !!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(c){return false}})();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},_checkBrowser:function(){var b=navigator.userAgent;if(/Arora/.test(b)){this.arora=true}else{if(/Chrome/.test(b)){this.chrome=true}else{if(/Epiphany/.test(b)){this.epiphany=true}else{if(/Firefox/.test(b)){this.firefox=true}else{if(/Mobile Safari/.test(b)){this.mobileSafari=true}else{if(/MSIE (\d+\.\d+);/.test(b)){this.ie=true;this.ieVersion=parseInt(RegExp.$1)}else{if(/Midori/.test(b)){this.midori=true}else{if(/Opera/.test(b)){this.opera=true}else{if(/Safari/.test(b)){this.safari=true}}}}}}}}}if(navigator.standalone){this.webApp=true}},_checkAudio:function(){this.audioData=!!(window.Audio);this.webAudio=!!(window.webkitAudioContext||window.AudioContext);var d=document.createElement("audio");var b=false;try{if(b=!!d.canPlayType){if(d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")){this.ogg=true}if(d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")){this.opus=true}if(d.canPlayType("audio/mpeg;").replace(/^no$/,"")){this.mp3=true}if(d.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")){this.wav=true}if(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/aac;").replace(/^no$/,"")){this.m4a=true}if(d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")){this.webm=true}}}catch(c){}},_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},_checkCSS3D:function(){var d=document.createElement("p");var e;var c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(d,null);for(var b in c){if(d.style[b]!==undefined){d.style[b]="translate3d(1px,1px,1px)";e=window.getComputedStyle(d).getPropertyValue(c[b])}}document.body.removeChild(d);this.css3D=(e!==undefined&&e.length>0&&e!=="none")},canPlayAudio:function(b){if(b=="mp3"&&this.mp3){return true}else{if(b=="ogg"&&(this.ogg||this.opus)){return true}else{if(b=="m4a"&&this.m4a){return true}else{if(b=="wav"&&this.wav){return true}else{if(b=="webm"&&this.webm){return true}}}}}return false},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}};Phaser.RequestAnimationFrame=function(c){this.game=c;this._isSetTimeOut=false;this.isRunning=false;var d=["ms","moz","webkit","o"];for(var b=0;b>>0;c-=e;c*=e;e=c>>>0;c-=e;e+=c*4294967296}return(e>>>0)*2.3283064365386963e-10},integer:function(){return this.rnd.apply(this)*4294967296},frac:function(){return this.rnd.apply(this)+(this.rnd.apply(this)*2097152|0)*1.1102230246251565e-16},real:function(){return this.integer()+this.frac()},integerInRange:function(c,b){return Math.floor(this.realInRange(c,b))},realInRange:function(c,b){c=c||0;b=b||0;return this.frac()*(b-c)+c},normal:function(){return 1-2*this.frac()},uuid:function(){var d,c;for(c=d="";d++<36;c+=~d%5|d*3&4?(d^15?8^this.frac()*(d^20?16:4):4).toString(16):"-"){}return c},pick:function(b){return b[this.integerInRange(0,b.length)]},weightedPick:function(b){return b[~~(Math.pow(this.frac(),2)*b.length)]},timestamp:function(d,c){return this.realInRange(d||946684800000,c||1577862000000)},angle:function(){return this.integerInRange(-180,180)}};Phaser.Math={PI2:Math.PI*2,fuzzyEqual:function(d,c,e){if(typeof e==="undefined"){e=0.0001}return Math.abs(d-c)c-e},fuzzyCeil:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.ceil(b-c)},fuzzyFloor:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.floor(b+c)},average:function(){var b=[];for(var d=0;d<(arguments.length-0);d++){b[d]=arguments[d+0]}var e=0;for(var c=0;c0)?Math.floor(b):Math.ceil(b)},shear:function(b){return b%1},snapTo:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.round(b/d);return c+b},snapToFloor:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.floor(b/d);return c+b},snapToCeil:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.ceil(b/d);return c+b},snapToInArray:function(d,c,f){if(typeof f==="undefined"){f=true}if(f){c.sort()}if(dd/2){c+=d*2}if(b<-d/2&&c>d/2){b+=d*2}return b-c},interpolateAngles:function(c,b,d,e,f){if(typeof e==="undefined"){e=true}if(typeof f==="undefined"){f=null}c=this.normalizeAngle(c,e);b=this.normalizeAngleToAnother(b,c,e);return(typeof f==="function")?f(d,c,b-c,1):this.interpolateFloat(c,b,d)},chanceRoll:function(b){if(typeof b==="undefined"){b=50}if(b<=0){return false}else{if(b>=100){return true}else{if(Math.random()*100>=b){return false}else{return true}}}},numberArray:function(e,c){var b=[];for(var d=e;d<=c;d++){b.push(d)}return b},maxAdd:function(d,c,b){d+=c;if(d>b){d=b}return d},minSub:function(d,c,b){d-=c;if(d0.5)?1:-1},isOdd:function(b){return(b&1)},isEven:function(b){if(b&1){return false}else{return true}},max:function(){for(var d=1,c=0,b=arguments.length;d=-180&&c<=180){return c}b=(c+180)%360;if(b<0){b+=360}return b-180},angleLimit:function(e,d,c){var b=e;if(e>c){b=c}else{if(e1){return this.linear(d[b],d[b-1],b-g)}return this.linear(d[e],d[e+1>b?b:e+1],g-e)},bezierInterpolation:function(e,d){var c=0;var g=e.length-1;for(var f=0;f<=g;f++){c+=Math.pow(1-d,g-f)*Math.pow(d,f)*e[f]*this.bernstein(g,f)}return c},catmullRomInterpolation:function(d,c){var b=d.length-1;var g=b*c;var e=Math.floor(g);if(d[0]===d[b]){if(c<0){e=Math.floor(g=b*(1+c))}return this.catmullRom(d[(e-1+b)%b],d[e],d[(e+1)%b],d[(e+2)%b],g-e)}else{if(c<0){return d[0]-(this.catmullRom(d[0],d[0],d[1],d[1],-g)-d[0])}if(c>1){return d[b]-(this.catmullRom(d[b],d[b],d[b-1],d[b-1],g-b)-d[b])}return this.catmullRom(d[e?e-1:0],d[e],d[bd.length-e)){b=d.length-e}if(b>0){return d[e+Math.floor(Math.random()*b)]}}return null},floor:function(b){var c=b|0;return(b>0)?(c):((c!=b)?(c-1):(c))},ceil:function(b){var c=b|0;return(b>0)?((c!=b)?(c+1):(c)):(c)},sinCosGenerator:function(b,j,d,h){if(typeof j==="undefined"){j=1}if(typeof d==="undefined"){d=1}if(typeof h==="undefined"){h=1}var i=j;var l=d;var f=h*Math.PI/b;var e=[];var k=[];for(var g=0;g0;d--){var c=Math.floor(Math.random()*(d+1));var b=e[d];e[d]=e[c];e[c]=b}return e},distance:function(e,g,d,f){var c=e-d;var b=g-f;return Math.sqrt(c*c+b*b)},distanceRounded:function(c,e,b,d){return Math.round(Phaser.Math.distance(c,e,b,d))},clamp:function(d,e,c){return(dc)?c:d)},clampBottom:function(b,c){return b=b){return 1}c=(c-d)/(b-d);return c*c*(3-2*c)},smootherstep:function(c,d,b){if(c<=d){return 0}if(c>=b){return 1}c=(c-d)/(b-d);return c*c*c*(c*(c*6-15)+10)},sign:function(b){return(b<0)?-1:((b>0)?1:0)},degToRad:function(){var b=Math.PI/180;return function(c){return c*b}}(),radToDeg:function(){var b=180/Math.PI;return function(c){return c*b}}()};Phaser.QuadTree=function(g,c,i,f,b,e,d,h){this.physicsManager=g;this.ID=g.quadTreeID;g.quadTreeID++;this.maxObjects=e||10;this.maxLevels=d||4;this.level=h||0;this.bounds={x:Math.round(c),y:Math.round(i),width:f,height:b,subWidth:Math.floor(f/2),subHeight:Math.floor(b/2),right:Math.round(c)+Math.floor(f/2),bottom:Math.round(i)+Math.floor(b/2)};this.objects=[];this.nodes=[]};Phaser.QuadTree.prototype={split:function(){this.level++;this.nodes[0]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[1]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[2]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[3]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(b){var d=0;var c;if(this.nodes[0]!=null){c=this.getIndex(b);if(c!==-1){this.nodes[c].insert(b);return}}this.objects.push(b);if(this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom)){b=2}}}else{if(c.x>this.bounds.right){if((c.ythis.bounds.bottom)){b=3}}}}return b},retrieve:function(b){var c=this.objects;b.body.quadTreeIndex=this.getIndex(b.body);b.body.quadTreeIDs.push(this.ID);if(this.nodes[0]){if(b.body.quadTreeIndex!==-1){c=c.concat(this.nodes[b.body.quadTreeIndex].retrieve(b))}else{c=c.concat(this.nodes[0].retrieve(b));c=c.concat(this.nodes[1].retrieve(b));c=c.concat(this.nodes[2].retrieve(b));c=c.concat(this.nodes[3].retrieve(b))}}return c},clear:function(){this.objects=[];for(var c=0,b=this.nodes.length;c0){this._radius=c*0.5}else{this._radius=0}};Phaser.Circle.prototype={circumference:function(){return 2*(Math.PI*this._radius)},setTo:function(b,d,c){this.x=b;this.y=d;this._diameter=c;this._radius=c*0.5;return this},copyFrom:function(b){return this.setTo(b.x,b.y,b.diameter)},copyTo:function(b){b[x]=this.x;b[y]=this.y;b[diameter]=this._diameter;return b},distance:function(c,b){if(typeof b==="undefined"){b=false}if(b){return Phaser.Math.distanceRound(this.x,this.y,c.x,c.y)}else{return Phaser.Math.distance(this.x,this.y,c.x,c.y)}},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Circle()}return b.setTo(a.x,a.y,a.diameter)},contains:function(b,c){return Phaser.Circle.contains(this,b,c)},circumferencePoint:function(d,c,b){return Phaser.Circle.circumferencePoint(this,d,c,b)},offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}};Object.defineProperty(Phaser.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(b){if(b>0){this._diameter=b;this._radius=b*0.5}}});Object.defineProperty(Phaser.Circle.prototype,"radius",{get:function(){return this._radius},set:function(b){if(b>0){this._radius=b;this._diameter=b*2}}});Object.defineProperty(Phaser.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(b){if(b>this.x){this._radius=0;this._diameter=0}else{this.radius=this.x-b}}});Object.defineProperty(Phaser.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(b){if(bthis.y){this._radius=0;this._diameter=0}else{this.radius=this.y-b}}});Object.defineProperty(Phaser.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(b){if(b0){return Math.PI*this._radius*this._radius}else{return 0}}});Object.defineProperty(Phaser.Circle.prototype,"empty",{get:function(){return(this._diameter==0)},set:function(b){this.setTo(0,0,0)}});Phaser.Circle.contains=function(d,b,f){if(b>=d.left&&b<=d.right&&f>=d.top&&f<=d.bottom){var e=(d.x-b)*(d.x-b);var c=(d.y-f)*(d.y-f);return(e+c)<=(d.radius*d.radius)}return false};Phaser.Circle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.diameter==c.diameter)};Phaser.Circle.intersects=function(d,c){return(Phaser.Math.distance(d.x,d.y,c.x,c.y)<=(d.radius+c.radius))};Phaser.Circle.circumferencePoint=function(b,e,d,c){if(typeof d==="undefined"){d=false}if(typeof c==="undefined"){c=new Phaser.Point()}if(d===true){e=Phaser.Math.radToDeg(e)}c.x=b.x+b.radius*Math.cos(e);c.y=b.y+b.radius*Math.sin(e);return c};Phaser.Circle.intersectsRectangle=function(m,d){var g=Math.abs(m.x-d.x-d.halfWidth);var l=d.halfWidth+m.radius;if(g>l){return false}var f=Math.abs(m.y-d.y-d.halfHeight);var j=d.halfHeight+m.radius;if(f>j){return false}if(g<=d.halfWidth||f<=d.halfHeight){return true}var h=g-d.halfWidth;var e=f-d.halfHeight;var k=h*h;var b=e*e;var i=m.radius*m.radius;return k+b<=i};Phaser.Point=function(b,c){b=b||0;c=c||0;this.x=b;this.y=c};Phaser.Point.prototype={copyFrom:function(b){return this.setTo(b.x,b.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(b,c){this.x=b;this.y=c;return this},add:function(b,c){this.x+=b;this.y+=c;return this},subtract:function(b,c){this.x-=b;this.y-=c;return this},multiply:function(b,c){this.x*=b;this.y*=c;return this},divide:function(b,c){this.x/=b;this.y/=c;return this},clampX:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);return this},clampY:function(c,b){this.y=Phaser.Math.clamp(this.y,c,b);return this},clamp:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);this.y=Phaser.Math.clamp(this.y,c,b);return this},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Point}return b.setTo(this.x,this.y)},copyFrom:function(b){return this.setTo(b.x,b.y)},copyTo:function(b){b[x]=this.x;b[y]=this.y;return b},distance:function(c,b){return Phaser.Point.distance(this,c,b)},equals:function(b){return(b.x==this.x&&b.y==this.y)},rotate:function(b,f,d,c,e){return Phaser.Point.rotate(this,b,f,d,c,e)},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};Phaser.Point.add=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x+c.x;e.y=d.y+c.y;return e};Phaser.Point.subtract=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x-c.x;e.y=d.y-c.y;return e};Phaser.Point.multiply=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x*c.x;e.y=d.y*c.y;return e};Phaser.Point.divide=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x/c.x;e.y=d.y/c.y;return e};Phaser.Point.equals=function(d,c){return(d.x==c.x&&d.y==c.y)};Phaser.Point.distance=function(d,c,e){if(typeof e==="undefined"){e=false}if(e){return Phaser.Math.distanceRound(d.x,d.y,c.x,c.y)}else{return Phaser.Math.distance(d.x,d.y,c.x,c.y)}},Phaser.Point.rotate=function(c,b,g,e,d,f){d=d||false;f=f||null;if(d){e=Phaser.Math.radToDeg(e)}if(f===null){f=Math.sqrt(((b-c.x)*(b-c.x))+((g-c.y)*(g-c.y)))}return c.setTo(b+f*Math.cos(e),g+f*Math.sin(e))};Phaser.Rectangle=function(c,e,d,b){c=c||0;e=e||0;d=d||0;b=b||0;this.x=c;this.y=e;this.width=d;this.height=b};Phaser.Rectangle.prototype={offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},setTo:function(c,e,d,b){this.x=c;this.y=e;this.width=d;this.height=b;return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y)},copyFrom:function(b){return this.setTo(b.x,b.y,b.width,b.height)},copyTo:function(b){b.x=this.x;b.y=this.y;b.width=this.width;b.height=this.height;return b},inflate:function(c,b){return Phaser.Rectangle.inflate(this,c,b)},size:function(b){return Phaser.Rectangle.size(this,b)},clone:function(b){return Phaser.Rectangle.clone(this,b)},contains:function(b,c){return Phaser.Rectangle.contains(this,b,c)},containsRect:function(c){return Phaser.Rectangle.containsRect(this,c)},equals:function(c){return Phaser.Rectangle.equals(this,c)},intersection:function(c,d){return Phaser.Rectangle.intersection(this,c,output)},intersects:function(c,d){return Phaser.Rectangle.intersects(this,c,d)},intersectsRaw:function(f,d,e,c,b){return Phaser.Rectangle.intersectsRaw(this,f,d,e,c,b)},union:function(c,d){return Phaser.Rectangle.union(this,c,d)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}};Object.defineProperty(Phaser.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"bottomRight",{get:function(){return new Phaser.Point(this.right,this.bottom)},set:function(b){this.right=b.x;this.bottom=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"left",{get:function(){return this.x},set:function(b){if(b>=this.right){this.width=0}else{this.width=this.right-b}this.x=b}});Object.defineProperty(Phaser.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Object.defineProperty(Phaser.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}});Object.defineProperty(Phaser.Rectangle.prototype,"perimeter",{get:function(){return(this.width*2)+(this.height*2)}});Object.defineProperty(Phaser.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(b){this.x=b-this.halfWidth}});Object.defineProperty(Phaser.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(b){this.y=b-this.halfHeight}});Object.defineProperty(Phaser.Rectangle.prototype,"top",{get:function(){return this.y},set:function(b){if(b>=this.bottom){this.height=0;this.y=b}else{this.height=(this.bottom-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"topLeft",{get:function(){return new Phaser.Point(this.x,this.y)},set:function(b){this.x=b.x;this.y=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"empty",{get:function(){return(!this.width||!this.height)},set:function(b){this.setTo(0,0,0,0)}});Phaser.Rectangle.inflate=function(c,d,b){c.x-=d;c.width+=2*d;c.y-=b;c.height+=2*b;return c};Phaser.Rectangle.inflatePoint=function(c,b){return Phaser.Phaser.Rectangle.inflate(c,b.x,b.y)};Phaser.Rectangle.size=function(b,c){if(typeof c==="undefined"){c=new Phaser.Point()}return c.setTo(b.width,b.height)};Phaser.Rectangle.clone=function(b,c){if(typeof c==="undefined"){c=new Phaser.Rectangle()}return c.setTo(b.x,b.y,b.width,b.height)};Phaser.Rectangle.contains=function(c,b,d){return(b>=c.x&&b<=c.right&&d>=c.y&&d<=c.bottom)};Phaser.Rectangle.containsPoint=function(c,b){return Phaser.Phaser.Rectangle.contains(c,b.x,b.y)};Phaser.Rectangle.containsRect=function(d,c){if(d.volume>c.volume){return false}return(d.x>=c.x&&d.y>=c.y&&d.right<=c.right&&d.bottom<=c.bottom)};Phaser.Rectangle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.width==c.width&&d.height==c.height)};Phaser.Rectangle.intersection=function(d,c,e){e=e||new Phaser.Rectangle;if(Phaser.Rectangle.intersects(d,c)){e.x=Math.max(d.x,c.x);e.y=Math.max(d.y,c.y);e.width=Math.min(d.right,c.right)-e.x;e.height=Math.min(d.bottom,c.bottom)-e.y}return e};Phaser.Rectangle.intersects=function(d,c,e){e=e||0;return !(d.x>c.right+e||d.rightc.bottom+e||d.bottomb.right+c||eb.bottom+c||d1){if(f&&f==this.decodeURI(d[0])){return this.decodeURI(d[1])}else{c[this.decodeURI(d[0])]=this.decodeURI(d[1])}}}return c},decodeURI:function(b){return decodeURIComponent(b.replace(/\+/g," "))}};Phaser.TweenManager=function(b){this.game=b;this._tweens=[];this._add=[];this.game.onPause.add(this.pauseAll,this);this.game.onResume.add(this.resumeAll,this)};Phaser.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(b){this._add.push(b)},create:function(b){return new Phaser.Tween(b,this.game)},remove:function(c){var b=this._tweens.indexOf(c);if(b!==-1){this._tweens[b].pendingDelete=true}},update:function(){if(this._tweens.length===0&&this._add.length===0){return false}var b=0;var c=this._tweens.length;while(b0){this._tweens=this._tweens.concat(this._add);this._add.length=0}return true},pauseAll:function(){for(var b=this._tweens.length-1;b>=0;b--){this._tweens[b].pause()}},resumeAll:function(){for(var b=this._tweens.length-1;b>=0;b--){this._tweens[b].resume()}}};Phaser.Tween=function(c,b){this._object=c;this.game=b;this._manager=this.game.tweens;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1000;this._repeat=0;this._yoyo=false;this._reversed=false;this._delayTime=0;this._startTime=null;this._easingFunction=Phaser.Easing.Linear.None;this._interpolationFunction=Phaser.Math.linearInterpolation;this._chainedTweens=[];this._onStartCallback=null;this._onStartCallbackFired=false;this._onUpdateCallback=null;this._onCompleteCallback=null;this._pausedTime=0;this.pendingDelete=false;for(var d in c){this._valuesStart[d]=parseFloat(c[d],10)}this.onStart=new Phaser.Signal();this.onComplete=new Phaser.Signal();this.isRunning=false};Phaser.Tween.prototype={to:function(d,g,h,c,b,f,e){g=g||1000;h=h||null;c=c||false;b=b||0;f=f||0;e=e||false;this._repeat=f;this._duration=g;this._valuesEnd=d;if(h!==null){this._easingFunction=h}if(b>0){this._delayTime=b}this._yoyo=e;if(c){return this.start()}else{return this}},start:function(c){if(this.game===null||this._object===null){return}this._manager.add(this);this.onStart.dispatch(this._object);this.isRunning=true;this._onStartCallbackFired=false;this._startTime=this.game.time.now+this._delayTime;for(var b in this._valuesEnd){if(this._valuesEnd[b] instanceof Array){if(this._valuesEnd[b].length===0){continue}this._valuesEnd[b]=[this._object[b]].concat(this._valuesEnd[b])}this._valuesStart[b]=this._object[b];if((this._valuesStart[b] instanceof Array)===false){this._valuesStart[b]*=1}this._valuesStartRepeat[b]=this._valuesStart[b]||0}return this},stop:function(){this._manager.remove(this);this.isRunning=false;return this},delay:function(b){this._delayTime=b;return this},repeat:function(b){this._repeat=b;return this},yoyo:function(b){this._yoyo=b;return this},easing:function(b){this._easingFunction=b;return this},interpolation:function(b){this._interpolationFunction=b;return this},chain:function(){this._chainedTweens=arguments;return this},onStartCallback:function(b){this._onStartCallback=b;return this},onUpdateCallback:function(b){this._onUpdateCallback=b;return this},onCompleteCallback:function(b){this._onCompleteCallback=b;return this},pause:function(){this._paused=true},resume:function(){this._paused=false;this._startTime+=this.game.time.pauseDuration},update:function(c){if(this.pendingDelete){return false}if(this._paused||c1?1:k;var h=this._easingFunction(k);for(j in this._valuesEnd){var b=this._valuesStart[j]||0;var d=this._valuesEnd[j];if(d instanceof Array){this._object[j]=this._interpolationFunction(d,h)}else{if(typeof(d)==="string"){d=b+parseFloat(d,10)}if(typeof(d)==="number"){this._object[j]=b+(d-b)*h}}}if(this._onUpdateCallback!==null){this._onUpdateCallback.call(this._object,h)}if(k==1){if(this._repeat>0){if(isFinite(this._repeat)){this._repeat--}for(j in this._valuesStartRepeat){if(typeof(this._valuesEnd[j])==="string"){this._valuesStartRepeat[j]=this._valuesStartRepeat[j]+parseFloat(this._valuesEnd[j],10)}if(this._yoyo){var e=this._valuesStartRepeat[j];this._valuesStartRepeat[j]=this._valuesEnd[j];this._valuesEnd[j]=e;this._reversed=!this._reversed}this._valuesStart[j]=this._valuesStartRepeat[j]}this._startTime=c+this._delayTime;this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}return true}else{this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}for(var f=0,g=this._chainedTweens.length;fthis._timeLastSecond+1000){this.fps=Math.round((this.frames*1000)/(this.now-this._timeLastSecond));this.fpsMin=this.game.math.min(this.fpsMin,this.fps);this.fpsMax=this.game.math.max(this.fpsMax,this.fps);this._timeLastSecond=this.now;this.frames=0}this.time=this.now;this.lastTime=b+this.timeToCall;this.physicsElapsed=1*(this.elapsed/1000);if(this.game.paused){this.pausedTime=this.now-this._pauseStarted}},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now();this.pauseDuration=this.pausedTime;this._justResumed=true},elapsedSince:function(b){return this.now-b},elapsedSecondsSince:function(b){return(this.now-b)*0.001},reset:function(){this._started=this.now}};Phaser.AnimationManager=function(b){this.sprite=b;this.game=b.game;this.currentFrame=null;this.updateIfVisible=true;this._frameData=null;this._anims={};this._outputFrames=[]};Phaser.AnimationManager.prototype={loadFrameData:function(b){this._frameData=b;this.frame=0},add:function(e,f,d,c,b){if(this._frameData==null){console.warn("No FrameData available for Phaser.Animation "+e);return}d=d||60;if(typeof c==="undefined"){c=false}if(typeof b==="undefined"){b=true}if(this.sprite.events.onAnimationStart==null){this.sprite.events.onAnimationStart=new Phaser.Signal();this.sprite.events.onAnimationComplete=new Phaser.Signal();this.sprite.events.onAnimationLoop=new Phaser.Signal()}this._outputFrames.length=0;this._frameData.getFrameIndexes(f,b,this._outputFrames);this._anims[e]=new Phaser.Animation(this.game,this.sprite,e,this._frameData,this._outputFrames,d,c);this.currentAnim=this._anims[e];this.currentFrame=this.currentAnim.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);return this._anims[e]},validateFrames:function(d,b){if(typeof b=="undefined"){b=true}for(var c=0;cthis._frameData.total){return false}}else{if(this._frameData.checkFrameName(d[c])==false){return false}}}return true},play:function(d,c,b){if(this._anims[d]){if(this.currentAnim==this._anims[d]){if(this.currentAnim.isPlaying==false){return this.currentAnim.play(c,b)}}else{this.currentAnim=this._anims[d];return this.currentAnim.play(c,b)}}},stop:function(c,b){if(typeof b=="undefined"){b=false}if(typeof c=="string"){if(this._anims[c]){this.currentAnim=this._anims[c];this.currentAnim.stop(b)}}else{if(this.currentAnim){this.currentAnim.stop(b)}}},update:function(){if(this.updateIfVisible&&this.sprite.visible==false){return false}if(this.currentAnim&&this.currentAnim.update()==true){this.currentFrame=this.currentAnim.currentFrame;this.sprite.currentFrame=this.currentFrame;return true}return false},destroy:function(){this._anims={};this._frameData=null;this._frameIndex=0;this.currentAnim=null;this.currentFrame=null}};Object.defineProperty(Phaser.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameTotal",{get:function(){if(this._frameData){return this._frameData.total}else{return -1}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame){return this._frameIndex}},set:function(b){if(this._frameData&&this._frameData.getFrame(b)!==null){this.currentFrame=this._frameData.getFrame(b);this._frameIndex=b;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame){return this.currentFrame.name}},set:function(b){if(this._frameData&&this._frameData.getFrameByName(b)!==null){this.currentFrame=this._frameData.getFrameByName(b);this._frameIndex=this.currentFrame.index;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}else{console.warn("Cannot set frameName: "+b)}}});Phaser.Animation=function(c,g,e,f,h,d,b){this.game=c;this._parent=g;this._frameData=f;this.name=e;this._frames=[];this._frames=this._frames.concat(h);this.delay=1000/d;this.looped=b;this.isFinished=false;this.isPlaying=false;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])};Phaser.Animation.prototype={play:function(c,b){c=c||null;b=b||null;if(c!==null){this.delay=1000/c}if(b!==null){this.looped=b}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.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);if(this._parent.events){this._parent.events.onAnimationStart.dispatch(this._parent,this)}return this},restart:function(){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:function(b){if(typeof b==="undefined"){b=false}this.isPlaying=false;this.isFinished=true;if(b){this.currentFrame=this._frameData.getFrame(this._frames[0])}},update:function(){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.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);this._parent.events.onAnimationLoop.dispatch(this._parent,this)}else{this.onComplete()}}else{this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;return true}return false},destroy:function(){this.game=null;this._parent=null;this._frames=null;this._frameData=null;this.currentFrame=null;this.isPlaying=false},onComplete:function(){this.isPlaying=false;this.isFinished=true;if(this._parent.events){this._parent.events.onAnimationComplete.dispatch(this._parent,this)}}};Object.defineProperty(Phaser.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}});Object.defineProperty(Phaser.Animation.prototype,"frame",{get:function(){if(this.currentFrame!==null){return this.currentFrame.index}else{return this._frameIndex}},set:function(b){this.currentFrame=this._frameData.getFrame(b);if(this.currentFrame!==null){this._frameIndex=b;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Phaser.Animation.Frame=function(e,c,h,g,b,d,f){this.index=e;this.x=c;this.y=h;this.width=g;this.height=b;this.name=d;this.uuid=f;this.centerX=Math.floor(g/2);this.centerY=Math.floor(b/2);this.distance=Phaser.Math.distance(0,0,g,b);this.rotated=false;this.rotationDirection="cw";this.trimmed=false;this.sourceSizeW=g;this.sourceSizeH=b;this.spriteSourceSizeX=0;this.spriteSourceSizeY=0;this.spriteSourceSizeW=0;this.spriteSourceSizeH=0};Phaser.Animation.Frame.prototype={setTrim:function(f,e,h,c,b,d,g){this.trimmed=f;if(f){this.width=e;this.height=h;this.sourceSizeW=e;this.sourceSizeH=h;this.centerX=Math.floor(e/2);this.centerY=Math.floor(h/2);this.spriteSourceSizeX=c;this.spriteSourceSizeY=b;this.spriteSourceSizeW=d;this.spriteSourceSizeH=g}}};Phaser.Animation.FrameData=function(){this._frames=[];this._frameNames=[]};Phaser.Animation.FrameData.prototype={addFrame:function(b){b.index=this._frames.length;this._frames.push(b);if(b.name!==""){this._frameNames[b.name]=b.index}return b},getFrame:function(b){if(this._frames[b]){return this._frames[b]}return null},getFrameByName:function(b){if(typeof this._frameNames[b]==="number"){return this._frames[this._frameNames[b]]}return null},checkFrameName:function(b){if(this._frameNames[b]==null){return false}return true},getFrameRange:function(e,b,c){if(typeof c==="undefined"){c=[]}for(var d=e;d<=b;d++){c.push(this._frames[d])}return c},getFrames:function(f,c,d){if(typeof c==="undefined"){c=true}if(typeof d==="undefined"){d=[]}if(typeof f==="undefined"||f.length==0){for(var e=0;e tag");return}var d=new Phaser.Animation.FrameData();var j=g.getElementsByTagName("SubTexture");var f;for(var e=0;e0){this._progressChunk=100/this._keys.length;this.loadFile()}else{this.progress=100;this.hasLoaded=true;this.onLoadComplete.dispatch()}},loadFile:function(){var b=this._fileList[this._keys.shift()];var c=this;switch(b.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tilemap":b.data=new Image();b.data.name=b.key;b.data.onload=function(){return c.fileComplete(b.key)};b.data.onerror=function(){return c.fileError(b.key)};b.data.crossOrigin=this.crossOrigin;b.data.src=this.baseURL+b.url;break;case"audio":b.url=this.getAudioURL(b.url);if(b.url!==null){if(this.game.sound.usingWebAudio){this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="arraybuffer";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send()}else{if(this.game.sound.usingAudioTag){if(this.game.sound.touchLocked){b.data=new Audio();b.data.name=b.key;b.data.preload="auto";b.data.src=this.baseURL+b.url;this.fileComplete(b.key)}else{b.data=new Audio();b.data.name=b.key;b.data.onerror=function(){return c.fileError(b.key)};b.data.preload="auto";b.data.src=this.baseURL+b.url;b.data.addEventListener("canplaythrough",Phaser.GAMES[this.game.id].load.fileComplete(b.key),false);b.data.load()}}}}else{this.fileError(b.key)}break;case"text":this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="text";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send();break}},getAudioURL:function(c){var d;for(var b=0;b100){this.progress=100}if(this.preloadSprite!==null){if(this.preloadSprite.direction==0){this.preloadSprite.crop.width=(this.preloadSprite.width/100)*this.progress}else{this.preloadSprite.crop.height=(this.preloadSprite.height/100)*this.progress}this.preloadSprite.sprite.crop=this.preloadSprite.crop}this.onFileComplete.dispatch(this.progress,b,c,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()}}};Phaser.Loader.Parser={bitmapFont:function(q,h,l){if(!h.getElementsByTagName("font")){console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing tag");return}var m=PIXI.TextureCache[l];var e={};var c=h.getElementsByTagName("info")[0];var j=h.getElementsByTagName("common")[0];e.font=c.attributes.getNamedItem("face").nodeValue;e.size=parseInt(c.attributes.getNamedItem("size").nodeValue,10);e.lineHeight=parseInt(j.attributes.getNamedItem("lineHeight").nodeValue,10);e.chars={};var k=h.getElementsByTagName("char");for(var d=0;d=this.duration){if(this.usingWebAudio){if(this.loop){this.onLoop.dispatch(this);if(this.currentMarker==""){this.currentTime=0;this.startTime=this.game.time.now}else{this.play(this.currentMarker,0,this.volume,true,true)}}else{this.stop()}}else{if(this.loop){this.onLoop.dispatch(this);this.play(this.currentMarker,0,this.volume,true,true)}else{this.stop()}}}}},play:function(d,b,f,c,e){d=d||"";b=b||0;f=f||1;if(typeof c=="undefined"){c=false}if(typeof e=="undefined"){e=false}console.log("play "+d+" position "+b+" volume "+f+" loop "+c);if(this.isPlaying==true&&e==false&&this.override==false){return}if(this.isPlaying&&this.override){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=d;if(d!==""&&this.markers[d]){this.position=this.markers[d].start;this.volume=this.markers[d].volume;this.loop=this.markers[d].loop;this.duration=this.markers[d].duration*1000;this._tempMarker=d;this._tempPosition=this.position;this._tempVolume=this.volume;this._tempLoop=this.loop}else{this.position=b;this.volume=f;this.loop=c;this.duration=0;this._tempMarker=d;this._tempPosition=b;this._tempVolume=f;this._tempLoop=c}if(this.usingWebAudio){if(this.game.cache.isSoundDecoded(this.key)){if(this._buffer==null){this._buffer=this.game.cache.getSoundData(this.key)}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&&d==""){this._sound.loop=true}if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration/1000)}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)}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{if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked){this.game.cache.reloadSound(this.key);this.pendingPlayback=true}else{if(this._sound&&this._sound.readyState==4){this._sound.play();this.totalDuration=this._sound.duration;if(this.duration==0){this.duration=this.totalDuration*1000}this._sound.currentTime=this.position;this._sound.muted=this._muted;if(this._muted){this._sound.volume=0}else{this._sound.volume=this._volume}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}}}},restart:function(d,b,e,c){d=d||"";b=b||0;e=e||1;if(typeof c=="undefined"){c=false}this.play(d,b,e,c,true)},pause:function(){if(this.isPlaying&&this._sound){this.stop();this.isPlaying=false;this.paused=true;this.onPause.dispatch(this)}},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration)}else{this._sound.start(0,this.position,this.duration)}}else{this._sound.play()}this.isPlaying=true;this.paused=false;this.onResume.dispatch(this)}},stop:function(){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 b=this.currentMarker;this.currentMarker="";this.onStop.dispatch(this,b)}};Object.defineProperty(Phaser.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}});Object.defineProperty(Phaser.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}});Object.defineProperty(Phaser.Sound.prototype,"mute",{get:function(){return this._muted},set:function(b){b=b||null;if(b){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)}});Object.defineProperty(Phaser.Sound.prototype,"volume",{get:function(){return this._volume},set:function(b){if(this.usingWebAudio){this._volume=b;this.gainNode.gain.value=b}else{if(this.usingAudioTag&&this._sound){if(b>=0&&b<=1){this._volume=b;this._sound.volume=b}}}}});Phaser.SoundManager=function(b){this.game=b;this.onSoundDecode=new Phaser.Signal;this._muted=false;this._unlockSource=null;this._volume=1;this._sounds=[];this.context=null;this.usingWebAudio=true;this.usingAudioTag=false;this.noAudio=false;this.touchLocked=false;this.channels=32};Phaser.SoundManager.prototype={boot:function(){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{this.touchLocked=false}if(window.PhaserGlobal){if(window.PhaserGlobal.disableAudio==true){this.usingWebAudio=false;this.noAudio=true;return}if(window.PhaserGlobal.disableWebAudio==true){this.usingWebAudio=false;this.usingAudioTag=true;this.noAudio=false;return}}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)}},unlock:function(){if(this.touchLocked==false){return}if(this.game.device.webAudio==false||(window.PhaserGlobal&&window.PhaserGlobal.disableWebAudio==true)){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}else{var b=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource();this._unlockSource.buffer=b;this._unlockSource.connect(this.context.destination);this._unlockSource.noteOn(0)}},stopAll:function(){for(var b=0;b255){return Phaser.Color.getColor(255,255,255)}if(d>c){return Phaser.Color.getColor(255,255,255)}var f=d+Math.round(Math.random()*(c-d));var e=d+Math.round(Math.random()*(c-d));var b=d+Math.round(Math.random()*(c-d));return Phaser.Color.getColor32(g,f,e,b)},getRGB:function(b){return{alpha:b>>>24,red:b>>16&255,green:b>>8&255,blue:b&255}},getWebRGB:function(c){var f=(c>>>24)/255;var e=c>>16&255;var d=c>>8&255;var b=c&255;return"rgba("+e.toString()+","+d.toString()+","+b.toString()+","+f.toString()+")"},getAlpha:function(b){return b>>>24},getAlphaFloat:function(b){return(b>>>24)/255},getRed:function(b){return b>>16&255},getGreen:function(b){return b>>8&255},getBlue:function(b){return b&255}};Phaser.Physics={};Phaser.Physics.Arcade=function(b){this.game=b;this.gravity=new Phaser.Point;this.bounds=new Phaser.Rectangle(0,0,b.world.width,b.world.height);this.maxObjects=10;this.maxLevels=4;this.OVERLAP_BIAS=4;this.TILE_OVERLAP=false;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels);this.quadTreeID=0;this._bounds1=new Phaser.Rectangle;this._bounds2=new Phaser.Rectangle;this._overlap=0;this._maxOverlap=0;this._velocity1=0;this._velocity2=0;this._newVelocity1=0;this._newVelocity2=0;this._average=0;this._mapData=[];this._result=false;this._total=0};Phaser.Physics.Arcade.prototype={updateMotion:function(b){this._velocityDelta=(this.computeVelocity(0,false,b.angularVelocity,b.angularAcceleration,b.angularDrag,b.maxAngular)-b.angularVelocity)/2;b.angularVelocity+=this._velocityDelta;b.rotation+=b.angularVelocity*this.game.time.physicsElapsed;this._velocityDelta=(this.computeVelocity(1,b,b.velocity.x,b.acceleration.x,b.drag.x)-b.velocity.x)/2;b.velocity.x+=this._velocityDelta;this._delta=b.velocity.x*this.game.time.physicsElapsed;b.x+=this._delta;this._velocityDelta=(this.computeVelocity(2,b,b.velocity.y,b.acceleration.y,b.drag.y)-b.velocity.y)/2;b.velocity.y+=this._velocityDelta;this._delta=b.velocity.y*this.game.time.physicsElapsed;b.y+=this._delta},computeVelocity:function(e,c,g,f,d,b){b=b||10000;if(e==1&&c.allowGravity){g+=this.gravity.x+c.gravity.x}else{if(e==2&&c.allowGravity){g+=this.gravity.y+c.gravity.y}}if(f!==0){g+=f*this.game.time.physicsElapsed}else{if(d!==0){this._drag=d*this.game.time.physicsElapsed;if(g-this._drag>0){g=g-this._drag}else{if(g+this._drag<0){g+=this._drag}else{g=0}}}}if(g!=0){if(g>b){g=b}else{if(g<-b){g=-b}}}return g},preUpdate:function(){this.quadTree.clear();this.quadTreeID=0;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},collide:function(f,e,d,c,b){d=d||null;c=c||null;b=b||d;this._result=false;this._total=0;if(f&&e&&f.exists&&e.exists){if(f.type==Phaser.SPRITE){if(e.type==Phaser.SPRITE){this.collideSpriteVsSprite(f,e,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideSpriteVsGroup(f,e,d,c,b)}else{if(e.type==Phaser.TILEMAP){this.collideSpriteVsTilemap(f,e,d,c,b)}}}}else{if(f.type==Phaser.GROUP){if(e.type==Phaser.SPRITE){this.collideSpriteVsGroup(e,f,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideGroupVsGroup(f,e,d,c,b)}else{if(e.type==Phaser.TILEMAP){this.collideGroupVsTilemap(f,e,d,c,b)}}}}else{if(f.type==Phaser.TILEMAP){if(e.type==Phaser.SPRITE){this.collideSpriteVsTilemap(e,f,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideGroupVsTilemap(e,f,d,c,b)}}}else{if(f.type==Phaser.EMITTER){if(e.type==Phaser.SPRITE){this.collideSpriteVsGroup(e,f,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideGroupVsGroup(f,e,d,c,b)}else{if(e.type==Phaser.TILEMAP){this.collideGroupVsTilemap(f,e,d,c,b)}}}}}}}}return(this._total>0)},collideSpriteVsSprite:function(f,e,d,c,b){this.separate(f.body,e.body);if(this._result){if(c){if(c.call(b,f,e)){this._total++;if(d){d.call(b,f,e)}}}else{this._total++;if(d){d.call(b,f,e)}}}},collideGroupVsTilemap:function(g,f,e,d,b){if(g._container.first._iNext){var c=g._container.first._iNext;do{if(c.exists){this.collideSpriteVsTilemap(c,f,e,d,b)}c=c._iNext}while(c!=g._container.last._iNext)}},collideSpriteVsTilemap:function(d,g,f,e,b){this._mapData=g.collisionLayer.getTileOverlaps(d);var c=this._mapData.length;while(c--){if(e){if(e.call(b,d,this._mapData[c].tile)){this._total++;if(f){f.call(b,d,this._mapData[c].tile)}}}else{this._total++;if(f){f.call(b,d,this._mapData[c].tile)}}}},collideSpriteVsGroup:function(e,h,g,f,c){this._potentials=this.quadTree.retrieve(e);for(var d=0,b=this._potentials.length;d0)?c.deltaX():0),c.lastY,c.width+((c.deltaX()>0)?c.deltaX():-c.deltaX()),c.height);this._bounds2.setTo(b.x-((b.deltaX()>0)?b.deltaX():0),b.lastY,b.width+((b.deltaX()>0)?b.deltaX():-b.deltaX()),b.height);if((this._bounds1.right>this._bounds2.x)&&(this._bounds1.xthis._bounds2.y)&&(this._bounds1.yb.deltaX()){this._overlap=c.x+c.width-b.x;if((this._overlap>this._maxOverlap)||c.allowCollision.right==false||b.allowCollision.left==false){this._overlap=0}else{c.touching.right=true;b.touching.left=true}}else{if(c.deltaX()this._maxOverlap)||c.allowCollision.left==false||b.allowCollision.right==false){this._overlap=0}else{c.touching.left=true;b.touching.right=true}}}}}if(this._overlap!=0){c.overlapX=this._overlap;b.overlapX=this._overlap;if(c.customSeparateX||b.customSeparateX){return true}this._velocity1=c.velocity.x;this._velocity2=b.velocity.x;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.x=c.x-this._overlap;b.x+=this._overlap;this._newVelocity1=Math.sqrt((this._velocity2*this._velocity2*b.mass)/c.mass)*((this._velocity2>0)?1:-1);this._newVelocity2=Math.sqrt((this._velocity1*this._velocity1*c.mass)/b.mass)*((this._velocity1>0)?1:-1);this._average=(this._newVelocity1+this._newVelocity2)*0.5;this._newVelocity1-=this._average;this._newVelocity2-=this._average;c.velocity.x=this._average+this._newVelocity1*c.bounce.x;b.velocity.x=this._average+this._newVelocity2*b.bounce.x}else{if(!c.immovable){c.x=c.x-this._overlap;c.velocity.x=this._velocity2-this._velocity1*c.bounce.x}else{if(!b.immovable){b.x+=this._overlap;b.velocity.x=this._velocity1-this._velocity2*b.bounce.x}}}return true}else{return false}},separateY:function(c,b){if(c.immovable&&b.immovable){return false}this._overlap=0;if(c.deltaY()!=b.deltaY()){this._bounds1.setTo(c.x,c.y-((c.deltaY()>0)?c.deltaY():0),c.width,c.height+c.deltaAbsY());this._bounds2.setTo(b.x,b.y-((b.deltaY()>0)?b.deltaY():0),b.width,b.height+b.deltaAbsY());if((this._bounds1.right>this._bounds2.x)&&(this._bounds1.xthis._bounds2.y)&&(this._bounds1.yb.deltaY()){this._overlap=c.y+c.height-b.y;if((this._overlap>this._maxOverlap)||c.allowCollision.down==false||b.allowCollision.up==false){this._overlap=0}else{c.touching.down=true;b.touching.up=true}}else{if(c.deltaY()this._maxOverlap)||c.allowCollision.up==false||b.allowCollision.down==false){this._overlap=0}else{c.touching.up=true;b.touching.down=true}}}}}if(this._overlap!=0){c.overlapY=this._overlap;b.overlapY=this._overlap;if(c.customSeparateY||b.customSeparateY){return true}this._velocity1=c.velocity.y;this._velocity2=b.velocity.y;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.y=c.y-this._overlap;b.y+=this._overlap;this._newVelocity1=Math.sqrt((this._velocity2*this._velocity2*b.mass)/c.mass)*((this._velocity2>0)?1:-1);this._newVelocity2=Math.sqrt((this._velocity1*this._velocity1*c.mass)/b.mass)*((this._velocity1>0)?1:-1);this._average=(this._newVelocity1+this._newVelocity2)*0.5;this._newVelocity1-=this._average;this._newVelocity2-=this._average;c.velocity.y=this._average+this._newVelocity1*c.bounce.y;b.velocity.y=this._average+this._newVelocity2*b.bounce.y}else{if(!c.immovable){c.y=c.y-this._overlap;c.velocity.y=this._velocity2-this._velocity1*c.bounce.y;if(b.active&&b.moves&&(c.deltaY()>b.deltaY())){c.x+=b.x-b.lastX}}else{if(!b.immovable){b.y+=this._overlap;b.velocity.y=this._velocity1-this._velocity2*b.bounce.y;if(c.sprite.active&&c.moves&&(c.deltaY()h)&&(this._bounds1.xg)&&(this._bounds1.y0){this._overlap=c.x+c.width-h;if((this._overlap>this._maxOverlap)||!c.allowCollision.right||!d){this._overlap=0}else{c.touching.right=true}}else{if(c.deltaX()<0){this._overlap=c.x-b-h;if((-this._overlap>this._maxOverlap)||!c.allowCollision.left||!i){this._overlap=0}else{c.touching.left=true}}}}}if(this._overlap!=0){if(e){c.x=c.x-this._overlap;if(c.bounce.x==0){c.velocity.x=0}else{c.velocity.x=-c.velocity.x*c.bounce.x}}return true}else{return false}},separateTileY:function(d,h,g,c,j,f,i,b,e){if(d.immovable){return false}this._overlap=0;if(d.deltaY()!=0){this._bounds1.setTo(d.x,d.y,d.width,d.height);if((this._bounds1.right>h)&&(this._bounds1.xg)&&(this._bounds1.y0){this._overlap=d.bottom-g;if((this._overlap>this._maxOverlap)||!d.allowCollision.down||!b){this._overlap=0}else{d.touching.down=true}}else{this._overlap=d.y-j-g;if((-this._overlap>this._maxOverlap)||!d.allowCollision.up||!i){this._overlap=0}else{d.touching.up=true}}}}if(this._overlap!=0){if(e){d.y=d.y-this._overlap;if(d.bounce.y==0){d.velocity.y=0}else{d.velocity.y=-d.velocity.y*d.bounce.y}}return true}else{return false}},velocityFromAngle:function(e,d,b){d=d||0;b=b||new Phaser.Point;var c=this.game.math.degToRad(e);return b.setTo((Math.cos(c)*d),(Math.sin(c)*d))},moveTowardsObject:function(g,e,f,c){f=f||60;c=c||0;var b=this.angleBetween(g,e);if(c>0){var h=this.distanceBetween(g,e);f=h/(c/1000)}g.body.velocity.x=Math.cos(b)*f;g.body.velocity.y=Math.sin(b)*f},accelerateTowardsObject:function(f,d,e,b,g){b=b||1000;g=g||1000;var c=this.angleBetween(f,d);f.body.velocity.x=0;f.body.velocity.y=0;f.body.acceleration.x=Math.cos(c)*e;f.body.acceleration.y=Math.sin(c)*e;f.body.maxVelocity.x=b;f.body.maxVelocity.y=g},moveTowardsMouse:function(f,e,c){e=e||60;c=c||0;var b=this.angleBetweenMouse(f);if(c>0){var g=this.distanceToMouse(f);e=g/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsMouse:function(e,d,b,f){b=b||1000;f=f||1000;var c=this.angleBetweenMouse(e);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=f},moveTowardsPoint:function(f,g,e,c){e=e||60;c=c||0;var b=this.angleBetweenPoint(f,g);if(c>0){var h=this.distanceToPoint(f,g);e=h/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsPoint:function(e,f,d,b,g){b=b||1000;g=g||1000;var c=this.angleBetweenPoint(e,f);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=g},distanceBetween:function(e,c){var f=e.center.x-c.center.x;var d=e.center.y-c.center.y;return Math.sqrt(f*f+d*d)},distanceToPoint:function(c,e){var d=c.center.x-e.x;var b=c.center.y-e.y;return Math.sqrt(d*d+b*b)},distanceToMouse:function(c){var d=c.center.x-this.game.input.x;var b=c.center.y-this.game.input.y;return Math.sqrt(d*d+b*b)},angleBetweenPoint:function(c,f,e){e=e||false;var d=f.x-c.center.x;var b=f.y-c.center.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}},angleBetween:function(e,c,g){g=g||false;var f=c.center.x-e.center.x;var d=c.center.y-e.center.y;if(g){return this.game.math.radToDeg(Math.atan2(d,f))}else{return Math.atan2(d,f)}},velocityFromFacing:function(b,c){},angleBetweenMouse:function(c,e){e=e||false;var d=this.game.input.x-c.bounds.x;var b=this.game.input.y-c.bounds.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}}};Phaser.Physics.Arcade.Body=function(b){this.sprite=b;this.game=b.game;this.offset=new Phaser.Point;this.x=b.x;this.y=b.y;this.lastX=b.x;this.lastY=b.y;this.sourceWidth=b.currentFrame.sourceSizeW;this.sourceHeight=b.currentFrame.sourceSizeH;this.width=b.currentFrame.sourceSizeW;this.height=b.currentFrame.sourceSizeH;this.halfWidth=Math.floor(b.currentFrame.sourceSizeW/2);this.halfHeight=Math.floor(b.currentFrame.sourceSizeH/2);this._sx=b.scale.x;this._sy=b.scale.y;this.velocity=new Phaser.Point;this.acceleration=new Phaser.Point;this.drag=new Phaser.Point;this.gravity=new Phaser.Point;this.bounce=new Phaser.Point;this.maxVelocity=new Phaser.Point(10000,10000);this.angularVelocity=0;this.angularAcceleration=0;this.angularDrag=0;this.maxAngular=1000;this.mass=1;this.quadTreeIDs=[];this.quadTreeIndex=-1;this.allowCollision={none:false,any:true,up:true,down:true,left:true,right:true};this.touching={none:true,up:false,down:false,left:false,right:false};this.wasTouching={none:true,up:false,down:false,left:false,right:false};this.immovable=false;this.moves=true;this.rotation=0;this.allowRotation=true;this.allowGravity=true;this.customSeparateX=false;this.customSeparateY=false;this.overlapX=0;this.overlapY=0;this.collideWorldBounds=false};Phaser.Physics.Arcade.Body.prototype={updateBounds:function(e,d,c,b){if(c!=this._sx||b!=this._sy){this.width=this.sourceWidth*c;this.height=this.sourceHeight*b;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this._sx=c;this._sy=b}},update:function(){this.wasTouching.none=this.touching.none;this.wasTouching.up=this.touching.up;this.wasTouching.down=this.touching.down;this.wasTouching.left=this.touching.left;this.wasTouching.right=this.touching.right;this.touching.none=true;this.touching.up=false;this.touching.down=false;this.touching.left=false;this.touching.right=false;this.lastX=this.x;this.lastY=this.y;this.rotation=this.sprite.angle;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;if(this.moves){this.game.physics.updateMotion(this)}if(this.collideWorldBounds){this.checkWorldBounds()}if(this.allowCollision.none==false&&this.sprite.visible&&this.sprite.alive){this.quadTreeIDs=[];this.quadTreeIndex=-1;this.game.physics.quadTree.insert(this)}if(this.deltaX()!=0){this.sprite.x-=this.deltaX()}if(this.deltaY()!=0){this.sprite.y-=this.deltaY()}this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},postUpdate:function(){this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},checkWorldBounds:function(){if(this.xthis.game.world.bounds.right){this.x=this.game.world.bounds.right-this.width;this.velocity.x*=-this.bounce.x}}if(this.ythis.game.world.bounds.bottom){this.y=this.game.world.bounds.bottom-this.height;this.velocity.y*=-this.bounce.y}}},setSize:function(d,c,b,e){b=b||this.offset.x;e=e||this.offset.y;this.sourceWidth=d;this.sourceHeight=c;this.width=this.sourceWidth*this._sx;this.height=this.sourceHeight*this._sy;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this.offset.setTo(b,e)},reset:function(){this.velocity.setTo(0,0);this.acceleration.setTo(0,0);this.angularVelocity=0;this.angularAcceleration=0;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;this.lastX=this.x;this.lastY=this.y},deltaAbsX:function(){return(this.deltaX()>0?this.deltaX():-this.deltaX())},deltaAbsY:function(){return(this.deltaY()>0?this.deltaY():-this.deltaY())},deltaX:function(){return this.x-this.lastX},deltaY:function(){return this.y-this.lastY}};Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Phaser.Particles=function(b){this.emitters={};this.ID=0};Phaser.Particles.prototype={emitters:null,add:function(b){this.emitters[b.name]=b;return b},remove:function(b){delete this.emitters[b.name]},update:function(){for(var b in this.emitters){if(this.emitters[b].exists){this.emitters[b].update()}}}};Phaser.Particles.Arcade={};Phaser.Particles.Arcade.Emitter=function(c,b,e,d){d=d||50;Phaser.Group.call(this,c);this.name="emitter"+this.game.particles.ID++;this.type=Phaser.EMITTER;this.x=0;this.y=0;this.width=1;this.height=1;this.minParticleSpeed=new Phaser.Point(-100,-100);this.maxParticleSpeed=new Phaser.Point(100,100);this.minParticleScale=1;this.maxParticleScale=1;this.minRotation=-360;this.maxRotation=360;this.gravity=2;this.particleClass=null;this.particleDrag=new Phaser.Point();this.angularDrag=0;this.frequency=100;this.maxParticles=d;this.lifespan=2000;this.bounce=new Phaser.Point();this._quantity=0;this._timer=0;this._counter=0;this._explode=true;this.on=false;this.exists=true;this.emitX=b;this.emitY=e};Phaser.Particles.Arcade.Emitter.prototype=Object.create(Phaser.Group.prototype);Phaser.Particles.Arcade.Emitter.prototype.constructor=Phaser.Particles.Arcade.Emitter;Phaser.Particles.Arcade.Emitter.prototype.update=function(){if(this.on){if(this._explode){this._counter=0;do{this.emitParticle();this._counter++}while(this._counter=this._timer){this.emitParticle();this._counter++;if(this._quantity>0){if(this._counter>=this._quantity){this.on=false}}this._timer=this.game.time.now+this.frequency}}}};Phaser.Particles.Arcade.Emitter.prototype.makeParticles=function(j,f,c,h,k){if(typeof f=="undefined"){f=0}c=c||this.maxParticles;h=h||0;if(typeof k=="undefined"){k=false}var e;var d=0;var b=j;var g=0;while(d0){e.body.allowCollision.any=true;e.body.allowCollision.none=false}else{e.body.allowCollision.none=true}e.body.collideWorldBounds=k;e.exists=false;e.visible=false;e.anchor.setTo(0.5,0.5);this.add(e);d++}return this};Phaser.Particles.Arcade.Emitter.prototype.kill=function(){this.on=false;this.alive=false;this.exists=false};Phaser.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=true;this.exists=true};Phaser.Particles.Arcade.Emitter.prototype.start=function(b,e,d,c){if(typeof b!=="boolean"){b=true}e=e||0;d=d||250;c=c||0;this.revive();this.visible=true;this.on=true;this._explode=b;this.lifespan=e;this.frequency=d;if(b){this._quantity=c}else{this._quantity+=c}this._counter=0;this._timer=this.game.time.now+d};Phaser.Particles.Arcade.Emitter.prototype.emitParticle=function(){var c=this.getFirstExists(false);if(c==null){return}if(this.width>1||this.height>1){c.reset(this.emiteX-this.game.rnd.integerInRange(this.left,this.right),this.emiteY-this.game.rnd.integerInRange(this.top,this.bottom))}else{c.reset(this.emitX,this.emitY)}c.lifespan=this.lifespan;c.body.bounce.setTo(this.bounce.x,this.bounce.y);if(this.minParticleSpeed.x!=this.maxParticleSpeed.x){c.body.velocity.x=this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x)}else{c.body.velocity.x=this.minParticleSpeed.x}if(this.minParticleSpeed.y!=this.maxParticleSpeed.y){c.body.velocity.y=this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y)}else{c.body.velocity.y=this.minParticleSpeed.y}c.body.gravity.y=this.gravity;if(this.minRotation!=this.maxRotation){c.body.angularVelocity=this.game.rnd.integerInRange(this.minRotation,this.maxRotation)}else{c.body.angularVelocity=this.minRotation}if(this.minParticleScale!==1||this.maxParticleScale!==1){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);c.scale.setTo(b,b)}c.body.drag.x=this.particleDrag.x;c.body.drag.y=this.particleDrag.y;c.body.angularDrag=this.angularDrag};Phaser.Particles.Arcade.Emitter.prototype.setSize=function(c,b){this.width=c;this.height=b};Phaser.Particles.Arcade.Emitter.prototype.setXSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.x=c;this.maxParticleSpeed.x=b};Phaser.Particles.Arcade.Emitter.prototype.setYSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.y=c;this.maxParticleSpeed.y=b};Phaser.Particles.Arcade.Emitter.prototype.setRotation=function(c,b){c=c||0;b=b||0;this.minRotation=c;this.maxRotation=b};Phaser.Particles.Arcade.Emitter.prototype.at=function(b){this.emitX=b.center.x;this.emitY=b.center.y};Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(b){this._container.alpha=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(b){this._container.visible=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(b){this.emitX=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(b){this.emitY=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-(this.height/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+(this.height/2))}});Phaser.Tilemap=function(d,e,b,i,g,h,c){if(typeof g==="undefined"){g=true}if(typeof h==="undefined"){h=0}if(typeof c==="undefined"){c=0}this.game=d;this.group=null;this.name="";this.key=e;this.renderOrderID=0;this.collisionCallback=null;this.exists=true;this.visible=true;this.tiles=[];this.layers=[];var f=this.game.cache.getTilemap(e);PIXI.DisplayObjectContainer.call(this);this.position.x=b;this.position.y=i;this.type=Phaser.TILEMAP;this.renderer=new Phaser.TilemapRenderer(this.game);this.mapFormat=f.format;switch(this.mapFormat){case Phaser.Tilemap.CSV:this.parseCSV(f.mapData,e,h,c);break;case Phaser.Tilemap.JSON:this.parseTiledJSON(f.mapData,e);break}if(this.currentLayer&&g){this.game.world.setSize(this.currentLayer.widthInPixels,this.currentLayer.heightInPixels,true)}};Phaser.Tilemap.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);Phaser.Tilemap.prototype.constructor=Phaser.Tilemap;Phaser.Tilemap.CSV=0;Phaser.Tilemap.JSON=1;Phaser.Tilemap.prototype.parseCSV=function(d,j,h,g){var f=new Phaser.TilemapLayer(this,0,j,Phaser.Tilemap.CSV,"TileLayerCSV"+this.layers.length.toString(),h,g);d=d.trim();var k=d.split("\n");for(var e=0;e0){f.addColumn(c)}}f.updateBounds();f.createCanvas();var b=f.parseTileOffsets();this.currentLayer=f;this.collisionLayer=f;this.layers.push(f);this.generateTiles(b)};Phaser.Tilemap.prototype.parseTiledJSON=function(g,f){for(var e=0;e0){this.collisionCallback.call(this.collisionCallbackContext,b,this._tempCollisionData)}return true}else{return false}};Phaser.Tilemap.prototype.putTile=function(b,e,c,d){if(typeof d==="undefined"){d=this.currentLayer.ID}this.layers[d].putTile(b,e,c)};Phaser.Tilemap.prototype.update=function(){this.renderer.render(this)};Phaser.Tilemap.prototype.destroy=function(){this.tiles.length=0;this.layers.length=0};Object.defineProperty(Phaser.Tilemap.prototype,"widthInPixels",{get:function(){return this.currentLayer.widthInPixels}});Object.defineProperty(Phaser.Tilemap.prototype,"heightInPixels",{get:function(){return this.currentLayer.heightInPixels}});Phaser.TilemapLayer=function(f,i,e,d,c,h,b){this.exists=true;this.visible=true;this.widthInTiles=0;this.heightInTiles=0;this.widthInPixels=0;this.heightInPixels=0;this.tileMargin=0;this.tileSpacing=0;this.parent=f;this.game=f.game;this.ID=i;this.name=c;this.key=e;this.type=Phaser.TILEMAPLAYER;this.mapFormat=d;this.tileWidth=h;this.tileHeight=b;this.boundsInTiles=new Phaser.Rectangle();var g=this.game.cache.getTilemap(e);this.tileset=g.data;this._alpha=1;this.canvas=null;this.context=null;this.baseTexture=null;this.texture=null;this.sprite=null;this.mapData=[];this._tempTileBlock=[];this._tempBlockResults=[]};Phaser.TilemapLayer.prototype={putTileWorldXY:function(b,d,c){b=this.game.math.snapToFloor(b,this.tileWidth)/this.tileWidth;d=this.game.math.snapToFloor(d,this.tileHeight)/this.tileHeight;if(d>=0&&d=0&&b=0&&d=0&&bthis.widthInPixels||b.body.y<0||b.body.bottom>this.heightInPixels){return this._tempBlockResults}this._tempTileX=this.game.math.snapToFloor(b.body.x,this.tileWidth)/this.tileWidth;this._tempTileY=this.game.math.snapToFloor(b.body.y,this.tileHeight)/this.tileHeight;this._tempTileW=(this.game.math.snapToCeil(b.body.width,this.tileWidth)+this.tileWidth)/this.tileWidth;this._tempTileH=(this.game.math.snapToCeil(b.body.height,this.tileHeight)+this.tileHeight)/this.tileHeight;this.getTempBlock(this._tempTileX,this._tempTileY,this._tempTileW,this._tempTileH,true);for(var c=0;cthis.widthInTiles){g=this.widthInTiles}if(c>this.heightInTiles){c=this.heightInTiles}this._tempTileBlock=[];for(var b=h;b=0&&c=0&&bb.widthInTiles){this._maxX=b.widthInTiles}if(this._maxY>b.heightInTiles){this._maxY=b.heightInTiles}if(this._startX+this._maxX>b.widthInTiles){this._startX=b.widthInTiles-this._maxX}if(this._startY+this._maxY>b.heightInTiles){this._startY=b.heightInTiles-this._maxY}this._dx=-(this.game.camera.x-(this._startX*b.tileWidth));this._dy=-(this.game.camera.y-(this._startY*b.tileHeight));this._tx=this._dx;this._ty=this._dy;if(b.alpha!==1){this._ga=b.context.globalAlpha;b.context.globalAlpha=b.alpha}b.context.clearRect(0,0,b.canvas.width,b.canvas.height);for(var f=this._startY;f-1){b.context.globalAlpha=this._ga}if(this.game.renderType==Phaser.WEBGL){PIXI.texturesToUpdate.push(b.baseTexture)}}return true}}; \ No newline at end of file +/*! Phaser v1.1.0 | (c) 2013 Photon Storm Ltd. */ +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.Phaser=b()}(this,function(){function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}function c(){return d.Matrix="undefined"!=typeof Float32Array?Float32Array:Array,d.Matrix}function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}var d=d||{},e=e||{VERSION:"1.1.0",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,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4};return d.InteractionManager=function(){},e.Utils={shuffle:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},pad:function(a,b,c,d){if("undefined"==typeof b)var b=0;if("undefined"==typeof c)var c=" ";if("undefined"==typeof d)var d=3;if(b+1>=a.length)switch(d){case 1:a=Array(b+1-a.length).join(c)+a;break;case 3:var e=Math.ceil((padlen=b-a.length)/2),f=padlen-e;a=Array(f+1).join(c)+a+Array(e+1).join(c);break;default:a+=Array(b+1-a.length).join(c)}return a},isPlainObject:function(a){if("object"!=typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!hasOwn.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},extend:function(){var a,b,c,d,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),j===i&&(h=this,--i);j>i;i++)if(null!=(a=arguments[i]))for(b in a)c=h[b],d=a[b],h!==d&&(k&&d&&(e.Utils.isPlainObject(d)||(f=Array.isArray(d)))?(f?(f=!1,g=c&&Array.isArray(c)?c:[]):g=c&&e.Utils.isPlainObject(c)?c:{},h[b]=e.Utils.extend(k,g,d)):void 0!==d&&(h[b]=d));return h}},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){var a=Array.prototype.slice;return function(b){function c(){var f=e.concat(a.call(arguments));d.apply(this instanceof c?this:b,f)}var d=this,e=a.call(arguments,1);if("function"!=typeof d)throw new TypeError;return c.prototype=function f(a){return a&&(f.prototype=a),this instanceof f?void 0:new f}(d.prototype),c}}()),c(),d.mat3={},d.mat3.create=function(){var a=new d.Matrix(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat3.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat4={},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat3.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5],s=b[6],t=b[7],u=b[8];return c[0]=m*d+n*g+o*j,c[1]=m*e+n*h+o*k,c[2]=m*f+n*i+o*l,c[3]=p*d+q*g+r*j,c[4]=p*e+q*h+r*k,c[5]=p*f+q*i+r*l,c[6]=s*d+t*g+u*j,c[7]=s*e+t*h+u*k,c[8]=s*f+t*i+u*l,c},d.mat3.clone=function(a){var b=new d.Matrix(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},d.mat3.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];return a[1]=a[3],a[2]=a[6],a[3]=c,a[5]=a[7],a[6]=d,a[7]=e,a}return b[0]=a[0],b[1]=a[3],b[2]=a[6],b[3]=a[1],b[4]=a[4],b[5]=a[7],b[6]=a[2],b[7]=a[5],b[8]=a[8],b},d.mat3.toMat4=function(a,b){return b||(b=d.mat4.create()),b[15]=1,b[14]=0,b[13]=0,b[12]=0,b[11]=0,b[10]=a[8],b[9]=a[7],b[8]=a[6],b[7]=0,b[6]=a[5],b[5]=a[4],b[4]=a[3],b[3]=0,b[2]=a[2],b[1]=a[1],b[0]=a[0],b},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat4.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],f=a[6],g=a[7],h=a[11];return a[1]=a[4],a[2]=a[8],a[3]=a[12],a[4]=c,a[6]=a[9],a[7]=a[13],a[8]=d,a[9]=f,a[11]=a[14],a[12]=e,a[13]=g,a[14]=h,a}return b[0]=a[0],b[1]=a[4],b[2]=a[8],b[3]=a[12],b[4]=a[1],b[5]=a[5],b[6]=a[9],b[7]=a[13],b[8]=a[2],b[9]=a[6],b[10]=a[10],b[11]=a[14],b[12]=a[3],b[13]=a[7],b[14]=a[11],b[15]=a[15],b},d.mat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15],t=b[0],u=b[1],v=b[2],w=b[3];return c[0]=t*d+u*h+v*l+w*p,c[1]=t*e+u*i+v*m+w*q,c[2]=t*f+u*j+v*n+w*r,c[3]=t*g+u*k+v*o+w*s,t=b[4],u=b[5],v=b[6],w=b[7],c[4]=t*d+u*h+v*l+w*p,c[5]=t*e+u*i+v*m+w*q,c[6]=t*f+u*j+v*n+w*r,c[7]=t*g+u*k+v*o+w*s,t=b[8],u=b[9],v=b[10],w=b[11],c[8]=t*d+u*h+v*l+w*p,c[9]=t*e+u*i+v*m+w*q,c[10]=t*f+u*j+v*n+w*r,c[11]=t*g+u*k+v*o+w*s,t=b[12],u=b[13],v=b[14],w=b[15],c[12]=t*d+u*h+v*l+w*p,c[13]=t*e+u*i+v*m+w*q,c[14]=t*f+u*j+v*n+w*r,c[15]=t*g+u*k+v*o+w*s,c},d.Point=function(a,b){this.x=a||0,this.y=b||0},d.Point.prototype.clone=function(){return new d.Point(this.x,this.y)},d.Point.prototype.constructor=d.Point,d.Rectangle=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},d.Rectangle.prototype.clone=function(){return new d.Rectangle(this.x,this.y,this.width,this.height)},d.Rectangle.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1},d.Rectangle.prototype.constructor=d.Rectangle,d.DisplayObject=function(){this.last=this,this.first=this,this.position=new d.Point,this.scale=new d.Point(1,1),this.pivot=new d.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.worldTransform=d.mat3.create(),this.localTransform=d.mat3.create(),this.color=[],this.dynamic=!0,this._sr=0,this._cr=1},d.DisplayObject.prototype.constructor=d.DisplayObject,d.DisplayObject.prototype.setInteractive=function(a){this.interactive=a},Object.defineProperty(d.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(a){this._interactive=a,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(d.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(a){this._mask=a,a?this.addFilter(a):this.removeFilter()}}),d.DisplayObject.prototype.addFilter=function(a){if(!this.filter){this.filter=!0;var b=new d.FilterBlock,c=new d.FilterBlock;b.mask=a,c.mask=a,b.first=b.last=this,c.first=c.last=this,b.open=!0;var e,f,g=b,h=b;f=this.first._iPrev,f?(e=f._iNext,g._iPrev=f,f._iNext=g):e=this,e&&(e._iPrev=h,h._iNext=e);var g=c,h=c,e=null,f=null;f=this.last,e=f._iNext,e&&(e._iPrev=h,h._iNext=e),g._iPrev=f,f._iNext=g;for(var i=this,j=this.last;i;)i.last==j&&(i.last=c),i=i.parent;this.first=b,this.__renderGroup&&this.__renderGroup.addFilterBlocks(b,c),a.renderable=!1}},d.DisplayObject.prototype.removeFilter=function(){if(this.filter){this.filter=!1;var a=this.first,b=a._iNext,c=a._iPrev;b&&(b._iPrev=c),c&&(c._iNext=b),this.first=a._iNext;var d=this.last,b=d._iNext,c=d._iPrev;b&&(b._iPrev=c),c._iNext=b;for(var e=d._iPrev,f=this;f.last==d&&(f.last=e,f=f.parent););var g=a.mask;g.renderable=!0,this.__renderGroup&&this.__renderGroup.removeFilterBlocks(a,d)}},d.DisplayObject.prototype.updateTransform=function(){this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation));var a=this.localTransform,b=this.parent.worldTransform,c=this.worldTransform;a[0]=this._cr*this.scale.x,a[1]=-this._sr*this.scale.y,a[3]=this._sr*this.scale.x,a[4]=this._cr*this.scale.y;var e=this.pivot.x,f=this.pivot.y,g=a[0],h=a[1],i=this.position.x-a[0]*e-f*a[1],j=a[3],k=a[4],l=this.position.y-a[4]*f-e*a[3],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5];a[2]=i,a[5]=l,c[0]=m*g+n*j,c[1]=m*h+n*k,c[2]=m*i+n*l+o,c[3]=p*g+q*j,c[4]=p*h+q*k,c[5]=p*i+q*l+r,this.worldAlpha=this.alpha*this.parent.worldAlpha,this.vcount=d.visibleCount},d.visibleCount=0,d.DisplayObjectContainer=function(){d.DisplayObject.call(this),this.children=[]},d.DisplayObjectContainer.prototype=Object.create(d.DisplayObject.prototype),d.DisplayObjectContainer.prototype.constructor=d.DisplayObjectContainer,d.DisplayObjectContainer.prototype.addChild=function(a){if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.children.push(a),this.stage){var b=a;do b.interactive&&(this.stage.dirty=!0),b.stage=this.stage,b=b._iNext;while(b)}var c,d,e=a.first,f=a.last;d=this.filter?this.last._iPrev:this.last,c=d._iNext;for(var g=this,h=d;g;)g.last==h&&(g.last=a.last),g=g.parent;c&&(c._iPrev=f,f._iNext=c),e._iPrev=d,d._iNext=e,this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.addChildAt=function(a,b){if(!(b>=0&&b<=this.children.length))throw new Error(a+" The index "+b+" supplied is out of bounds "+this.children.length);if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.stage){var c=a;do c.interactive&&(this.stage.dirty=!0),c.stage=this.stage,c=c._iNext;while(c)}var d,e,f=a.first,g=a.last;if(b==this.children.length){e=this.last;for(var h=this,i=this.last;h;)h.last==i&&(h.last=a.last),h=h.parent}else e=0==b?this:this.children[b-1].last;d=e._iNext,d&&(d._iPrev=g,g._iNext=d),f._iPrev=e,e._iNext=f,this.children.splice(b,0,a),this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.swapChildren=function(){},d.DisplayObjectContainer.prototype.getChildAt=function(a){if(a>=0&&aa;a++)this.children[a].updateTransform()}},d.blendModes={},d.blendModes.NORMAL=0,d.blendModes.SCREEN=1,d.Sprite=function(a){d.DisplayObjectContainer.call(this),this.anchor=new d.Point,this.texture=a,this.blendMode=d.blendModes.NORMAL,this._width=0,this._height=0,a.baseTexture.hasLoaded?this.updateFrame=!0:(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Sprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Sprite.prototype.constructor=d.Sprite,Object.defineProperty(d.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(d.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),d.Sprite.prototype.setTexture=function(a){this.texture.baseTexture!=a.baseTexture?(this.textureChange=!0,this.texture=a,this.__renderGroup&&this.__renderGroup.updateTexture(this)):this.texture=a,this.updateFrame=!0},d.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height),this.updateFrame=!0},d.Sprite.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache"+this);return new d.Sprite(b)},d.Sprite.fromImage=function(a){var b=d.Texture.fromImage(a);return new d.Sprite(b)},d.Stage=function(a,b){d.DisplayObjectContainer.call(this),this.worldTransform=d.mat3.create(),this.interactive=b,this.interactionManager=new d.InteractionManager(this),this.dirty=!0,this.__childrenAdded=[],this.__childrenRemoved=[],this.stage=this,this.stage.hitArea=new d.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(a),this.worldVisible=!0},d.Stage.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Stage.prototype.constructor=d.Stage,d.Stage.prototype.updateTransform=function(){this.worldAlpha=1,this.vcount=d.visibleCount;for(var a=0,b=this.children.length;b>a;a++)this.children[a].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},d.Stage.prototype.setBackgroundColor=function(a){this.backgroundColor=a||0,this.backgroundColorSplit=b(this.backgroundColor);var c=this.backgroundColor.toString(16);c="000000".substr(0,6-c.length)+c,this.backgroundColorString="#"+c},d.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},d.CustomRenderable=function(){d.DisplayObject.call(this)},d.CustomRenderable.prototype=Object.create(d.DisplayObject.prototype),d.CustomRenderable.prototype.constructor=d.CustomRenderable,d.CustomRenderable.prototype.renderCanvas=function(){},d.CustomRenderable.prototype.initWebGL=function(){},d.CustomRenderable.prototype.renderWebGL=function(){},d.Strip=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.blendMode=d.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(e){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=b,this.height=c,a.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Strip.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Strip.prototype.constructor=d.Strip,d.Strip.prototype.setTexture=function(a){this.texture=a,this.width=a.frame.width,this.height=a.frame.height,this.updateFrame=!0},d.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.Rope=function(a,b){d.Strip.call(this,a),this.points=b;try{this.verticies=new Float32Array(4*b.length),this.uvs=new Float32Array(4*b.length),this.colors=new Float32Array(2*b.length),this.indices=new Uint16Array(2*b.length)}catch(c){this.verticies=verticies,this.uvs=uvs,this.colors=colors,this.indices=indices}this.refresh()},d.Rope.prototype=Object.create(d.Strip.prototype),d.Rope.prototype.constructor=d.Rope,d.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=this.indices,d=this.colors,e=a[0],f=a[0];this.count-=.2,b[0]=0,b[1]=1,b[2]=0,b[3]=1,d[0]=1,d[1]=1,c[0]=0,c[1]=1;for(var g=a.length,h=1;g>h;h++){var f=a[h],i=4*h,j=h/(g-1);h%2?(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1):(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1),i=2*h,d[i]=1,d[i+1]=1,i=2*h,c[i]=i,c[i+1]=i+1,e=f}}},d.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,c=this.verticies,e=a[0],f={x:0,y:0},g=a[0];this.count-=.2,c[0]=g.x+f.x,c[1]=g.y+f.y,c[2]=g.x-f.x,c[3]=g.y-f.y;for(var h=a.length,i=1;h>i;i++){var g=a[i],j=4*i;b=i1&&(k=1);var l=Math.sqrt(f.x*f.x+f.y*f.y),m=this.texture.height/2;f.x/=l,f.y/=l,f.x*=m,f.y*=m,c[j]=g.x+f.x,c[j+1]=g.y+f.y,c[j+2]=g.x-f.x,c[j+3]=g.y-f.y,e=g}d.DisplayObjectContainer.prototype.updateTransform.call(this)}},d.Rope.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.width=b,this.height=c,this.tileScale=new d.Point(1,1),this.tilePosition=new d.Point(0,0),this.renderable=!0,this.blendMode=d.blendModes.NORMAL},d.TilingSprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.TilingSprite.prototype.constructor=d.TilingSprite,d.TilingSprite.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.FilterBlock=function(a){this.graphics=a,this.visible=!0,this.renderable=!0},d.MaskFilter=function(){this.graphics},d.Graphics=function(){d.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor="black",this.graphicsData=[],this.currentPath={points:[]}},d.Graphics.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Graphics.prototype.constructor=d.Graphics,d.Graphics.prototype.lineStyle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.lineWidth=a||0,this.lineColor=b||0,this.lineAlpha=void 0==c?1:c,this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:d.Graphics.POLY},this.graphicsData.push(this.currentPath)},d.Graphics.prototype.moveTo=function(a,b){0==this.currentPath.points.length&&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:d.Graphics.POLY},this.currentPath.points.push(a,b),this.graphicsData.push(this.currentPath)},d.Graphics.prototype.lineTo=function(a,b){this.currentPath.points.push(a,b),this.dirty=!0},d.Graphics.prototype.beginFill=function(a,b){this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0==b?1:b},d.Graphics.prototype.endFill=function(){this.filling=!1,this.fillColor=null,this.fillAlpha=1},d.Graphics.prototype.drawRect=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.RECT},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawCircle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,c],type:d.Graphics.CIRC},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawElipse=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.ELIP},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.clear=function(){this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[]},d.Graphics.POLY=0,d.Graphics.RECT=1,d.Graphics.CIRC=2,d.Graphics.ELIP=3,d.CanvasGraphics=function(){},d.CanvasGraphics.renderGraphics=function(a,b){for(var c=a.worldAlpha,e=0;e1&&(c=1,console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var e=0;1>e;e++){var f=a.graphicsData[e],g=f.points;if(f.type==d.Graphics.POLY){b.beginPath(),b.moveTo(g[0],g[1]);for(var h=1;h0&&(d.Texture.frameUpdates=[])},d.CanvasRenderer.prototype.resize=function(a,b){this.width=a,this.height=b,this.view.width=a,this.view.height=b},d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,c=this.context;c.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable){if(a instanceof d.Sprite){var f=a.texture.frame;f&&(c.globalAlpha=a.worldAlpha,c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.drawImage(a.texture.baseTexture.source,f.x,f.y,f.width,f.height,a.anchor.x*-f.width,a.anchor.y*-f.height,f.width,f.height))}else if(a instanceof d.Strip)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)a.renderCanvas(this);else if(a instanceof d.Graphics)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.CanvasGraphics.renderGraphics(a,c);else if(a instanceof d.FilterBlock)if(a.open){c.save();var g=a.mask.alpha,h=a.mask.worldTransform;c.setTransform(h[0],h[3],h[1],h[4],h[2],h[5]),a.mask.worldAlpha=.5,c.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(a.mask,c),c.clip(),a.mask.worldAlpha=g}else c.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},d.CanvasRenderer.prototype.renderStripFlat=function(a){var b=this.context,c=a.verticies;a.uvs;var d=c.length/2;this.count++,b.beginPath();for(var e=1;d-2>e;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},d.CanvasRenderer.prototype.renderTilingSprite=function(a){var b=this.context;b.globalAlpha=a.worldAlpha,a.__tilePattern||(a.__tilePattern=b.createPattern(a.texture.baseTexture.source,"repeat")),b.beginPath();var c=a.tilePosition,d=a.tileScale;b.scale(d.x,d.y),b.translate(c.x,c.y),b.fillStyle=a.__tilePattern,b.fillRect(-c.x,-c.y,a.width/d.x,a.height/d.y),b.scale(1/d.x,1/d.y),b.translate(-c.x,-c.y),b.closePath()},d.CanvasRenderer.prototype.renderStrip=function(a){var b=this.context,c=a.verticies,d=a.uvs,e=c.length/2;this.count++;for(var f=1;e-2>f;f++){var g=2*f,h=c[g],i=c[g+2],j=c[g+4],k=c[g+1],l=c[g+3],m=c[g+5],n=d[g]*a.texture.width,o=d[g+2]*a.texture.width,p=d[g+4]*a.texture.width,q=d[g+1]*a.texture.height,r=d[g+3]*a.texture.height,s=d[g+5]*a.texture.height;b.save(),b.beginPath(),b.moveTo(h,k),b.lineTo(i,l),b.lineTo(j,m),b.closePath(),b.clip();var t=n*r+q*p+o*s-r*p-q*o-n*s,u=h*r+q*j+i*s-r*j-q*i-h*s,v=n*i+h*p+o*j-i*p-h*o-n*j,w=n*r*j+q*i*p+h*o*s-h*r*p-q*o*j-n*i*s,x=k*r+q*m+l*s-r*m-q*l-k*s,y=n*l+k*p+o*m-l*p-k*o-n*m,z=n*r*m+q*l*p+k*o*s-k*r*p-q*o*m-n*l*s;b.transform(u/t,x/t,v/t,y/t,w/t,z/t),b.drawImage(a.texture.baseTexture.source,0,0),b.restore()}},d._batchs=[],d._getBatch=function(a){return 0==d._batchs.length?new d.WebGLBatch(a):d._batchs.pop()},d._returnBatch=function(a){a.clean(),d._batchs.push(a)},d._restoreBatchs=function(a){for(var b=0;bc;c++){var d=6*c,e=4*c;this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+3}a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW)},d.WebGLBatch.prototype.refresh=function(){this.gl,this.dynamicSize3&&d.WebGLGraphics.buildPoly(c,a._webGL),c.lineWidth>0&&d.WebGLGraphics.buildLine(c,a._webGL)):c.type==d.Graphics.RECT?d.WebGLGraphics.buildRectangle(c,a._webGL):(c.type==d.Graphics.CIRC||c.type==d.Graphics.ELIP)&&d.WebGLGraphics.buildCircle(c,a._webGL)}a._webGL.lastIndex=a.graphicsData.length;var e=d.gl;a._webGL.glPoints=new Float32Array(a._webGL.points),e.bindBuffer(e.ARRAY_BUFFER,a._webGL.buffer),e.bufferData(e.ARRAY_BUFFER,a._webGL.glPoints,e.STATIC_DRAW),a._webGL.glIndicies=new Uint16Array(a._webGL.indices),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a._webGL.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,a._webGL.glIndicies,e.STATIC_DRAW)},d.WebGLGraphics.buildRectangle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3];if(a.fill){var j=b(a.fillColor),k=a.fillAlpha,l=j[0]*k,m=j[1]*k,n=j[2]*k,o=c.points,p=c.indices,q=o.length/6;o.push(f,g),o.push(l,m,n,k),o.push(f+h,g),o.push(l,m,n,k),o.push(f,g+i),o.push(l,m,n,k),o.push(f+h,g+i),o.push(l,m,n,k),p.push(q,q,q+1,q+2,q+3,q+3)}a.lineWidth&&(a.points=[f,g,f+h,g,f+h,g+i,f,g+i,f,g],d.WebGLGraphics.buildLine(a,c))},d.WebGLGraphics.buildCircle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3],j=40,k=2*Math.PI/j;if(a.fill){var l=b(a.fillColor),m=a.fillAlpha,n=l[0]*m,o=l[1]*m,p=l[2]*m,q=c.points,r=c.indices,s=q.length/6;r.push(s);for(var t=0;j+1>t;t++)q.push(f,g,n,o,p,m),q.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i,n,o,p,m),r.push(s++,s++);r.push(s-1)}if(a.lineWidth){a.points=[];for(var t=0;j+1>t;t++)a.points.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i);d.WebGLGraphics.buildLine(a,c)}},d.WebGLGraphics.buildLine=function(a,c){var e=a.points;if(0!=e.length){var f=new d.Point(e[0],e[1]),g=new d.Point(e[e.length-2],e[e.length-1]);if(f.x==g.x&&f.y==g.y){e.pop(),e.pop(),g=new d.Point(e[e.length-2],e[e.length-1]);var h=g.x+.5*(f.x-g.x),i=g.y+.5*(f.y-g.y);e.unshift(h,i),e.push(h,i)}var j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E=c.points,F=c.indices,G=e.length/2,H=e.length,I=E.length/6,J=a.lineWidth/2,K=b(a.lineColor),L=a.lineAlpha,M=K[0]*L,N=K[1]*L,O=K[2]*L;j=e[0],k=e[1],l=e[2],m=e[3],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,E.push(j-p,k-q,M,N,O,L),E.push(j+p,k+q,M,N,O,L);for(var P=1;G-1>P;P++)j=e[2*(P-1)],k=e[2*(P-1)+1],l=e[2*P],m=e[2*P+1],n=e[2*(P+1)],o=e[2*(P+1)+1],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,r=-(m-o),s=l-n,D=Math.sqrt(r*r+s*s),r/=D,s/=D,r*=J,s*=J,v=-q+k-(-q+m),w=-p+l-(-p+j),x=(-p+j)*(-q+m)-(-p+l)*(-q+k),y=-s+o-(-s+m),z=-r+l-(-r+n),A=(-r+n)*(-s+m)-(-r+l)*(-s+o),B=v*z-y*w,0==B&&(B+=1),px=(w*A-z*x)/B,py=(y*x-v*A)/B,C=(px-l)*(px-l)+(py-m)+(py-m),C>19600?(t=p-r,u=q-s,D=Math.sqrt(t*t+u*u),t/=D,u/=D,t*=J,u*=J,E.push(l-t,m-u),E.push(M,N,O,L),E.push(l+t,m+u),E.push(M,N,O,L),E.push(l-t,m-u),E.push(M,N,O,L),H++):(E.push(px,py),E.push(M,N,O,L),E.push(l-(px-l),m-(py-m)),E.push(M,N,O,L));j=e[2*(G-2)],k=e[2*(G-2)+1],l=e[2*(G-1)],m=e[2*(G-1)+1],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,E.push(l-p,m-q),E.push(M,N,O,L),E.push(l+p,m+q),E.push(M,N,O,L),F.push(I);for(var P=0;H>P;P++)F.push(I++);F.push(I-1)}},d.WebGLGraphics.buildPoly=function(a,c){var e=a.points;if(!(e.length<6)){for(var f=c.points,g=c.indices,h=e.length/2,i=b(a.fillColor),j=a.fillAlpha,k=i[0]*j,l=i[1]*j,m=i[2]*j,n=d.PolyK.Triangulate(e),o=f.length/6,p=0;pp;p++)f.push(e[2*p],e[2*p+1],k,l,m,j)}},d._defaultFrame=new d.Rectangle(0,0,1,1),d.gl,d.WebGLRenderer=function(a,b,c,e,f){this.transparent=!!e,this.width=a||800,this.height=b||600,this.view=c||document.createElement("canvas"),this.view.width=this.width,this.view.height=this.height;var g=this;this.view.addEventListener("webglcontextlost",function(a){g.handleContextLost(a)},!1),this.view.addEventListener("webglcontextrestored",function(a){g.handleContextRestored(a)},!1),this.batchs=[];try{d.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!f,premultipliedAlpha:!1,stencil:!0})}catch(h){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}d.initPrimitiveShader(),d.initDefaultShader(),d.initDefaultStripShader(),d.activateDefaultShader();var i=this.gl;d.WebGLRenderer.gl=i,this.batch=new d.WebGLBatch(i),i.disable(i.DEPTH_TEST),i.disable(i.CULL_FACE),i.enable(i.BLEND),i.colorMask(!0,!0,!0,this.transparent),d.projection=new d.Point(400,300),this.resize(this.width,this.height),this.contextLost=!1,this.stageRenderGroup=new d.WebGLRenderGroup(this.gl)},d.WebGLRenderer.prototype.constructor=d.WebGLRenderer,d.WebGLRenderer.getBatch=function(){return 0==d._batchs.length?new d.WebGLBatch(d.WebGLRenderer.gl):d._batchs.pop()},d.WebGLRenderer.returnBatch=function(a){a.clean(),d._batchs.push(a)},d.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(this.__stage=a,this.stageRenderGroup.setRenderable(a)),d.WebGLRenderer.updateTextures(),d.visibleCount++,a.updateTransform();var b=this.gl;if(b.colorMask(!0,!0,!0,this.transparent),b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],!this.transparent),b.clear(b.COLOR_BUFFER_BIT),this.stageRenderGroup.backgroundColor=a.backgroundColorSplit,this.stageRenderGroup.render(d.projection),a.interactive&&(a._interactiveEventsAdded||(a._interactiveEventsAdded=!0,a.interactionManager.setTarget(this))),d.Texture.frameUpdates.length>0){for(var c=0;c0;)n=n.children[n.children.length-1],n.renderable&&(m=n);if(m instanceof d.Sprite){l=m.batch;var k=l.head;if(k==m)g=0;else for(g=1;k.__next!=m;)g++,k=k.__next}else l=m;if(j==l)return j instanceof d.WebGLBatch?j.render(e,g+1):this.renderSpecial(j,b),void 0;f=this.batchs.indexOf(j),h=this.batchs.indexOf(l),j instanceof d.WebGLBatch?j.render(e):this.renderSpecial(j,b);for(var o=f+1;h>o;o++)renderable=this.batchs[o],renderable instanceof d.WebGLBatch?this.batchs[o].render():this.renderSpecial(renderable,b);l instanceof d.WebGLBatch?l.render(0,g+1):this.renderSpecial(l,b)},d.WebGLRenderGroup.prototype.renderSpecial=function(a,b){var c=a.vcount===d.visibleCount;if(a instanceof d.TilingSprite)c&&this.renderTilingSprite(a,b);else if(a instanceof d.Strip)c&&this.renderStrip(a,b);else if(a instanceof d.CustomRenderable)c&&a.renderWebGL(this,b);else if(a instanceof d.Graphics)c&&a.renderable&&d.WebGLGraphics.renderGraphics(a,b);else if(a instanceof d.FilterBlock){var e=d.gl;a.open?(e.enable(e.STENCIL_TEST),e.colorMask(!1,!1,!1,!1),e.stencilFunc(e.ALWAYS,1,255),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),d.WebGLGraphics.renderGraphics(a.mask,b),e.colorMask(!0,!0,!0,!0),e.stencilFunc(e.NOTEQUAL,0,255),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)):e.disable(e.STENCIL_TEST)}},d.WebGLRenderGroup.prototype.updateTexture=function(a){this.removeObject(a);for(var b=a.first;b!=this.root&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););this.insertObject(a,b,c)},d.WebGLRenderGroup.prototype.addFilterBlocks=function(a,b){a.__renderGroup=this,b.__renderGroup=this;for(var c=a;c!=this.root&&(c=c._iPrev,!c.renderable||!c.__renderGroup););this.insertAfter(a,c);for(var d=b;d!=this.root&&(d=d._iPrev,!d.renderable||!d.__renderGroup););this.insertAfter(b,d)},d.WebGLRenderGroup.prototype.removeFilterBlocks=function(a,b){this.removeObject(a),this.removeObject(b)},d.WebGLRenderGroup.prototype.addDisplayObjectAndChildren=function(a){a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a);for(var b=a.first;b!=this.root.first&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););var d=a.first,e=a.last._iNext;do d.__renderGroup=this,d.renderable&&(this.insertObject(d,b,c),b=d),d=d._iNext;while(d!=e)},d.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren=function(a){if(a.__renderGroup==this){a.last;do a.__renderGroup=null,a.renderable&&this.removeObject(a),a=a._iNext;while(a)}},d.WebGLRenderGroup.prototype.insertObject=function(a,b,c){var e=b,f=c;if(a instanceof d.Sprite){var g,h;if(e instanceof d.Sprite){if(g=e.batch,g&&g.texture==a.texture.baseTexture&&g.blendMode==a.blendMode)return g.insertAfter(a,e),void 0}else g=e;if(f)if(f instanceof d.Sprite){if(h=f.batch){if(h.texture==a.texture.baseTexture&&h.blendMode==a.blendMode)return h.insertBefore(a,f),void 0;if(h==g){var i=g.split(f),j=d.WebGLRenderer.getBatch(),k=this.batchs.indexOf(g);return j.init(a),this.batchs.splice(k+1,0,j,i),void 0}}}else h=f;var j=d.WebGLRenderer.getBatch();if(j.init(a),g){var k=this.batchs.indexOf(g);this.batchs.splice(k+1,0,j)}else this.batchs.push(j)}else a instanceof d.TilingSprite?this.initTilingSprite(a):a instanceof d.Strip&&this.initStrip(a),this.insertAfter(a,e)},d.WebGLRenderGroup.prototype.insertAfter=function(a,b){if(b instanceof d.Sprite){var c=b.batch;if(c)if(c.tail==b){var e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a)}else{var f=c.split(b.__next),e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a,f)}else this.batchs.push(a)}else{var e=this.batchs.indexOf(b);this.batchs.splice(e+1,0,a)}},d.WebGLRenderGroup.prototype.removeObject=function(a){var b;if(a instanceof d.Sprite){var c=a.batch;if(!c)return;c.remove(a),0==c.size&&(b=c)}else b=a;if(b){var e=this.batchs.indexOf(b);if(-1==e)return;if(0==e||e==this.batchs.length-1)return this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),void 0;if(this.batchs[e-1]instanceof d.WebGLBatch&&this.batchs[e+1]instanceof d.WebGLBatch&&this.batchs[e-1].texture==this.batchs[e+1].texture&&this.batchs[e-1].blendMode==this.batchs[e+1].blendMode)return this.batchs[e-1].merge(this.batchs[e+1]),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),d.WebGLRenderer.returnBatch(this.batchs[e+1]),this.batchs.splice(e,2),void 0;this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b)}},d.WebGLRenderGroup.prototype.initTilingSprite=function(a){var b=this.gl;a.verticies=new Float32Array([0,0,a.width,0,a.width,a.height,0,a.height]),a.uvs=new Float32Array([0,0,1,0,1,1,0,1]),a.colors=new Float32Array([1,1,1,1]),a.indices=new Uint16Array([0,1,3,2]),a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW),a.texture.baseTexture._glTexture?(b.bindTexture(b.TEXTURE_2D,a.texture.baseTexture._glTexture),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.REPEAT),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.REPEAT),a.texture.baseTexture._powerOf2=!0):a.texture.baseTexture._powerOf2=!0},d.WebGLRenderGroup.prototype.renderStrip=function(a,b){var c=this.gl,e=d.shaderProgram;c.useProgram(d.stripShaderProgram);var f=d.mat3.clone(a.worldTransform);d.mat3.transpose(f),c.uniformMatrix3fv(d.stripShaderProgram.translationMatrix,!1,f),c.uniform2f(d.stripShaderProgram.projectionVector,b.x,b.y),c.uniform1f(d.stripShaderProgram.alpha,a.worldAlpha),a.dirty?(a.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,a.verticies,c.STATIC_DRAW),c.vertexAttribPointer(e.vertexPositionAttribute,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferData(c.ARRAY_BUFFER,a.uvs,c.STATIC_DRAW),c.vertexAttribPointer(e.textureCoordAttribute,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.bufferData(c.ARRAY_BUFFER,a.colors,c.STATIC_DRAW),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,a.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.verticies),c.vertexAttribPointer(e.vertexPositionAttribute,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.vertexAttribPointer(e.textureCoordAttribute,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer)),c.drawElements(c.TRIANGLE_STRIP,a.indices.length,c.UNSIGNED_SHORT,0),c.useProgram(d.shaderProgram)},d.WebGLRenderGroup.prototype.renderTilingSprite=function(a,b){var c=this.gl;d.shaderProgram;var e=a.tilePosition,f=a.tileScale,g=e.x/a.texture.baseTexture.width,h=e.y/a.texture.baseTexture.height,i=a.width/a.texture.baseTexture.width/f.x,j=a.height/a.texture.baseTexture.height/f.y;a.uvs[0]=0-g,a.uvs[1]=0-h,a.uvs[2]=1*i-g,a.uvs[3]=0-h,a.uvs[4]=1*i-g,a.uvs[5]=1*j-h,a.uvs[6]=0-g,a.uvs[7]=1*j-h,c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.uvs),this.renderStrip(a,b)},d.WebGLRenderGroup.prototype.initStrip=function(a){var b=this.gl;this.shaderProgram,a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW)},d.shaderFragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor = gl_FragColor * vColor;","}"],d.shaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","gl_Position = vec4( aVertexPosition.x / projectionVector.x -1.0, aVertexPosition.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.stripShaderFragmentSrc=["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;","}"],d.stripShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.primitiveShaderFragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","gl_FragColor = vColor;","}"],d.primitiveShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform float alpha;","varying vec4 vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vColor = aColor * alpha;","}"],d.initPrimitiveShader=function(){var a=d.gl,b=d.compileProgram(d.primitiveShaderVertexSrc,d.primitiveShaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.translationMatrix=a.getUniformLocation(b,"translationMatrix"),b.alpha=a.getUniformLocation(b,"alpha"),d.primitiveProgram=b},d.initDefaultShader=function(){var a=this.gl,b=d.compileProgram(d.shaderVertexSrc,d.shaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.textureCoordAttribute=a.getAttribLocation(b,"aTextureCoord"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.samplerUniform=a.getUniformLocation(b,"uSampler"),d.shaderProgram=b},d.initDefaultStripShader=function(){var a=this.gl,b=d.compileProgram(d.stripShaderVertexSrc,d.stripShaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.textureCoordAttribute=a.getAttribLocation(b,"aTextureCoord"),b.translationMatrix=a.getUniformLocation(b,"translationMatrix"),b.alpha=a.getUniformLocation(b,"alpha"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.samplerUniform=a.getUniformLocation(b,"uSampler"),d.stripShaderProgram=b},d.CompileVertexShader=function(a,b){return d._CompileShader(a,b,a.VERTEX_SHADER)},d.CompileFragmentShader=function(a,b){return d._CompileShader(a,b,a.FRAGMENT_SHADER)},d._CompileShader=function(a,b,c){var d=b.join("\n"),e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:(alert(a.getShaderInfoLog(e)),null)},d.compileProgram=function(a,b){var c=d.gl,e=d.CompileFragmentShader(c,b),f=d.CompileVertexShader(c,a),g=c.createProgram();return c.attachShader(g,f),c.attachShader(g,e),c.linkProgram(g),c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders"),g},d.activateDefaultShader=function(){var a=d.gl,b=d.shaderProgram;a.useProgram(b),a.enableVertexAttribArray(b.vertexPositionAttribute),a.enableVertexAttribArray(b.textureCoordAttribute),a.enableVertexAttribArray(b.colorAttribute)},d.activatePrimitiveShader=function(){var a=d.gl;a.disableVertexAttribArray(d.shaderProgram.textureCoordAttribute),a.disableVertexAttribArray(d.shaderProgram.colorAttribute),a.useProgram(d.primitiveProgram),a.enableVertexAttribArray(d.primitiveProgram.vertexPositionAttribute),a.enableVertexAttribArray(d.primitiveProgram.colorAttribute)},d.BitmapText=function(a,b){d.DisplayObjectContainer.call(this),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.BitmapText.prototype=Object.create(d.DisplayObjectContainer.prototype),d.BitmapText.prototype.constructor=d.BitmapText,d.BitmapText.prototype.setText=function(a){this.text=a||" ",this.dirty=!0},d.BitmapText.prototype.setStyle=function(a){a=a||{},a.align=a.align||"left",this.style=a;var b=a.font.split(" ");this.fontName=b[b.length-1],this.fontSize=b.length>=2?parseInt(b[b.length-2],10):d.BitmapText.fonts[this.fontName].size,this.dirty=!0},d.BitmapText.prototype.updateText=function(){for(var a=d.BitmapText.fonts[this.fontName],b=new d.Point,c=null,e=[],f=0,g=[],h=0,i=this.fontSize/a.size,j=0;j=j;j++){var n=0;"right"==this.style.align?n=f-g[j]:"center"==this.style.align&&(n=(f-g[j])/2),m.push(n)}for(j=0;j0;)this.removeChild(this.getChildAt(0));this.updateText(),this.dirty=!1}d.DisplayObjectContainer.prototype.updateTransform.call(this)},d.BitmapText.fonts={},d.Text=function(a,b){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),d.Sprite.call(this,d.Texture.fromCanvas(this.canvas)),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.Text.prototype=Object.create(d.Sprite.prototype),d.Text.prototype.constructor=d.Text,d.Text.prototype.setStyle=function(a){a=a||{},a.font=a.font||"bold 20pt Arial",a.fill=a.fill||"black",a.align=a.align||"left",a.stroke=a.stroke||"black",a.strokeThickness=a.strokeThickness||0,a.wordWrap=a.wordWrap||!1,a.wordWrapWidth=a.wordWrapWidth||100,this.style=a,this.dirty=!0},d.Sprite.prototype.setText=function(a){this.text=a.toString()||" ",this.dirty=!0},d.Text.prototype.updateText=function(){this.context.font=this.style.font;var a=this.text;this.style.wordWrap&&(a=this.wordWrap(this.text));for(var b=a.split(/(?:\r\n|\r|\n)/),c=[],e=0,f=0;fe?f:arguments.callee(a,b,f,d,e):arguments.callee(a,b,c,f,e)},c=function(a,c,d){if(a.measureText(c).width<=d||c.length<1)return c;var e=b(a,c,0,c.length,d);return c.substring(0,e)+"\n"+arguments.callee(a,c.substring(e),d)},d="",e=a.split("\n"),f=0;fthis.baseTexture.width||a.y+a.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,d.Texture.frameUpdates.push(this)},d.Texture.fromImage=function(a,b){var c=d.TextureCache[a];return c||(c=new d.Texture(d.BaseTexture.fromImage(a,b)),d.TextureCache[a]=c),c},d.Texture.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache "+this);return b},d.Texture.fromCanvas=function(a){var b=new d.BaseTexture(a);return new d.Texture(b)},d.Texture.addTextureToCache=function(a,b){d.TextureCache[b]=a},d.Texture.removeTextureFromCache=function(a){var b=d.TextureCache[a];return d.TextureCache[a]=null,b},d.Texture.frameUpdates=[],d.RenderTexture=function(a,b){d.EventTarget.call(this),this.width=a||100,this.height=b||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),d.gl?this.initWebGL():this.initCanvas()},d.RenderTexture.prototype=Object.create(d.Texture.prototype),d.RenderTexture.prototype.constructor=d.RenderTexture,d.RenderTexture.prototype.initWebGL=function(){var a=d.gl;this.glFramebuffer=a.createFramebuffer(),a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),this.glFramebuffer.width=this.width,this.glFramebuffer.height=this.height,this.baseTexture=new d.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTexture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,this.baseTexture._glTexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,this.width,this.height,0,a.RGBA,a.UNSIGNED_BYTE,null),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.baseTexture.isRender=!0,a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.baseTexture._glTexture,0),this.projection=new d.Point(this.width/2,this.height/2),this.render=this.renderWebGL},d.RenderTexture.prototype.resize=function(a,b){if(this.width=a,this.height=b,d.gl){this.projection.x=this.width/2,this.projection.y=this.height/2;var c=d.gl;c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null)}else this.frame.width=this.width,this.frame.height=this.height,this.renderer.resize(this.width,this.height)},d.RenderTexture.prototype.initCanvas=function(){this.renderer=new d.CanvasRenderer(this.width,this.height,null,0),this.baseTexture=new d.BaseTexture(this.renderer.view),this.frame=new d.Rectangle(0,0,this.width,this.height),this.render=this.renderCanvas},d.RenderTexture.prototype.renderWebGL=function(a,b,c){var e=d.gl;e.colorMask(!0,!0,!0,!0),e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,this.glFramebuffer),c&&(e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)); +var f=a.children,g=a.worldTransform;a.worldTransform=d.mat3.create(),a.worldTransform[4]=-1,a.worldTransform[5]=2*this.projection.y,b&&(a.worldTransform[2]=b.x,a.worldTransform[5]-=b.y),d.visibleCount++,a.vcount=d.visibleCount;for(var h=0,i=f.length;i>h;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection):j.renderSpecific(a,this.projection):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection)),a.worldTransform=g},d.RenderTexture.prototype.renderCanvas=function(a,b,c){var e=a.children;a.worldTransform=d.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},d.EventTarget=function(){var a={};this.addEventListener=this.on=function(b,c){void 0===a[b]&&(a[b]=[]),-1===a[b].indexOf(c)&&a[b].push(c)},this.dispatchEvent=this.emit=function(b){for(var c in a[b.type])a[b.type][c](b)},this.removeEventListener=this.off=function(b,c){var d=a[b].indexOf(c);-1!==d&&a[b].splice(d,1)}},d.PolyK={},d.PolyK.Triangulate=function(a){var b=!0,c=a.length>>1;if(3>c)return[];for(var e=[],f=[],g=0;c>g;g++)f.push(g);for(var g=0,h=c;h>3;){var i=f[(g+0)%h],j=f[(g+1)%h],k=f[(g+2)%h],l=a[2*i],m=a[2*i+1],n=a[2*j],o=a[2*j+1],p=a[2*k],q=a[2*k+1],r=!1;if(d.PolyK._convex(l,m,n,o,p,q,b)){r=!0;for(var s=0;h>s;s++){var t=f[s];if(t!=i&&t!=j&&t!=k&&d.PolyK._PointInTriangle(a[2*t],a[2*t+1],l,m,n,o,p,q)){r=!1;break}}}if(r)e.push(i,j,k),f.splice((g+1)%h,1),h--,g=0;else if(g++>3*h){if(!b)return console.log("PIXI Warning: shape too complex to fill"),[];var e=[];f=[];for(var g=0;c>g;g++)f.push(g);g=0,h=c,b=!1}}return e.push(f[0],f[1],f[2]),e},d.PolyK._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},d.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0==g},e.Camera=function(a,b,c,d,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new e.Rectangle(c,d,f,g),this.screenView=new e.Rectangle(c,d,f,g),this.bounds=new e.Rectangle(c,d,f,g),this.deadzone=null,this.visible=!0,this.atLimit={x:!1,y:!1},this.target=null,this._edge=0,this.displayObject=null},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.prototype={follow:function(a,b){"undefined"==typeof b&&(b=e.Camera.FOLLOW_LOCKON),this.target=a;var c;switch(b){case e.Camera.FOLLOW_PLATFORMER:var d=this.width/8,f=this.height/3;this.deadzone=new e.Rectangle((this.width-d)/2,(this.height-f)/2-.25*f,d,f);break;case e.Camera.FOLLOW_TOPDOWN:c=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:c=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},focusOn:function(a){this.setPosition(Math.round(a.x-this.view.halfWidth),Math.round(a.y-this.view.halfHeight))},focusOnXY:function(a,b){this.setPosition(Math.round(a-this.view.halfWidth),Math.round(b-this.view.halfHeight))},update:function(){this.target&&this.updateTarget(),this.bounds&&this.checkBounds(),this.view.x!==-this.displayObject.position.x&&(this.displayObject.position.x=-this.view.x),this.view.y!==-this.displayObject.position.y&&(this.displayObject.position.y=-this.view.y)},updateTarget:function(){this.deadzone?(this._edge=this.target.x-this.deadzone.x,this.view.x>this._edge&&(this.view.x=this._edge),this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width,this.view.xthis._edge&&(this.view.y=this._edge),this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height,this.view.ythis.bounds.right-this.width&&(this.atLimit.x=!0,this.view.x=this.bounds.right-this.width+1),this.view.ythis.bounds.bottom-this.height&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom-this.height+1),this.view.floor()},setPosition:function(a,b){this.view.x=a,this.view.y=b,this.bounds&&this.checkBounds()},setSize:function(a,b){this.view.width=a,this.view.height=b}},Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),e.State=function(){this.game=null,this.add=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null},e.State.prototype={preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}},e.StateManager=function(a,b){this.game=a,this.states={},null!==b&&(this._pendingState=b)},e.StateManager.prototype={game:null,_pendingState:null,_created:!1,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){null!==this._pendingState&&("string"==typeof this._pendingState?this.start(this._pendingState,!1,!1):this.add("default",this._pendingState,!0))},add:function(a,b,c){"undefined"==typeof c&&(c=!1);var d;return b instanceof e.State?d=b:"object"==typeof b?(d=b,d.game=this.game):"function"==typeof b&&(d=new b(this.game)),this.states[a]=d,c&&(this.game.isBooted?this.start(a):this._pendingState=a),d},remove:function(a){this.current==a&&(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[a]},start:function(a,b,c){return"undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=!1),0==this.game.isBooted?(this._pendingState=a,void 0):(0!=this.checkState(a)&&(this.current&&this.onShutDownCallback.call(this.callbackContext),b&&(this.game.tweens.removeAll(),this.game.world.destroy(),1==c&&this.game.cache.destroy()),this.setCurrentState(a),this.onPreloadCallback?(this.game.load.reset(),this.onPreloadCallback.call(this.callbackContext),0==this.game.load.queueSize?this.game.loadComplete():this.game.load.start()):this.game.loadComplete()),void 0)},dummy:function(){},checkState:function(a){if(this.states[a]){var b=!1;return this.states[a].preload&&(b=!0),0==b&&this.states[a].loadRender&&(b=!0),0==b&&this.states[a].loadUpdate&&(b=!0),0==b&&this.states[a].create&&(b=!0),0==b&&this.states[a].update&&(b=!0),0==b&&this.states[a].preRender&&(b=!0),0==b&&this.states[a].render&&(b=!0),0==b&&this.states[a].paused&&(b=!0),0==b?(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions."),!1):!0}return console.warn("Phaser.StateManager - No state found with the key: "+a),!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].physics=this.game.physics,this.states[a].rnd=this.game.rnd},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,this.onRenderCallback=this.states[a].render||null,this.onPausedCallback=this.states[a].paused||null,this.onShutDownCallback=this.states[a].shutdown||this.dummy,this.current=a,this._created=!1,this.onInitCallback.call(this.callbackContext)},loadComplete:function(){0==this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext)):this._created=!0},update:function(){this._created&&this.onUpdateCallback?this.onUpdateCallback.call(this.callbackContext):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext)},preRender:function(){this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext)},render:function(){this._created&&this.onRenderCallback?this.onRenderCallback.call(this.callbackContext):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext)},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}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(a){return 0==this.total&&null==this.first&&null==this.last?(this.first=a,this.last=a,this.next=a,a.prev=this,this.total++,a):(this.last.next=a,a.prev=this.last,this.last=a,this.total++,a)},remove:function(a){a==this.first?this.first=this.first.next:a==this.last&&(this.last=this.last.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),a.next=a.prev=null,null==this.first&&(this.last=null),this.total--},callAll:function(a){if(this.first&&this.last){var b=this.first;do b&&b[a]&&b[a].call(b),b=b.next;while(b!=this.last.next)}}},e.Signal=function(){this._bindings=[],this._prevParams=null;var a=this;this.dispatch=function(){e.Signal.prototype.dispatch.apply(a,arguments)}},e.Signal.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(a,b){if("function"!=typeof a)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},_registerListener:function(a,b,c,d){var f,g=this._indexOfListener(a,c);if(-1!==g){if(f=this._bindings[g],f.isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else f=new e.SignalBinding(this,a,b,c,d),this._addBinding(f);return this.memorize&&this._prevParams&&f.execute(this._prevParams),f},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c,d=this._bindings.length;d--;)if(c=this._bindings[d],c._listener===a&&c.context===b)return d;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,b,c){return this.validateListener(a,"add"),this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){return this.validateListener(a,"addOnce"),this._registerListener(a,!0,b,c)},remove:function(a,b){this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var a,b=Array.prototype.slice.call(arguments),c=this._bindings.length;if(this.memorize&&(this._prevParams=b),c){a=this._bindings.slice(),this._shouldPropagate=!0;do c--;while(a[c]&&this._shouldPropagate&&a[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},e.SignalBinding=function(a,b,c,d,e){this._listener=b,this._isOnce=c,this.context=d,this._signal=a,this._priority=e||0},e.SignalBinding.prototype={active:!0,params:null,execute:function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,c),this._isOnce&&this.detach()),b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},e.Plugin=function(a,b){"undefined"==typeof b&&(b=null),this.game=a,this.parent=b,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.PluginManager=function(a,b){this.game=a,this._parent=b,this.plugins=[],this._pluginsLength=0},e.PluginManager.prototype={add:function(a){var b=!1;return"function"==typeof a?a=new a(this.game,this._parent):(a.game=this.game,a.parent=this._parent),"function"==typeof a.preUpdate&&(a.hasPreUpdate=!0,b=!0),"function"==typeof a.update&&(a.hasUpdate=!0,b=!0),"function"==typeof a.render&&(a.hasRender=!0,b=!0),"function"==typeof a.postRender&&(a.hasPostRender=!0,b=!0),b?((a.hasPreUpdate||a.hasUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._pluginsLength=this.plugins.push(a),a):null},remove:function(){this._pluginsLength--},preUpdate:function(){if(0!=this._pluginsLength)for(this._p=0;this._pthis._nextOffsetCheck&&(e.Canvas.getOffset(this.canvas,this.offset),this._nextOffsetCheck=this.game.time.now+this.checkOffsetInterval)},visibilityChange:function(a){this.disableVisibilityChange||(this.game.paused="pagehide"==a.type||"blur"==a.type||1==document.hidden||1==document.webkitHidden?!0:!1)}},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(a){this._backgroundColor=a,"string"==typeof a&&(a=e.Color.hexToRGB(a)),this._stage.setBackgroundColor(a)}}),e.Group=function(a,b,c,f){"undefined"==typeof b&&(b=a.world),"undefined"==typeof f&&(f=!1),this.game=a,this.name=c||"group",f?this._container=this.game.stage._stage:(this._container=new d.DisplayObjectContainer,this._container.name=this.name,b?b instanceof e.Group?(b._container.addChild(this._container),b._container.updateTransform()):(b.addChild(this._container),b.updateTransform()):(this.game.stage._stage.addChild(this._container),this.game.stage._stage.updateTransform())),this.type=e.GROUP,this.exists=!0,this.scale=new e.Point(1,1)},e.Group.prototype={add:function(a){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChild(a),a.updateTransform()),a},addAt:function(a,b){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChildAt(a,b),a.updateTransform()),a},getAt:function(a){return this._container.getChildAt(a)},create:function(a,b,c,d,f){"undefined"==typeof f&&(f=!0);var g=new e.Sprite(this.game,a,b,c,d);return g.group=this,g.exists=f,g.visible=f,g.alive=f,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),g},createMultiple:function(a,b,c,d){"undefined"==typeof d&&(d=!1);for(var f=0;a>f;f++){var g=new e.Sprite(this.game,0,0,b,c);g.group=this,g.exists=d,g.visible=d,g.alive=d,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform()}},swap:function(a,b){if(a===b||!a.parent||!b.parent)return console.warn("You cannot swap a child with itself or swap un-parented children"),!1;var c=a._iPrev,d=a._iNext,e=b._iPrev,f=b._iNext,g=this._container.last._iNext,h=this.game.stage._stage;do h!==a&&h!==b&&(h.first===a?h.first=b:h.first===b&&(h.first=a),h.last===a?h.last=b:h.last===b&&(h.last=a)),h=h._iNext;while(h!=g);return a._iNext==b?(a._iNext=f,a._iPrev=b,b._iNext=a,b._iPrev=c,c&&(c._iNext=b),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):b._iNext==a?(a._iNext=b,a._iPrev=e,b._iNext=d,b._iPrev=a,e&&(e._iNext=a),d&&(f._iPrev=b),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):(a._iNext=f,a._iPrev=e,b._iNext=d,b._iPrev=c,c&&(c._iNext=b),d&&(d._iPrev=b),e&&(e._iNext=a),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0)},bringToTop:function(a){return a.group===this&&(this.remove(a),this.add(a)),a},getIndex:function(a){return this._container.children.indexOf(a)},replace:function(a,b){if(this._container.first._iNext){var c=this.getIndex(a);-1!=c&&(void 0!=b.parent&&(b.events.onRemovedFromGroup.dispatch(b,this),b.parent.removeChild(b)),this._container.removeChild(a),this._container.addChildAt(b,c),b.events.onAddedToGroup.dispatch(b,this),b.updateTransform())}},setProperty:function(a,b,c,d){d=d||0,1==b.length?0==d?a[b[0]]=c:1==d?a[b[0]]+=c:2==d?a[b[0]]-=c:3==d?a[b[0]]*=c:4==d&&(a[b[0]]/=c):2==b.length?0==d?a[b[0]][b[1]]=c:1==d?a[b[0]][b[1]]+=c:2==d?a[b[0]][b[1]]-=c:3==d?a[b[0]][b[1]]*=c:4==d&&(a[b[0]][b[1]]/=c):3==b.length?0==d?a[b[0]][b[1]][b[2]]=c:1==d?a[b[0]][b[1]][b[2]]+=c:2==d?a[b[0]][b[1]][b[2]]-=c:3==d?a[b[0]][b[1]][b[2]]*=c:4==d&&(a[b[0]][b[1]][b[2]]/=c):4==b.length&&(0==d?a[b[0]][b[1]][b[2]][b[3]]=c:1==d?a[b[0]][b[1]][b[2]][b[3]]+=c:2==d?a[b[0]][b[1]][b[2]][b[3]]-=c:3==d?a[b[0]][b[1]][b[2]][b[3]]*=c:4==d&&(a[b[0]][b[1]][b[2]][b[3]]/=c))},setAll:function(a,b,c,d,e){if(a=a.split("."),"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=!1),e=e||0,this._container.children.length>0&&this._container.first._iNext){var f=this._container.first._iNext;do(0==c||c&&f.alive)&&(0==d||d&&f.visible)&&this.setProperty(f,a,b,e),f=f._iNext;while(f!=this._container.last._iNext)}},addAll:function(a,b,c,d){this.setAll(a,b,c,d,1)},subAll:function(a,b,c,d){this.setAll(a,b,c,d,2)},multiplyAll:function(a,b,c,d){this.setAll(a,b,c,d,3)},divideAll:function(a,b,c,d){this.setAll(a,b,c,d,4)},callAllExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.exists==b&&d[a]&&d[a].apply(d,c),d=d._iNext;while(d!=this._container.last._iNext)}},callAll:function(a){var b=Array.prototype.splice.call(arguments,1);if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do c[a]&&c[a].apply(c,b),c=c._iNext;while(c!=this._container.last._iNext)}},forEach:function(a,b,c){"undefined"==typeof c&&(c=!1);var d=Array.prototype.splice.call(arguments,3);if(d.unshift(null),this._container.children.length>0&&this._container.first._iNext){var e=this._container.first._iNext;do(0==c||c&&e.exists)&&(d[0]=e,a.apply(b,d)),e=e._iNext;while(e!=this._container.last._iNext)}},forEachAlive:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(c.unshift(null),this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.alive&&(c[0]=d,a.apply(b,c)),d=d._iNext;while(d!=this._container.last._iNext)}},forEachDead:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(c.unshift(null),this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do 0==d.alive&&(c[0]=d,a.apply(b,c)),d=d._iNext;while(d!=this._container.last._iNext)}},getFirstExists:function(a){if("boolean"!=typeof a&&(a=!0),this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.exists===a)return b;b=b._iNext}while(b!=this._container.last._iNext)}return null},getFirstAlive:function(){if(this._container.children.length>0&&this._container.first._iNext){var a=this._container.first._iNext;do{if(a.alive)return a;a=a._iNext}while(a!=this._container.last._iNext)}return null},getFirstDead:function(){if(this._container.children.length>0&&this._container.first._iNext){var a=this._container.first._iNext;do{if(!a.alive)return a;a=a._iNext}while(a!=this._container.last._iNext)}return null},countLiving:function(){var a=0;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do b.alive&&a++,b=b._iNext;while(b!=this._container.last._iNext)}else a=-1;return a},countDead:function(){var a=0;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do b.alive||a++,b=b._iNext;while(b!=this._container.last._iNext)}else a=-1;return a},getRandom:function(a,b){return 0==this._container.children.length?null:(a=a||0,b=b||this._container.children.length,this.game.math.getRandom(this._container.children,a,b))},remove:function(a){a.events&&a.events.onRemovedFromGroup.dispatch(a,this),this._container.removeChild(a),a.group=null},removeAll:function(){if(0!=this._container.children.length)do 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)},removeBetween:function(a,b){if(0!=this._container.children.length){if(a>b||0>a||b>this._container.children.length)return!1;for(var c=a;b>c;c++){var d=this._container.children[c];d.events.onRemovedFromGroup.dispatch(d,this),this._container.removeChild(d)}}},destroy:function(){this.removeAll(),this._container.parent.removeChild(this._container),this._container=null,this.game=null,this.exists=!1},dump:function(a){"undefined"==typeof a&&(a=!1);var b=20,c="\n"+e.Utils.pad("Node",b)+"|"+e.Utils.pad("Next",b)+"|"+e.Utils.pad("Previous",b)+"|"+e.Utils.pad("First",b)+"|"+e.Utils.pad("Last",b);console.log(c);var c=e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b);if(console.log(c),a)var d=this.game.stage._stage.last._iNext,f=this.game.stage._stage;else var d=this._container.last._iNext,f=this._container;do{var g=f.name||"*",h="-",i="-",j="-",k="-";f._iNext&&(h=f._iNext.name),f._iPrev&&(i=f._iPrev.name),f.first&&(j=f.first.name),f.last&&(k=f.last.name),"undefined"==typeof h&&(h="-"),"undefined"==typeof i&&(i="-"),"undefined"==typeof j&&(j="-"),"undefined"==typeof k&&(k="-");var c=e.Utils.pad(g,b)+"|"+e.Utils.pad(h,b)+"|"+e.Utils.pad(i,b)+"|"+e.Utils.pad(j,b)+"|"+e.Utils.pad(k,b);console.log(c),f=f._iNext}while(f!=d)}},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this._container.children.length}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this._container.children.length}}),Object.defineProperty(e.Group.prototype,"x",{get:function(){return this._container.position.x},set:function(a){this._container.position.x=a}}),Object.defineProperty(e.Group.prototype,"y",{get:function(){return this._container.position.y},set:function(a){this._container.position.y=a}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this._container.rotation)},set:function(a){this._container.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Group.prototype,"rotation",{get:function(){return this._container.rotation},set:function(a){this._container.rotation=a}}),Object.defineProperty(e.Group.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Group.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),e.World=function(a){e.Group.call(this,a,null,"__world",!1),this.scale=new e.Point(1,1),this.bounds=new e.Rectangle(0,0,a.width,a.height),this.camera=null,this.currentRenderOrderID=0},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.camera.displayObject=this._container,this.game.camera=this.camera},e.World.prototype.update=function(){if(this.currentRenderOrderID=0,this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.preUpdate&&a.preUpdate(),a.update&&a.update(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.postUpdate=function(){if(this.camera.update(),this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.postUpdate&&a.postUpdate(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.setBounds=function(a,b,c,d){this.bounds.setTo(a,b,c,d),this.camera.bounds&&this.camera.bounds.setTo(a,b,c,d)},e.World.prototype.destroy=function(){this.camera.x=0,this.camera.y=0,this.game.input.reset(!0),this.removeAll()},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){this.bounds.width=a}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){this.bounds.height=a}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}}),Object.defineProperty(e.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.integerInRange(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.integerInRange(this.bounds.x,this.bounds.width)}}),Object.defineProperty(e.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.integerInRange(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.integerInRange(this.bounds.y,this.bounds.height)}}),e.Game=function(a,b,c,d,f,g,h){a=a||800,b=b||600,c=c||e.AUTO,d=d||"",f=f||null,"undefined"==typeof g&&(g=!1),"undefined"==typeof h&&(h=!0),this.id=e.GAMES.push(this)-1,this.parent=d,this.width=a,this.height=b,this.transparent=g,this.antialias=h,this.renderer=null,this.state=new e.StateManager(this,f),this._paused=!1,this.renderType=c,this._loadComplete=!1,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.rnd=null,this.device=null,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null;var i=this;return this._onBoot=function(){return i.boot()},"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(this._onBoot,0):(document.addEventListener("DOMContentLoaded",this._onBoot,!1),window.addEventListener("load",this._onBoot,!1)),this},e.Game.prototype={boot:function(){if(!this.isBooted)if(document.body){document.removeEventListener("DOMContentLoaded",this._onBoot),window.removeEventListener("load",this._onBoot),this.onPause=new e.Signal,this.onResume=new e.Signal,this.isBooted=!0,this.device=new e.Device,this.math=e.Math,this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.stage=new e.Stage(this,this.width,this.height),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics.Arcade(this),this.particles=new e.Particles(this),this.plugins=new e.PluginManager(this,this),this.net=new e.Net(this),this.debug=new e.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.renderType==e.CANVAS?console.log("%cPhaser "+e.VERSION+" initialized. Rendering to Canvas","color: #ffff33; background: #000000"):console.log("%cPhaser "+e.VERSION+" initialized. Rendering to WebGL","color: #ffff33; background: #000000");var a=e.VERSION.indexOf("-"),b=a>=0?e.VERSION.substr(a+1):null;if(b){var c=["a","e","i","o","u","y"].indexOf(b.charAt(0))>=0?"an":"a";console.warn("You are using %s %s version of Phaser. Some things may not work.",c,b)}this.isRunning=!0,this._loadComplete=!1,this.raf=new e.RequestAnimationFrame(this),this.raf.start()}else window.setTimeout(this._onBoot,20)},setUpRenderer:function(){if(this.renderType===e.CANVAS||this.renderType===e.AUTO&&0==this.device.webGL){if(!this.device.canvas)throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting."); +this.renderType=e.CANVAS,this.renderer=new d.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent),e.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias),this.canvas=this.renderer.view,this.context=this.renderer.context}else this.renderType=e.WEBGL,this.renderer=new d.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias),this.canvas=this.renderer.view,this.context=null;e.Canvas.addToDOM(this.renderer.view,this.parent,!0),e.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=!0,this.state.loadComplete()},update:function(a){this.time.update(a),this._paused||(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.renderer.render(this.stage._stage),this.plugins.render(),this.state.render(),this.plugins.postRender())},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=!1}},Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){a===!0?0==this._paused&&(this._paused=!0,this.onPause.dispatch(this)):this._paused&&(this._paused=!1,this.onResume.dispatch(this))}}),e.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:!1,multiInputOverride:e.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2e3,justPressedRate:200,justReleasedRate:200,recordPointerHistory:!1,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new e.LinkedList,boot:function(){this.mousePointer=new e.Pointer(this.game,0),this.pointer1=new e.Pointer(this.game,1),this.pointer2=new e.Pointer(this.game,2),this.mouse=new e.Mouse(this.game),this.keyboard=new e.Keyboard(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.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=!0},destroy:function(){this.mouse.stop(),this.keyboard.stop(),this.touch.stop(),this.mspointer.stop()},addPointer:function(){for(var a=0,b=10;b>0;b--)null===this["pointer"+b]&&(a=b);return 0==a?(console.warn("You can only have 10 Pointer objects"),null):(this["pointer"+a]=new e.Pointer(this.game,a),this["pointer"+a])},update:function(){return this.pollRate>0&&this._pollCounter=b;b++)this["pointer"+b]&&this["pointer"+b].reset();this.currentPointers=0,this.game.stage.canvas.style.cursor="default",1==a&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.interactiveItems.callAll("reset")),this._pollCounter=0}},resetSpeed:function(a,b){this._oldPosition.setTo(a,b),this.speed.setTo(0,0)},startPointer:function(a){if(this.maxPointers<10&&this.totalActivePointers==this.maxPointers)return null;if(0==this.pointer1.active)return this.pointer1.start(a);if(0==this.pointer2.active)return this.pointer2.start(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&0==this["pointer"+b].active)return this["pointer"+b].start(a);return null},updatePointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.move(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.move(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].move(a);return null},stopPointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.stop(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.stop(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].stop(a);return null},getPointer:function(a){if(a=a||!1,this.pointer1.active==a)return this.pointer1;if(this.pointer2.active==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active==a)return this["pointer"+b];return null},getPointerFromIdentifier:function(a){if(this.pointer1.identifier==a)return this.pointer1;if(this.pointer2.identifier==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].identifier==a)return this["pointer"+b];return null}},Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter=a;a++)this["pointer"+a]&&this["pointer"+a].active&&this.currentPointers++;return this.currentPointers}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Key=function(a,b){this.game=a,this.isDown=!1,this.isUp=!1,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=0,this.repeats=0,this.keyCode=b,this.onDown=new e.Signal,this.onUp=new e.Signal},e.Key.prototype={processKeyDown:function(a){this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown?(this.duration=a.timeStamp-this.timeDown,this.repeats++):(this.isDown=!0,this.isUp=!1,this.timeDown=a.timeStamp,this.duration=0,this.repeats=0,this.onDown.dispatch(this))},processKeyUp:function(a){this.isDown=!1,this.isUp=!0,this.timeUp=a.timeStamp,this.onUp.dispatch(this)},justPressed:function(a){return"undefined"==typeof a&&(a=250),this.isDown&&this.duration=this.game.input.holdRate&&((this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&this.game.input.onHold.dispatch(this),this._holdSent=!0),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}),this._history.length>this.game.input.recordLimit&&this._history.shift()))},move:function(a){if(!this.game.input.pollLocked){if("undefined"!=typeof a.button&&(this.button=a.button),this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.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,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(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),this.game.paused)return this;if(null!==this.targetObject&&1==this.targetObject.isDragged)return 0==this.targetObject.update(this)&&(this.targetObject=null),this;if(this._highestRenderOrderID=-1,this._highestRenderObject=null,this._highestInputPriorityID=-1,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do(b.pixelPerfect||b.priorityID>this._highestInputPriorityID||b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)&&b.checkPointerOver(this)&&(this._highestRenderOrderID=b.sprite.renderOrderID,this._highestInputPriorityID=b.priorityID,this._highestRenderObject=b),b=b.next;while(null!=b)}return null==this._highestRenderObject?this.targetObject&&(this.targetObject._pointerOutHandler(this),this.targetObject=null):null==this.targetObject?(this.targetObject=this._highestRenderObject,this._highestRenderObject._pointerOverHandler(this)):this.targetObject==this._highestRenderObject?0==this._highestRenderObject.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this),this.targetObject=this._highestRenderObject,this.targetObject._pointerOverHandler(this)),this}},leave:function(a){this.withinGame=!1,this.move(a)},stop:function(a){if(this._stateReset)return a.preventDefault(),void 0;if(this.timeUp=this.game.time.now,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.onUp.dispatch(this,a),this.duration>=0&&this.duration<=this.game.input.tapRate&&(this.timeUp-this.previousTapTime0&&(this.active=!1),this.withinGame=!1,this.isDown=!1,this.isUp=!0,0==this.isMouse&&this.game.input.currentPointers--,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do b&&b._releasedHandler(this),b=b.next;while(null!=b)}return this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null,this},justPressed:function(a){return a=a||this.game.input.justPressedRate,this.isDown===!0&&this.timeDown+a>this.game.time.now},justReleased:function(a){return a=a||this.game.input.justReleasedRate,this.isUp===!0&&this.timeUp+a>this.game.time.now},reset:function(){0==this.isMouse&&(this.active=!1),this.identifier=null,this.isDown=!1,this.isUp=!0,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},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+")}]"}},Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.now-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.Touch=function(a){this.game=a,this.disabled=!1,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},e.Touch.prototype={start:function(){var a=this;this.game.device.touch&&(this._onTouchStart=function(b){return a.onTouchStart(b)},this._onTouchMove=function(b){return a.onTouchMove(b)},this._onTouchEnd=function(b){return a.onTouchEnd(b)},this._onTouchEnter=function(b){return a.onTouchEnter(b)},this._onTouchLeave=function(b){return a.onTouchLeave(b)},this._onTouchCancel=function(b){return a.onTouchCancel(b)},this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,!1),this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,!1),this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,!1),this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,!1),this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,!1),this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,!1))},consumeDocumentTouches:function(){this._documentTouchMove=function(a){a.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(a){if(this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,a),!this.game.input.disabled&&!this.disabled){this.preventDefault&&a.preventDefault();for(var b=0;bc;c++)this._pointerData[c]={id:c,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new e.Point,this.enabled=!0,this.sprite.events&&null==this.sprite.events.onInputOver&&(this.sprite.events.onInputOver=new e.Signal,this.sprite.events.onInputOut=new e.Signal,this.sprite.events.onInputDown=new e.Signal,this.sprite.events.onInputUp=new e.Signal,this.sprite.events.onDragStart=new e.Signal,this.sprite.events.onDragStop=new e.Signal)}return this.sprite},reset:function(){this.enabled=!1;for(var a=0;10>a;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){0!=this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this),this.stop(),this.sprite=null)},pointerX:function(a){return a=a||0,this._pointerData[a].x},pointerY:function(a){return a=a||0,this._pointerData[a].y},pointerDown:function(a){return a=a||0,this._pointerData[a].isDown},pointerUp:function(a){return a=a||0,this._pointerData[a].isUp},pointerTimeDown:function(a){return a=a||0,this._pointerData[a].timeDown},pointerTimeUp:function(a){return a=a||0,this._pointerData[a].timeUp},pointerOver:function(a){return a=a||0,this._pointerData[a].isOver},pointerOut:function(a){return a=a||0,this._pointerData[a].isOut},pointerTimeOver:function(a){return a=a||0,this._pointerData[a].timeOver},pointerTimeOut:function(a){return a=a||0,this._pointerData[a].timeOut},pointerDragged:function(a){return a=a||0,this._pointerData[a].isDragged},checkPointerOver:function(a){return this.enabled&&this.sprite.visible&&(this.sprite.getLocalUnmodifiedPosition(this._tempPoint,a.x,a.y),this._tempPoint.x>=0&&this._tempPoint.x<=this.sprite.currentFrame.width&&this._tempPoint.y>=0&&this._tempPoint.y<=this.sprite.currentFrame.height)?this.pixelPerfect?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0:!1},checkPixel:function(a,b){if(this.sprite.texture.baseTexture.source){this.game.input.hitContext.clearRect(0,0,1,1),a+=this.sprite.texture.frame.x,b+=this.sprite.texture.frame.y,this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1);var c=this.game.input.hitContext.getImageData(0,0,1,1);if(c.data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){return 0==this.enabled||0==this.sprite.visible||this.sprite.group&&0==this.sprite.group.visible?(this._pointerOutHandler(a),!1):this.draggable&&this._draggedPointerID==a.id?this.updateDrag(a):1==this._pointerData[a.id].isOver?this.checkPointerOver(a)?(this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0):(this._pointerOutHandler(a),!1):void 0},_pointerOverHandler:function(a){0==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isOver=!0,this._pointerData[a.id].isOut=!1,this._pointerData[a.id].timeOver=this.game.time.now,this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="pointer"),this.sprite.events.onInputOver.dispatch(this.sprite,a))},_pointerOutHandler:function(a){this._pointerData[a.id].isOver=!1,this._pointerData[a.id].isOut=!0,this._pointerData[a.id].timeOut=this.game.time.now,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="default"),this.sprite&&this.sprite.events&&this.sprite.events.onInputOut.dispatch(this.sprite,a) +},_touchedHandler:function(a){return 0==this._pointerData[a.id].isDown&&1==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isDown=!0,this._pointerData[a.id].isUp=!1,this._pointerData[a.id].timeDown=this.game.time.now,this.sprite.events.onInputDown.dispatch(this.sprite,a),this.draggable&&0==this.isDragged&&this.startDrag(a),this.bringToTop&&this.sprite.bringToTop()),this.consumePointerEvent},_releasedHandler:function(a){this._pointerData[a.id].isDown&&a.isUp&&(this._pointerData[a.id].isDown=!1,this._pointerData[a.id].isUp=!0,this._pointerData[a.id].timeUp=this.game.time.now,this._pointerData[a.id].downDuration=this._pointerData[a.id].timeUp-this._pointerData[a.id].timeDown,this.checkPointerOver(a)?this.sprite.events.onInputUp.dispatch(this.sprite,a):this.useHandCursor&&(this.game.stage.canvas.style.cursor="default"),this.draggable&&this.isDragged&&this._draggedPointerID==a.id&&this.stopDrag(a))},updateDrag:function(a){return a.isUp?(this.stopDrag(a),!1):(this.allowHorizontalDrag&&(this.sprite.x=a.x+this._dragPoint.x+this.dragOffset.x),this.allowVerticalDrag&&(this.sprite.y=a.y+this._dragPoint.y+this.dragOffset.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),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),!0)},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)a;a++)this._pointerData[a].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1},startDrag:function(a){this.isDragged=!0,this._draggedPointerID=a.id,this._pointerData[a.id].isDragged=!0,this.dragFromCenter?(this.sprite.centerOn(a.x,a.y),this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y)):this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y),this.updateDrag(a),this.bringToTop&&this.sprite.bringToTop(),this.sprite.events.onDragStart.dispatch(this.sprite,a)},stopDrag:function(a){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[a.id].isDragged=!1,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,a),this.sprite.events.onInputUp.dispatch(this.sprite,a)},setDragLock:function(a,b){"undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d){"undefined"==typeof c&&(c=!0),"undefined"==typeof d&&(d=!1),this.snapX=a,this.snapY=b,this.snapOnDrag=c,this.snapOnRelease=d},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.xthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-this.sprite.width),this.sprite.ythis.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-this.sprite.height)},checkBoundsSprite:function(){this.sprite.xthis.boundsSprite.x+this.boundsSprite.width&&(this.sprite.x=this.boundsSprite.x+this.boundsSprite.width-this.sprite.width),this.sprite.ythis.boundsSprite.y+this.boundsSprite.height&&(this.sprite.y=this.boundsSprite.y+this.boundsSprite.height-this.sprite.height)}},e.Events=function(a){this.parent=a,this.onAddedToGroup=new e.Signal,this.onRemovedFromGroup=new e.Signal,this.onKilled=new e.Signal,this.onRevived=new e.Signal,this.onOutOfBounds=new e.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},e.Events.prototype={destroy:function(){this.parent=null,this.onAddedToGroup.dispose(),this.onRemovedFromGroup.dispose(),this.onKilled.dispose(),this.onRevived.dispose(),this.onOutOfBounds.dispose(),this.onInputOver&&(this.onInputOver.dispose(),this.onInputOut.dispose(),this.onInputDown.dispose(),this.onInputUp.dispose(),this.onDragStart.dispose(),this.onDragStop.dispose()),this.onAnimationStart&&(this.onAnimationStart.dispose(),this.onAnimationComplete.dispose(),this.onAnimationLoop.dispose())}},e.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},sprite:function(a,b,c,d){return this.world.create(a,b,c,d)},child:function(a,b,c,d,e){return a.create(b,c,d,e)},tween:function(a){return this.game.tweens.create(a)},group:function(a,b){return new e.Group(this.game,a,b)},audio:function(a,b,c){return this.game.sound.add(a,b,c)},tileSprite:function(a,b,c,d,f,g){return this.world.add(new e.TileSprite(this.game,a,b,c,d,f,g))},text:function(a,b,c,d){return this.world.add(new e.Text(this.game,a,b,c,d))},button:function(a,b,c,d,f,g,h,i){return this.world.add(new e.Button(this.game,a,b,c,d,f,g,h,i))},graphics:function(a,b){return this.world.add(new e.Graphics(this.game,a,b))},emitter:function(a,b,c){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,a,b,c))},bitmapText:function(a,b,c,d){return this.world.add(new e.BitmapText(this.game,a,b,c,d))},tilemap:function(a){return new e.Tilemap(this.game,a)},tileset:function(a){return this.game.cache.getTileset(a)},tilemapLayer:function(a,b,c,d,f,g,h){return this.world.add(new e.TilemapLayer(this.game,a,b,c,d,f,g,h))},renderTexture:function(a,b,c){var d=new e.RenderTexture(this.game,a,b,c);return this.game.cache.addRenderTexture(a,d),d}},e.Sprite=function(a,b,c,f,g){b=b||0,c=c||0,f=f||null,g=g||null,this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=e.SPRITE,this.renderOrderID=-1,this.lifespan=0,this.events=new e.Events(this),this.animations=new e.AnimationManager(this),this.input=new e.InputHandler(this),this.key=f,this.currentFrame=null,f instanceof e.RenderTexture?(d.Sprite.call(this,f),this.currentFrame=this.game.cache.getTextureFrame(f.name)):f instanceof d.Texture?(d.Sprite.call(this,f),this.currentFrame=g):((null==f||0==this.game.cache.checkImageKey(f))&&(f="__default",this.key=f),d.Sprite.call(this,d.TextureCache[f]),this.game.cache.isSpriteSheet(f)?(this.animations.loadFrameData(this.game.cache.getFrameData(f)),null!==g&&("string"==typeof g?this.frameName=g:this.frame=g)):this.currentFrame=this.game.cache.getFrame(f)),this.anchor=new e.Point,this.x=b,this.y=c,this.position.x=b,this.position.y=c,this.autoCull=!1,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:-1,a01:-1,a02:-1,a10:-1,a11:-1,a12:-1,id:-1,i01:-1,i10:-1,idi:-1,left:null,right:null,top:null,bottom:null,x:-1,y:-1,scaleX:1,scaleY:1,realScaleX:1,realScaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),calcWidth:-1,calcHeight:-1,frameID:-1,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,boundsX:0,boundsY:0,cameraVisible:!0,cropX:0,cropY:0,cropWidth:this.currentFrame.sourceSizeW,cropHeight:this.currentFrame.sourceSizeH},this.offset=new e.Point,this.center=new e.Point(b+Math.floor(this._cache.width/2),c+Math.floor(this._cache.height/2)),this.topLeft=new e.Point(b,c),this.topRight=new e.Point(b+this._cache.width,c),this.bottomRight=new e.Point(b+this._cache.width,c+this._cache.height),this.bottomLeft=new e.Point(b,c+this._cache.height),this.bounds=new e.Rectangle(b,c,this._cache.width,this._cache.height),this.body=new e.Physics.Arcade.Body(this),this.health=1,this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds),this.inWorldThreshold=0,this.outOfBoundsKill=!1,this._outOfBoundsFired=!1,this.fixedToCamera=!1,this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.cropEnabled=!1},e.Sprite.prototype=Object.create(d.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Sprite.prototype.preUpdate=function(){return this.exists?this.lifespan>0&&(this.lifespan-=this.game.time.elapsed,this.lifespan<=0)?(this.kill(),void 0):(this._cache.dirty=!1,this.animations.update()&&(this._cache.dirty=!0),this.visible&&(this.renderOrderID=this.game.world.currentRenderOrderID++),this.prevX=this.x,this.prevY=this.y,this.updateCache(),this.updateAnimation(),this.cropEnabled&&this.updateCrop(),this._cache.dirty&&(this.updateBounds(),this._cache.cameraVisible=e.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0),1==this.autoCull&&(this.renderable=this._cache.cameraVisible),this.body&&this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)),this.body&&this.body.preUpdate(),void 0):(this.renderOrderID=-1,void 0)},e.Sprite.prototype.updateCache=function(){(this.worldTransform[1]!=this._cache.i01||this.worldTransform[3]!=this._cache.i10)&&(this._cache.a00=this.worldTransform[0],this._cache.a01=this.worldTransform[1],this._cache.a10=this.worldTransform[3],this._cache.a11=this.worldTransform[4],this._cache.i01=this.worldTransform[1],this._cache.i10=this.worldTransform[3],this._cache.scaleX=Math.sqrt(this._cache.a00*this._cache.a00+this._cache.a01*this._cache.a01),this._cache.scaleY=Math.sqrt(this._cache.a10*this._cache.a10+this._cache.a11*this._cache.a11),this._cache.a01*=-1,this._cache.a10*=-1,this._cache.dirty=!0),(this.worldTransform[2]!=this._cache.a02||this.worldTransform[5]!=this._cache.a12)&&(this._cache.a02=this.worldTransform[2],this._cache.a12=this.worldTransform[5],this._cache.dirty=!0)},e.Sprite.prototype.updateAnimation=function(){this.currentFrame&&this.currentFrame.uuid!=this._cache.frameID&&(this._cache.frameWidth=this.texture.frame.width,this._cache.frameHeight=this.texture.frame.height,this._cache.frameID=this.currentFrame.uuid,this._cache.dirty=!0),this._cache.dirty&&this.currentFrame&&(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.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))},e.Sprite.prototype.updateBounds=function(){var a=1,b=1;(0!==this.worldTransform[3]||0!==this.worldTransform[1])&&(a=this.scale.x,b=this.scale.y),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,a,b),this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y,a,b),this.getLocalPosition(this.topRight,this.offset.x+this.width,this.offset.y,a,b),this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this.height,a,b),this.getLocalPosition(this.bottomRight,this.offset.x+this.width,this.offset.y+this.height,a,b),this._cache.left=e.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.right=e.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.top=e.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this._cache.bottom=e.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._cache.boundsX=this._cache.x,this._cache.boundsY=this._cache.y,this.updateFrame=!0,0==this.inWorld?(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),this.inWorld&&(this._outOfBoundsFired=!1)):(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),0==this.inWorld&&(this.events.onOutOfBounds.dispatch(this),this._outOfBoundsFired=!0,this.outOfBoundsKill&&this.kill()))},e.Sprite.prototype.getLocalPosition=function(a,b,c,d,e){return a.x=(this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*c+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*d+this._cache.a02,a.y=(this._cache.a00*this._cache.id*c+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*e+this._cache.a12,a},e.Sprite.prototype.getLocalUnmodifiedPosition=function(a,b,c){var d=this.worldTransform[0],e=this.worldTransform[1],f=this.worldTransform[2],g=this.worldTransform[3],h=this.worldTransform[4],i=this.worldTransform[5],j=1/(d*h+e*-g),k=h*j*b+-e*j*c+(i*e-f*h)*j,l=d*j*c+-g*j*b+(-i*d+f*g)*j;return a.x=k+this.anchor.x*this._cache.width,a.y=l+this.anchor.y*this._cache.height,a},e.Sprite.prototype.updateCrop=function(){(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=!0,d.Texture.frameUpdates.push(this.texture))},e.Sprite.prototype.resetCrop=function(){this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.texture.setFrame(this.crop),this.cropEnabled=!1},e.Sprite.prototype.postUpdate=function(){this.exists&&(this.body&&this.body.postUpdate(),this.fixedToCamera?(this._cache.x=this.game.camera.view.x+this.x,this._cache.y=this.game.camera.view.y+this.y):(this._cache.x=this.x,this._cache.y=this.y),(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y))},e.Sprite.prototype.loadTexture=function(a,b){this.key=a,a instanceof e.RenderTexture?this.currentFrame=this.game.cache.getTextureFrame(a.name):a instanceof d.Texture?this.currentFrame=b:(("undefined"==typeof a||this.game.cache.checkImageKey(a)===!1)&&(a="__default",this.key=a),this.game.cache.isSpriteSheet(a)?(this.animations.loadFrameData(this.game.cache.getFrameData(a)),"undefined"!=typeof b&&("string"==typeof b?this.frameName=b:this.frame=b)):(this.currentFrame=this.game.cache.getFrame(a),this.setTexture(d.TextureCache[a])))},e.Sprite.prototype.deltaAbsX=function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},e.Sprite.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},e.Sprite.prototype.deltaX=function(){return this.x-this.prevX},e.Sprite.prototype.deltaY=function(){return this.y-this.prevY},e.Sprite.prototype.centerOn=function(a,b){return this.x=a+(this.x-this.center.x),this.y=b+(this.y-this.center.y),this},e.Sprite.prototype.revive=function(a){return"undefined"==typeof a&&(a=1),this.alive=!0,this.exists=!0,this.visible=!0,this.health=a,this.events&&this.events.onRevived.dispatch(this),this},e.Sprite.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled.dispatch(this),this},e.Sprite.prototype.destroy=function(){this.group&&this.group.remove(this),this.input&&this.input.destroy(),this.events&&this.events.destroy(),this.animations&&this.animations.destroy(),this.alive=!1,this.exists=!1,this.visible=!1,this.game=null},e.Sprite.prototype.damage=function(a){return this.alive&&(this.health-=a,this.health<0&&this.kill()),this},e.Sprite.prototype.reset=function(a,b,c){return"undefined"==typeof c&&(c=1),this.x=a,this.y=b,this.position.x=this.x,this.position.y=this.y,this.alive=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this._outOfBoundsFired=!1,this.health=c,this.body&&this.body.reset(),this},e.Sprite.prototype.bringToTop=function(){return this.group?this.group.bringToTop(this):this.game.world.bringToTop(this),this},e.Sprite.prototype.play=function(a,b,c,d){return this.animations?this.animations.play(a,b,c,d):void 0},Object.defineProperty(e.Sprite.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(a){this.rotation=e.Math.degToRad(e.Math.wrapAngle(a))}}),Object.defineProperty(e.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}}),Object.defineProperty(e.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}),Object.defineProperty(e.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}}),Object.defineProperty(e.Sprite.prototype,"width",{get:function(){return this.scale.x*this.currentFrame.width},set:function(a){this.scale.x=a/this.currentFrame.width,this._cache.scaleX=a/this.currentFrame.width,this._width=a}}),Object.defineProperty(e.Sprite.prototype,"height",{get:function(){return this.scale.y*this.currentFrame.height},set:function(a){this.scale.y=a/this.currentFrame.height,this._cache.scaleY=a/this.currentFrame.height,this._height=a}}),Object.defineProperty(e.Sprite.prototype,"inputEnabled",{get:function(){return this.input.enabled},set:function(a){a?0==this.input.enabled&&this.input.start():this.input.enabled&&this.input.stop()}}),e.TileSprite=function(a,b,c,f,g,h,i){b=b||0,c=c||0,f=f||256,g=g||256,h=h||null,i=i||null,e.Sprite.call(this,a,b,c,h,i),this.texture=d.TextureCache[h],d.TilingSprite.call(this,this.texture,f,g),this.type=e.TILESPRITE,this.tileScale=new e.Point(1,1),this.tilePosition=new e.Point(0,0)},e.TileSprite.prototype=e.Utils.extend(!0,d.TilingSprite.prototype,e.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Text=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,this._text=f,this._style=g,d.Text.call(this,f,g),this.type=e.TEXT,this.position.x=this.x=b,this.position.y=this.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.Text.prototype=Object.create(d.Text.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(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=!0))},e.Text.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.Text.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Text.prototype,"content",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a,this.setText(a))}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._style},set:function(a){a!==this._style&&(this._style=a,this.setStyle(a))}}),e.BitmapText=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,d.BitmapText.call(this,f,g),this.type=e.BITMAPTEXT,this.position.x=b,this.position.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.BitmapText.prototype=Object.create(d.BitmapText.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.BitmapText.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(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=!0),this.pivot.x=this.anchor.x*this.width,this.pivot.y=this.anchor.y*this.height)},e.BitmapText.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.BitmapText.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.Button=function(a,b,c,d,f,g,h,i,j){b=b||0,c=c||0,d=d||null,f=f||null,g=g||this,e.Sprite.call(this,a,b,c,d,i),this.type=e.BUTTON,this._onOverFrameName=null,this._onOutFrameName=null,this._onDownFrameName=null,this._onUpFrameName=null,this._onOverFrameID=null,this._onOutFrameID=null,this._onDownFrameID=null,this._onUpFrameID=null,this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.setFrames(h,i,j),null!==f&&this.onInputUp.add(f,g),this.freezeFrames=!1,this.input.start(0,!0),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)},e.Button.prototype=e.Utils.extend(!0,e.Sprite.prototype,d.Sprite.prototype),e.Button.prototype.constructor=e.Button,e.Button.prototype.setFrames=function(a,b,c){null!==a&&("string"==typeof a?(this._onOverFrameName=a,this.input.pointerOver()&&(this.frameName=a)):(this._onOverFrameID=a,this.input.pointerOver()&&(this.frame=a))),null!==b&&("string"==typeof b?(this._onOutFrameName=b,this._onUpFrameName=b,0==this.input.pointerOver()&&(this.frameName=b)):(this._onOutFrameID=b,this._onUpFrameID=b,0==this.input.pointerOver()&&(this.frame=b))),null!==c&&("string"==typeof c?(this._onDownFrameName=c,this.input.pointerOver()&&(this.frameName=c)):(this._onDownFrameID=c,this.input.pointerOver()&&(this.frame=c)))},e.Button.prototype.onInputOverHandler=function(a){0==this.freezeFrames&&(null!=this._onOverFrameName?this.frameName=this._onOverFrameName:null!=this._onOverFrameID&&(this.frame=this._onOverFrameID)),this.onInputOver&&this.onInputOver.dispatch(this,a)},e.Button.prototype.onInputOutHandler=function(a){0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onInputOut&&this.onInputOut.dispatch(this,a)},e.Button.prototype.onInputDownHandler=function(a){0==this.freezeFrames&&(null!=this._onDownFrameName?this.frameName=this._onDownFrameName:null!=this._onDownFrameID&&(this.frame=this._onDownFrameID)),this.onInputDown&&this.onInputDown.dispatch(this,a)},e.Button.prototype.onInputUpHandler=function(a){0==this.freezeFrames&&(null!=this._onUpFrameName?this.frameName=this._onUpFrameName:null!=this._onUpFrameID&&(this.frame=this._onUpFrameID)),this.onInputUp&&this.onInputUp.dispatch(this,a)},e.Graphics=function(a){this.game=a,d.Graphics.call(this),this.type=e.GRAPHICS},e.Graphics.prototype=Object.create(d.Graphics.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Graphics.prototype.destroy=function(){this.clear(),this.group&&this.group.remove(this),this.game=null},Object.defineProperty(e.Graphics.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(a){this.rotation=e.Math.degToRad(e.Math.wrapAngle(a))}}),Object.defineProperty(e.Graphics.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.Graphics.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.RenderTexture=function(a,b,c,f){this.game=a,this.name=b,d.EventTarget.call(this),this.width=c||100,this.height=f||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),this.type=e.RENDERTEXTURE,d.gl?this.initWebGL():this.initCanvas()},e.RenderTexture.prototype=e.Utils.extend(!0,d.RenderTexture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,e.Canvas={create:function(a,b){a=a||256,b=b||256;var c=document.createElement("canvas");return c.width=a,c.height=b,c.style.display="block",c},getOffset:function(a,b){b=b||new e.Point;var c=a.getBoundingClientRect(),d=a.clientTop||document.body.clientTop||0,f=a.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||a.scrollTop||document.body.scrollTop,h=window.pageXOffset||a.scrollLeft||document.body.scrollLeft;return b.x=c.left+h-f,b.y=c.top+g-d,b},getAspectRatio:function(a){return a.width/a.height},setBackgroundColor:function(a,b){return b=b||"rgb(0,0,0)",a.style.backgroundColor=b,a},setTouchAction:function(a,b){return b=b||"none",a.style.msTouchAction=b,a.style["ms-touch-action"]=b,a.style["touch-action"]=b,a},setUserSelect:function(a,b){return b=b||"none",a.style["-webkit-touch-callout"]=b,a.style["-webkit-user-select"]=b,a.style["-khtml-user-select"]=b,a.style["-moz-user-select"]=b,a.style["-ms-user-select"]=b,a.style["user-select"]=b,a.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",a},addToDOM:function(a,b,c){return b=b||"","undefined"==typeof c&&(c=!0),""!==b?document.getElementById(b)?(document.getElementById(b).appendChild(a),c&&(document.getElementById(b).style.overflow="hidden")):document.body.appendChild(a):document.body.appendChild(a),a},setTransform:function(a,b,c,d,e,f,g){return a.setTransform(d,f,g,e,b,c),a},setSmoothingEnabled:function(a,b){return a.imageSmoothingEnabled=b,a.mozImageSmoothingEnabled=b,a.oImageSmoothingEnabled=b,a.webkitImageSmoothingEnabled=b,a.msImageSmoothingEnabled=b,a},setImageRenderingCrisp:function(a){return a.style["image-rendering"]="crisp-edges",a.style["image-rendering"]="-moz-crisp-edges",a.style["image-rendering"]="-webkit-optimize-contrast",a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},e.StageScaleMode=function(a){this._startHeight=0,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this.pageAlignHorizontally=!1,this.pageAlignVertically=!1,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.width=0,this.height=0,this.maxIterations=5,this.game=a,this.enterLandscape=new e.Signal,this.enterPortrait=new e.Signal,this.orientation=window.orientation?window.orientation:window.outerWidth>window.outerHeight?90:0,this.scaleFactor=new e.Point(1,1),this.aspectRatio=0;var b=this;window.addEventListener("orientationchange",function(a){return b.checkOrientation(a)},!1),window.addEventListener("resize",function(a){return b.checkResize(a)},!1)},e.StageScaleMode.EXACT_FIT=0,e.StageScaleMode.NO_SCALE=1,e.StageScaleMode.SHOW_ALL=2,e.StageScaleMode.prototype={startFullScreen:function(){if(!this.isFullScreen){var a=this.game.canvas;a.requestFullScreen?a.requestFullScreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullScreen&&a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT),this.game.stage.canvas.style.width="100%",this.game.stage.canvas.style.height="100%"}},stopFullScreen:function(){document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()},checkOrientationState:function(){this.incorrectOrientation?(this.forceLandscape&&window.innerWidth>window.innerHeight||this.forcePortrait&&window.innerHeight>window.innerWidth)&&(this.game.paused=!1,this.incorrectOrientation=!1,this.refresh()):(this.forceLandscape&&window.innerWidthwindow.outerHeight?90:0,this.isLandscape?this.enterLandscape.dispatch(this.orientation,!0,!1):this.enterPortrait.dispatch(this.orientation,!1,!0),this.game.stage.scaleMode!==e.StageScaleMode.NO_SCALE&&this.refresh()},refresh:function(){var a=this;0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),null==this._check&&this.maxIterations>0&&(this._iterations=this.maxIterations,this._check=window.setInterval(function(){return a.setScreenSize()},10),this.setScreenSize())},setScreenSize:function(a){"undefined"==typeof a&&(a=!1),0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),this._iterations--,(a||window.innerHeight>this._startHeight||this._iterations<0)&&(document.documentElement.style.minHeight=window.innerHeight+"px",1==this.incorrectOrientation?this.setMaximum():this.game.stage.scaleMode==e.StageScaleMode.EXACT_FIT?this.setExactFit():this.game.stage.scaleMode==e.StageScaleMode.SHOW_ALL&&this.setShowAll(),this.setSize(),clearInterval(this._check),this._check=null)},setSize:function(){0==this.incorrectOrientation&&(this.maxWidth&&this.width>this.maxWidth&&(this.width=this.maxWidth),this.maxHeight&&this.height>this.maxHeight&&(this.height=this.maxHeight),this.minWidth&&this.widththis.maxWidth?this.maxWidth:a,this.height=this.maxHeight&&b>this.maxHeight?this.maxHeight:b,console.log("setExactFit",this.width,this.height,this.game.stage.offset) +}},Object.defineProperty(e.StageScaleMode.prototype,"isFullScreen",{get:function(){return null===document.fullscreenElement||null===document.mozFullScreenElement||null===document.webkitFullscreenElement?!1:!0}}),Object.defineProperty(e.StageScaleMode.prototype,"isPortrait",{get:function(){return 0==this.orientation||180==this.orientation}}),Object.defineProperty(e.StageScaleMode.prototype,"isLandscape",{get:function(){return 90===this.orientation||-90===this.orientation}}),e.Device=function(){this.patchAndroidClearRectBug=!1,this.desktop=!1,this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.touch=!1,this.mspointer=!1,this.css3D=!1,this.pointerLock=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkCSS3D(),this._checkDevice(),this._checkFeatures(),this._checkOS()},e.Device.prototype={_checkOS:function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows/.test(a)&&(this.windows=!0),(this.windows||this.macOS||this.linux)&&(this.desktop=!0)},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.webGL=function(){try{var a=document.createElement("canvas");return!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}(),this.webGL=null===this.webGL?!1:!0,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled)&&(this.touch=!0),window.navigator.msPointerEnabled&&(this.mspointer=!0),this.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document},_checkBrowser:function(){var a=navigator.userAgent;/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},_checkAudio:function(){this.audioData=!!window.Audio,this.webAudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")&&(this.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(this.webm=!0))}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad")},_checkCSS3D:function(){var a,b=document.createElement("p"),c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(b,null);for(var d in c)void 0!==b.style[d]&&(b.style[d]="translate3d(1px,1px,1px)",a=window.getComputedStyle(b).getPropertyValue(c[d]));document.body.removeChild(b),this.css3D=void 0!==a&&a.length>0&&"none"!==a},canPlayAudio:function(a){return"mp3"==a&&this.mp3?!0:"ogg"==a&&(this.ogg||this.opus)?!0:"m4a"==a&&this.m4a?!0:"wav"==a&&this.wav?!0:"webm"==a&&this.webm?!0:!1},isConsoleOpen:function(){return window.console&&window.console.firebug?!0:window.console?(console.profile(),console.profileEnd(),console.clear&&console.clear(),console.profiles.length>0):!1}},e.RequestAnimationFrame=function(a){this.game=a,this._isSetTimeOut=!1,this.isRunning=!1;for(var b=["ms","moz","webkit","o"],c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(0|2097152*this.rnd.apply(this))},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(a,b))},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},uuid:function(){var a,b;for(b=a="";a++<36;b+=~a%5|4&3*a?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0,a.length)]},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)}},e.Math={PI2:2*Math.PI,fuzzyEqual:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),Math.abs(a-b)a},fuzzyGreaterThan:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),a>b-c},fuzzyCeil:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},shear:function(a){return a%1},snapTo:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},snapToFloor:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},snapToCeil:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},snapToInArray:function(a,b,c){if("undefined"==typeof c&&(c=!0),c&&b.sort(),a=f-a?f:e},roundTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},floorTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},ceilTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},interpolateFloat:function(a,b,c){return(b-a)*c+a},angleBetween:function(a,b,c,d){return Math.atan2(d-b,c-a)},normalizeAngle:function(a,b){"undefined"==typeof b&&(b=!0);var c=b?GameMath.PI:180;return this.wrap(a,c,-c)},nearestAngleBetween:function(a,b,c){"undefined"==typeof c&&(c=!0);var d=c?Math.PI:180;return a=this.normalizeAngle(a,c),b=this.normalizeAngle(b,c),-d/2>a&&b>d/2&&(a+=2*d),-d/2>b&&a>d/2&&(b+=2*d),b-a},interpolateAngles:function(a,b,c,d,e){return"undefined"==typeof d&&(d=!0),"undefined"==typeof e&&(e=null),a=this.normalizeAngle(a,d),b=this.normalizeAngleToAnother(b,a,d),"function"==typeof e?e(c,a,b-a,1):this.interpolateFloat(a,b,c)},chanceRoll:function(a){return"undefined"==typeof a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},numberArray:function(a,b){for(var c=[],d=a;b>=d;d++)c.push(d);return c},maxAdd:function(a,b,c){return a+=b,a>c&&(a=c),a},minSub:function(a,b,c){return a-=b,c>a&&(a=c),a},wrap:function(a,b,c){var d=c-b;if(0>=d)return 0;var e=(a-b)%d;return 0>e&&(e+=d),e+b},wrapValue:function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},randomSign:function(){return Math.random()>.5?1:-1},isOdd:function(a){return 1&a},isEven:function(a){return 1&a?!1:!0},max:function(){for(var a=1,b=0,c=arguments.length;c>a;a++)arguments[b]a;a++)arguments[a]=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},angleLimit:function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return 0>b?this.linear(a[0],a[1],d):b>1?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[e+1>c?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;d>=e;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},getRandom:function(a,b,c){if("undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),null!=a){var d=c;if((0==d||d>a.length-b)&&(d=a.length-b),d>0)return a[b+Math.floor(Math.random()*d)]}return null},floor:function(a){var b=0|a;return a>0?b:b!=a?b-1:b},ceil:function(a){var b=0|a;return a>0?b!=a?b+1:b:b},sinCosGenerator:function(a,b,c,d){"undefined"==typeof b&&(b=1),"undefined"==typeof c&&(c=1),"undefined"==typeof d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;a>j;j++)f-=e*g,e+=f*g,h[j]=f,i[j]=e;return{sin:i,cos:h}},shift:function(a){var b=a.shift();return a.push(b),b},shuffleArray:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceRounded:function(a,b,c,d){return Math.round(e.Math.distance(a,b,c,d))},clamp:function(a,b,c){return b>a?b:a>c?c:a},clampBottom:function(a,b){return b>a?b:a},within:function(a,b,c){return Math.abs(a-b)<=c},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*(3-2*a))},smootherstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*a*(a*(6*a-15)+10))},sign:function(a){return 0>a?-1:a>0?1:0},degToRad:function(){var a=Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}()},e.QuadTree=function(a,b,c,d,e,f,g,h){this.physicsManager=a,this.ID=a.quadTreeID,a.quadTreeID++,this.maxObjects=f||10,this.maxLevels=g||4,this.level=h||0,this.bounds={x:Math.round(b),y:Math.round(c),width:d,height:e,subWidth:Math.floor(d/2),subHeight:Math.floor(e/2),right:Math.round(b)+Math.floor(d/2),bottom:Math.round(c)+Math.floor(e/2)},this.objects=[],this.nodes=[]},e.QuadTree.prototype={split:function(){this.level++,this.nodes[0]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[1]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[2]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[3]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(a){var b,c=0;if(null!=this.nodes[0]&&(b=this.getIndex(a),-1!==b))return this.nodes[b].insert(a),void 0;if(this.objects.push(a),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.ythis.bounds.bottom&&(b=3)),b},retrieve:function(a){var b=this.objects;return a.body.quadTreeIndex=this.getIndex(a.body),a.body.quadTreeIDs.push(this.ID),this.nodes[0]&&(-1!==a.body.quadTreeIndex?b=b.concat(this.nodes[a.body.quadTreeIndex].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)))),b},clear:function(){this.objects=[];for(var a=0,b=this.nodes.length;b>a;a++)this.nodes[a]&&(this.nodes[a].clear(),delete this.nodes[a])}},e.Circle=function(a,b,c){a=a||0,b=b||0,c=c||0,this.x=a,this.y=b,this._diameter=c,this._radius=c>0?.5*c:0},e.Circle.prototype={circumference:function(){return 2*Math.PI*this._radius},setTo:function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},copyFrom:function(a){return this.setTo(a.x,a.y,a.diameter)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a[diameter]=this._diameter,a},distance:function(a,b){return"undefined"==typeof b&&(b=!1),b?e.Math.distanceRound(this.x,this.y,a.x,a.y):e.Math.distance(this.x,this.y,a.x,a.y)},clone:function(b){return"undefined"==typeof b&&(b=new e.Circle),b.setTo(a.x,a.y,a.diameter)},contains:function(a,b){return e.Circle.contains(this,a,b)},circumferencePoint:function(a,b,c){return e.Circle.circumferencePoint(this,a,b,c)},offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){a>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-a}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){athis.y?(this._radius=0,this._diameter=0):this.radius=this.y-a}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0==this._diameter},set:function(){this.setTo(0,0,0)}}),e.Circle.contains=function(a,b,c){if(b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom){var d=(a.x-b)*(a.x-b),e=(a.y-c)*(a.y-c);return d+e<=a.radius*a.radius}return!1},e.Circle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.diameter==b.diameter},e.Circle.intersects=function(a,b){return e.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},e.Circle.circumferencePoint=function(a,b,c,d){return"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=new e.Point),c===!0&&(b=e.Math.radToDeg(b)),d.x=a.x+a.radius*Math.cos(b),d.y=a.y+a.radius*Math.sin(b),d},e.Circle.intersectsRectangle=function(a,b){var c=Math.abs(a.x-b.x-b.halfWidth),d=b.halfWidth+a.radius;if(c>d)return!1;var e=Math.abs(a.y-b.y-b.halfHeight),f=b.halfHeight+a.radius;if(e>f)return!1;if(c<=b.halfWidth||e<=b.halfHeight)return!0;var g=c-b.halfWidth,h=e-b.halfHeight,i=g*g,j=h*h,k=a.radius*a.radius;return k>=i+j},e.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b},e.Point.prototype={copyFrom:function(a){return this.setTo(a.x,a.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(a,b){return this.x=a,this.y=b,this},add:function(a,b){return this.x+=a,this.y+=b,this},subtract:function(a,b){return this.x-=a,this.y-=b,this},multiply:function(a,b){return this.x*=a,this.y*=b,this},divide:function(a,b){return this.x/=a,this.y/=b,this},clampX:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=e.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this.y=e.Math.clamp(this.y,a,b),this},clone:function(a){return"undefined"==typeof a&&(a=new e.Point),a.setTo(this.x,this.y)},copyFrom:function(a){return this.setTo(a.x,a.y)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a},distance:function(a,b){return e.Point.distance(this,a,b)},equals:function(a){return a.x==this.x&&a.y==this.y},rotate:function(a,b,c,d,f){return e.Point.rotate(this,a,b,c,d,f)},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},e.Point.add=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x+b.x,c.y=a.y+b.y,c},e.Point.subtract=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x-b.x,c.y=a.y-b.y,c},e.Point.multiply=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x*b.x,c.y=a.y*b.y,c},e.Point.divide=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x/b.x,c.y=a.y/b.y,c},e.Point.equals=function(a,b){return a.x==b.x&&a.y==b.y},e.Point.distance=function(a,b,c){return"undefined"==typeof c&&(c=!1),c?e.Math.distanceRound(a.x,a.y,b.x,b.y):e.Math.distance(a.x,a.y,b.x,b.y)},e.Point.rotate=function(a,b,c,d,f,g){return f=f||!1,g=g||null,f&&(d=e.Math.radToDeg(d)),null===g&&(g=Math.sqrt((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y))),a.setTo(b+g*Math.cos(d),c+g*Math.sin(d))},e.Rectangle=function(a,b,c,d){a=a||0,b=b||0,c=c||0,d=d||0,this.x=a,this.y=b,this.width=c,this.height=d},e.Rectangle.prototype={offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},inflate:function(a,b){return e.Rectangle.inflate(this,a,b)},size:function(a){return e.Rectangle.size(this,a)},clone:function(a){return e.Rectangle.clone(this,a)},contains:function(a,b){return e.Rectangle.contains(this,a,b)},containsRect:function(a){return e.Rectangle.containsRect(this,a)},equals:function(a){return e.Rectangle.equals(this,a)},intersection:function(a){return e.Rectangle.intersection(this,a,output)},intersects:function(a,b){return e.Rectangle.intersects(this,a,b)},intersectsRaw:function(a,b,c,d,f){return e.Rectangle.intersectsRaw(this,a,b,c,d,f)},union:function(a,b){return e.Rectangle.union(this,a,b)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(a){this.width=a>=this.right?0:this.right-a,this.x=a}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(a){a>=this.bottom?(this.height=0,this.y=a):this.height=this.bottom-a}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(){this.setTo(0,0,0,0)}}),e.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},e.Rectangle.inflatePoint=function(a,b){return e.Rectangle.inflate(a,b.x,b.y)},e.Rectangle.size=function(a,b){return"undefined"==typeof b&&(b=new e.Point),b.setTo(a.width,a.height)},e.Rectangle.clone=function(a,b){return"undefined"==typeof b&&(b=new e.Rectangle),b.setTo(a.x,a.y,a.width,a.height)},e.Rectangle.contains=function(a,b,c){return b>=a.x&&b<=a.right&&c>=a.y&&c<=a.bottom},e.Rectangle.containsRaw=function(a,b,c,d,e,f){return e>=a&&a+c>=e&&f>=b&&b+d>=f},e.Rectangle.containsPoint=function(a,b){return e.Rectangle.contains(a,b.x,b.y)},e.Rectangle.containsRect=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.right<=b.right&&a.bottom<=b.bottom},e.Rectangle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.width==b.width&&a.height==b.height},e.Rectangle.intersection=function(a,b,c){return c=c||new e.Rectangle,e.Rectangle.intersects(a,b)&&(c.x=Math.max(a.x,b.x),c.y=Math.max(a.y,b.y),c.width=Math.min(a.right,b.right)-c.x,c.height=Math.min(a.bottom,b.bottom)-c.y),c},e.Rectangle.intersects=function(a,b){return a.xa.right+f||ca.bottom+f||e1){if(a&&a==this.decodeURI(e[0]))return this.decodeURI(e[1]);b[this.decodeURI(e[0])]=this.decodeURI(e[1])}}return b},decodeURI:function(a){return decodeURIComponent(a.replace(/\+/g," "))}},e.TweenManager=function(a){this.game=a,this._tweens=[],this._add=[],this.game.onPause.add(this.pauseAll,this),this.game.onResume.add(this.resumeAll,this)},e.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(a){this._add.push(a)},create:function(a){return new e.Tween(a,this.game)},remove:function(a){var b=this._tweens.indexOf(a);-1!==b&&(this._tweens[b].pendingDelete=!0)},update:function(){if(0===this._tweens.length&&0===this._add.length)return!1;for(var a=0,b=this._tweens.length;b>a;)this._tweens[a].update(this.game.time.now)?a++:(this._tweens.splice(a,1),b--);return this._add.length>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},pauseAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].pause()},resumeAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].resume()}},e.Tween=function(a,b){this._object=a,this.game=b,this._manager=this.game.tweens,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._yoyo=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=e.Easing.Linear.None,this._interpolationFunction=e.Math.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._pausedTime=0,this.pendingDelete=!1;for(var c in a)this._valuesStart[c]=parseFloat(a[c],10);this.onStart=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1},e.Tween.prototype={to:function(a,b,c,d,e,f,g){b=b||1e3,c=c||null,d=d||!1,e=e||0,f=f||0,g=g||!1;var h;return this._parent?(h=this._manager.create(this._object),this._lastChild.chain(h),this._lastChild=h):(h=this,this._parent=this,this._lastChild=this),h._repeat=f,h._duration=b,h._valuesEnd=a,null!==c&&(h._easingFunction=c),e>0&&(h._delayTime=e),h._yoyo=g,d?this.start():this},start:function(){if(null!==this.game&&null!==this._object){this._manager.add(this),this.onStart.dispatch(this._object),this.isRunning=!0,this._onStartCallbackFired=!1,this._startTime=this.game.time.now+this._delayTime;for(var a in this._valuesEnd){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]=this._object[a],this._valuesStart[a]instanceof Array==!1&&(this._valuesStart[a]*=1),this._valuesStartRepeat[a]=this._valuesStart[a]||0}return this}},stop:function(){return this._manager.remove(this),this.isRunning=!1,this},delay:function(a){return this._delayTime=a,this},repeat:function(a){return this._repeat=a,this},yoyo:function(a){return this._yoyo=a,this},easing:function(a){return this._easingFunction=a,this},interpolation:function(a){return this._interpolationFunction=a,this},chain:function(){return this._chainedTweens=arguments,this},loop:function(){return this._lastChild.chain(this),this},onStartCallback:function(a){return this._onStartCallback=a,this},onUpdateCallback:function(a){return this._onUpdateCallback=a,this},onCompleteCallback:function(a){return this._onCompleteCallback=a,this},pause:function(){this._paused=!0,this._pausedTime=this.game.time.now},resume:function(){this._paused=!1,this._startTime+=this.game.time.now-this._pausedTime},update:function(a){if(this.pendingDelete)return!1;if(this._paused||a1?1:c;var d=this._easingFunction(c);for(b in this._valuesEnd){var e=this._valuesStart[b]||0,f=this._valuesEnd[b];f instanceof Array?this._object[b]=this._interpolationFunction(f,d):("string"==typeof f&&(f=e+parseFloat(f,10)),"number"==typeof f&&(this._object[b]=e+(f-e)*d))}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._object,d),1==c){if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(b in this._valuesStartRepeat){if("string"==typeof this._valuesEnd[b]&&(this._valuesStartRepeat[b]=this._valuesStartRepeat[b]+parseFloat(this._valuesEnd[b],10)),this._yoyo){var g=this._valuesStartRepeat[b];this._valuesStartRepeat[b]=this._valuesEnd[b],this._valuesEnd[b]=g,this._reversed=!this._reversed}this._valuesStart[b]=this._valuesStartRepeat[b]}return this._startTime=a+this._delayTime,this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object),!0}this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object);for(var h=0,i=this._chainedTweens.length;i>h;h++)this._chainedTweens[h].start(a);return!1}return!0}},e.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*2*Math.PI/d)+1) +},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d):.5*c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-e.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*e.Easing.Bounce.In(2*a):.5*e.Easing.Bounce.Out(2*a-1)+.5}}},e.Time=function(a){this.game=a,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this.physicsElapsed=0,this.time=0,this.pausedTime=0,this.now=0,this.elapsed=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.frames=0,this.pauseDuration=0,this.timeToCall=0,this.lastTime=0,this.game.onPause.add(this.gamePaused,this),this.game.onResume.add(this.gameResumed,this),this._justResumed=!1},e.Time.prototype={totalElapsedSeconds:function(){return.001*(this.now-this._started)},update:function(a){this.now=a,this._justResumed&&(this.time=this.now,this._justResumed=!1),this.timeToCall=this.game.math.max(0,16-(a-this.lastTime)),this.elapsed=this.now-this.time,this.msMin=this.game.math.min(this.msMin,this.elapsed),this.msMax=this.game.math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=this.game.math.min(this.fpsMin,this.fps),this.fpsMax=this.game.math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0),this.time=this.now,this.lastTime=a+this.timeToCall,this.physicsElapsed=1*(this.elapsed/1e3),this.physicsElapsed>1&&(this.physicsElapsed=1),this.game.paused&&(this.pausedTime=this.now-this._pauseStarted)},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.pausedTime,this._justResumed=!0},elapsedSince:function(a){return this.now-a},elapsedSecondsSince:function(a){return.001*(this.now-a)},reset:function(){this._started=this.now}},e.AnimationManager=function(a){this.sprite=a,this.game=a.game,this.currentFrame=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(a){this._frameData=a,this.frame=0,this.isLoaded=!0},add:function(a,b,c,f,g){return null==this._frameData?(console.warn("No FrameData available for Phaser.Animation "+a),void 0):(c=c||60,"undefined"==typeof f&&(f=!1),"undefined"==typeof g&&(g=b&&"number"==typeof b[0]?!0:!1),null==this.sprite.events.onAnimationStart&&(this.sprite.events.onAnimationStart=new e.Signal,this.sprite.events.onAnimationComplete=new e.Signal,this.sprite.events.onAnimationLoop=new e.Signal),this._outputFrames.length=0,this._frameData.getFrameIndexes(b,g,this._outputFrames),this._anims[a]=new e.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,c,f),this.currentAnim=this._anims[a],this.currentFrame=this.currentAnim.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]),this._anims[a])},validateFrames:function(a,b){"undefined"==typeof b&&(b=!0);for(var c=0;cthis._frameData.total)return!1}else if(0==this._frameData.checkFrameName(a[c]))return!1;return!0},play:function(a,b,c,d){if(this._anims[a]){if(this.currentAnim!=this._anims[a])return this.currentAnim=this._anims[a],this.currentAnim.play(b,c,d);if(0==this.currentAnim.isPlaying)return this.currentAnim.play(b,c,d)}},stop:function(a,b){"undefined"==typeof b&&(b=!1),"string"==typeof a?this._anims[a]&&(this.currentAnim=this._anims[a],this.currentAnim.stop(b)):this.currentAnim&&this.currentAnim.stop(b)},update:function(){return this.updateIfVisible&&0==this.sprite.visible?!1:this.currentAnim&&1==this.currentAnim.update()?(this.currentFrame=this.currentAnim.currentFrame,this.sprite.currentFrame=this.currentFrame,!0):!1},refreshFrame:function(){this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])},destroy:function(){this._anims={},this._frameData=null,this._frameIndex=0,this.currentAnim=null,this.currentFrame=null}},Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData?this._frameData.total:-1}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this._frameIndex:void 0},set:function(a){"number"==typeof a&&this._frameData&&null!==this._frameData.getFrame(a)&&(this.currentFrame=this._frameData.getFrame(a),this._frameIndex=a,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(a){"string"==typeof a&&this._frameData&&null!==this._frameData.getFrameByName(a)?(this.currentFrame=this._frameData.getFrameByName(a),this._frameIndex=this.currentFrame.index,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])):console.warn("Cannot set frameName: "+a)}}),e.Animation=function(a,b,c,d,e,f,g){this.game=a,this._parent=b,this._frameData=d,this.name=c,this._frames=[],this._frames=this._frames.concat(e),this.delay=1e3/f,this.looped=g,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},e.Animation.prototype={play:function(a,b,c){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.looped=b),"undefined"!=typeof c&&(this.killOnComplete=c),this.isPlaying=!0,this.isFinished=!1,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.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events&&this._parent.events.onAnimationStart.dispatch(this._parent,this),this},restart:function(){this.isPlaying=!0,this.isFinished=!1,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:function(a){"undefined"==typeof a&&(a=!1),this.isPlaying=!1,this.isFinished=!0,a&&(this.currentFrame=this._frameData.getFrame(this._frames[0]))},update:function(){return this.isPaused?!1:1==this.isPlaying&&this.game.time.now>=this._timeNextFrame?(this._frameSkip=1,this._frameDiff=this.game.time.now-this._timeNextFrame,this._timeLastFrame=this.game.time.now,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.now+(this.delay-this._frameDiff),this._frameIndex+=this._frameSkip,this._frameIndex>=this._frames.length?this.looped?(this._frameIndex%=this._frames.length,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events.onAnimationLoop.dispatch(this._parent,this)):this.onComplete():(this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setTexture(d.TextureCache[this.currentFrame.uuid])),!0):!1},destroy:function(){this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1},onComplete:function(){this.isPlaying=!1,this.isFinished=!0,this._parent.events&&this._parent.events.onAnimationComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){this.isPaused=a,a?this._pauseStartTime=this.game.time.now:this.isPlaying&&(this._timeNextFrame=this.game.time.now+this.delay)}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(a),null!==this.currentFrame&&(this._frameIndex=a,this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),e.Animation.generateFrameNames=function(a,b,c,d,f){"undefined"==typeof d&&(d="");var g=[],h="";if(c>b)for(var i=b;c>=i;i++)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);else for(var i=b;i>=c;i--)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);return g},e.Frame=function(a,b,c,d,f,g,h){this.index=a,this.x=b,this.y=c,this.width=d,this.height=f,this.name=g,this.uuid=h,this.centerX=Math.floor(d/2),this.centerY=Math.floor(f/2),this.distance=e.Math.distance(0,0,d,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=d,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0},e.Frame.prototype={setTrim:function(a,b,c,d,e,f,g){this.trimmed=a,a&&(this.width=b,this.height=c,this.sourceSizeW=b,this.sourceSizeH=c,this.centerX=Math.floor(b/2),this.centerY=Math.floor(c/2),this.spriteSourceSizeX=d,this.spriteSourceSizeY=e,this.spriteSourceSizeW=f,this.spriteSourceSizeH=g)}},e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(a){return a.index=this._frames.length,this._frames.push(a),""!==a.name&&(this._frameNames[a.name]=a.index),a},getFrame:function(a){return this._frames.length>a?this._frames[a]:null},getFrameByName:function(a){return"number"==typeof this._frameNames[a]?this._frames[this._frameNames[a]]:null},checkFrameName:function(a){return null==this._frameNames[a]?!1:!0},getFrameRange:function(a,b,c){"undefined"==typeof c&&(c=[]);for(var d=a;b>=d;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0;dd;d++)b?c.push(this.getFrame(a[d])):c.push(this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0,e=this._frames.length;e>d;d++)c.push(this._frames[d].index);else for(var d=0,e=a.length;e>d;d++)b?c.push(a[d]):this.getFrameByName(a[d])&&c.push(this.getFrameByName(a[d]).index);return c}},Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(a,b,c,f,g){var h=a.cache.getImage(b);if(null==h)return null;var i=h.width,j=h.height;0>=c&&(c=Math.floor(-i/Math.min(-1,c))),0>=f&&(f=Math.floor(-j/Math.min(-1,f)));var k=Math.round(i/c),l=Math.round(j/f),m=k*l;if(-1!==g&&(m=g),0==i||0==j||c>i||f>j||0===m)return console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"),null;for(var n=new e.FrameData,o=0,p=0,q=0;m>q;q++){var r=a.rnd.uuid();n.addFrame(new e.Frame(q,o,p,c,f,"",r)),d.TextureCache[r]=new d.Texture(d.BaseTextureCache[b],{x:o,y:p,width:c,height:f}),o+=c,o===i&&(o=0,p+=f)}return n},JSONData:function(a,b,c){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),console.log(b),void 0;for(var f,g=new e.FrameData,h=b.frames,i=0;i tag"),void 0;for(var f,g=new e.FrameData,h=b.getElementsByTagName("SubTexture"),i=0;i0?(this._progressChunk=100/this._keys.length,this.loadFile()):(this.progress=100,this.hasLoaded=!0,this.onLoadComplete.dispatch()))},loadFile:function(){var a=this._fileList[this._keys.shift()],b=this;switch(a.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tileset":a.data=new Image,a.data.name=a.key,a.data.onload=function(){return b.fileComplete(a.key)},a.data.onerror=function(){return b.fileError(a.key)},a.data.crossOrigin=this.crossOrigin,a.data.src=this.baseURL+a.url;break;case"audio":a.url=this.getAudioURL(a.url),null!==a.url?this.game.sound.usingWebAudio?(this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="arraybuffer",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()):this.game.sound.usingAudioTag&&(this.game.sound.touchLocked?(a.data=new Audio,a.data.name=a.key,a.data.preload="auto",a.data.src=this.baseURL+a.url,this.fileComplete(a.key)):(a.data=new Audio,a.data.name=a.key,a.data.onerror=function(){return b.fileError(a.key)},a.data.preload="auto",a.data.src=this.baseURL+a.url,a.data.addEventListener("canplaythrough",e.GAMES[this.game.id].load.fileComplete(a.key),!1),a.data.load())):this.fileError(a.key);break;case"tilemap":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",a.format==e.Tilemap.TILED_JSON?this._xhr.onload=function(){return b.jsonLoadComplete(a.key)}:a.format==e.Tilemap.CSV&&(this._xhr.onload=function(){return b.csvLoadComplete(a.key)}),this._xhr.onerror=function(){return b.dataLoadError(a.key)},this._xhr.send();break;case"text":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()}},getAudioURL:function(a){for(var b,c=0;c100&&(this.progress=100),null!==this.preloadSprite&&(0==this.preloadSprite.direction?this.preloadSprite.crop.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.crop.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite.crop=this.preloadSprite.crop),this.onFileComplete.dispatch(this.progress,a,b,this.queueSize-this._keys.length,this.queueSize),this._keys.length>0?this.loadFile():(this.hasLoaded=!0,this.isLoading=!1,this.removeAll(),this.onLoadComplete.dispatch())}},e.LoaderParser={bitmapFont:function(a,b,c){if(!b.getElementsByTagName("font"))return console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"),void 0;var e=d.TextureCache[c],f={},g=b.getElementsByTagName("info")[0],h=b.getElementsByTagName("common")[0];f.font=g.attributes.getNamedItem("face").nodeValue,f.size=parseInt(g.attributes.getNamedItem("size").nodeValue,10),f.lineHeight=parseInt(h.attributes.getNamedItem("lineHeight").nodeValue,10),f.chars={};for(var i=b.getElementsByTagName("char"),j=0;j=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),""==this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.now):this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop():this.loop?(this.onLoop.dispatch(this),this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))},play:function(a,b,c,d,e){if(a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),"undefined"==typeof e&&(e=!0),1!=this.isPlaying||0!=e||0!=this.override){if(this.isPlaying&&this.override&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.currentMarker=a,""!==a){if(!this.markers[a])return console.warn("Phaser.Sound.play: audio marker "+a+" doesn't exist"),void 0;this.position=this.markers[a].start,this.volume=this.markers[a].volume,this.loop=this.markers[a].loop,this.duration=this.markers[a].duration,this.durationMS=this.markers[a].durationMS,this._tempMarker=a,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else this.position=b,this.volume=c,this.loop=d,this.duration=0,this.durationMS=0,this._tempMarker=a,this._tempPosition=b,this._tempVolume=c,this._tempLoop=d;this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(null==this._buffer&&(this._buffer=this.game.cache.getSoundData(this.key)),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),this.totalDuration=this._sound.buffer.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this.loop&&""==a&&(this._sound.loop=!0),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&0==this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&4==this._sound.readyState?(this._sound.play(),this.totalDuration=this._sound.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._sound.volume=this._muted?0:this._volume,this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0}},restart:function(a,b,c,d){a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),this.play(a,b,c,d,!0)},pause:function(){this.isPlaying&&this._sound&&(this.stop(),this.isPlaying=!1,this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.now,this.onPause.dispatch(this))},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var a=this.position+this.pausedPosition/1e3;this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,a,this.duration):this._sound.start(0,a,this.duration)}else this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.now-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){this.isPlaying&&this._sound&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.isPlaying=!1;var a=this.currentMarker;this.currentMarker="",this.onStop.dispatch(this,a)}},Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted},set:function(a){a=a||null,a?(this._muted=!0,this.usingWebAudio?(this._muteVolume=this.gainNode.gain.value,this.gainNode.gain.value=0):this.usingAudioTag&&this._sound&&(this._muteVolume=this._sound.volume,this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this)}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(a){this.usingWebAudio?(this._volume=a,this.gainNode.gain.value=a):this.usingAudioTag&&this._sound&&a>=0&&1>=a&&(this._volume=a,this._sound.volume=a)}}),e.SoundManager=function(a){this.game=a,this.onSoundDecode=new e.Signal,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this.context=null,this.usingWebAudio=!0,this.usingAudioTag=!1,this.noAudio=!1,this.touchLocked=!1,this.channels=32},e.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&0==this.game.device.webAudio&&(this.channels=1),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=!0):this.touchLocked=!1,window.PhaserGlobal){if(1==window.PhaserGlobal.disableAudio)return this.usingWebAudio=!1,this.noAudio=!0,void 0;if(1==window.PhaserGlobal.disableWebAudio)return this.usingWebAudio=!1,this.usingAudioTag=!0,this.noAudio=!1,void 0}window.AudioContext?this.context=new window.AudioContext:window.webkitAudioContext?this.context=new window.webkitAudioContext:window.Audio?(this.usingWebAudio=!1,this.usingAudioTag=!0):(this.usingWebAudio=!1,this.noAudio=!0),null!==this.context&&(this.masterGain="undefined"==typeof this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination))},unlock:function(){if(0!=this.touchLocked)if(0==this.game.device.webAudio||window.PhaserGlobal&&1==window.PhaserGlobal.disableWebAudio)this.touchLocked=!1,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;else{var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),this._unlockSource.noteOn(0)}},stopAll:function(){for(var a=0;a255)return e.Color.getColor(255,255,255);if(a>b)return e.Color.getColor(255,255,255);var d=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return e.Color.getColor32(c,d,f,g)},getRGB:function(a){return{alpha:a>>>24,red:255&a>>16,green:255&a>>8,blue:255&a}},getWebRGB:function(a){var b=(a>>>24)/255,c=255&a>>16,d=255&a>>8,e=255&a;return"rgba("+c.toString()+","+d.toString()+","+e.toString()+","+b.toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return 255&a>>16},getGreen:function(a){return 255&a>>8},getBlue:function(a){return 255&a}},e.Physics={},e.Physics.Arcade=function(a){this.game=a,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,a.world.width,a.world.height),this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTreeID=0,this._bounds1=new e.Rectangle,this._bounds2=new e.Rectangle,this._overlap=0,this._maxOverlap=0,this._velocity1=0,this._velocity2=0,this._newVelocity1=0,this._newVelocity2=0,this._average=0,this._mapData=[],this._mapTiles=0,this._result=!1,this._total=0,this._angle=0,this._dx=0,this._dy=0},e.Physics.Arcade.prototype={updateMotion:function(a){this._velocityDelta=(this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity)/2,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,this._velocityDelta=(this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x)-a.velocity.x)/2,a.velocity.x+=this._velocityDelta,a.x+=a.velocity.x*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,this._velocityDelta=(this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)-a.velocity.y)/2,a.velocity.y+=this._velocityDelta,a.y+=a.velocity.y*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta},computeVelocity:function(a,b,c,d,e,f){return f=f||1e4,1==a&&b.allowGravity?c+=this.gravity.x+b.gravity.x:2==a&&b.allowGravity&&(c+=this.gravity.y+b.gravity.y),0!==d?c+=d*this.game.time.physicsElapsed:0!==e&&(this._drag=e*this.game.time.physicsElapsed,c-this._drag>0?c-=this._drag:c+this._drag<0?c+=this._drag:c=0),c>f?c=f:-f>c&&(c=-f),c},preUpdate:function(){this.quadTree.clear(),this.quadTreeID=0,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},overlap:function(a,b){return a&&b&&a.exists&&b.exists?e.Rectangle.intersects(a.body,b.body):!1},collide:function(a,b,c,d,f){return c=c||null,d=d||null,f=f||c,this._result=!1,this._total=0,a&&b&&a.exists&&b.exists&&(a.type==e.SPRITE?b.type==e.SPRITE?this.collideSpriteVsSprite(a,b,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideSpriteVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,c,d,f):a.type==e.GROUP?b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f):a.type==e.TILEMAPLAYER?b.type==e.SPRITE?this.collideSpriteVsTilemapLayer(b,a,c,d,f):(b.type==e.GROUP||b.type==e.EMITTER)&&this.collideGroupVsTilemapLayer(b,a,c,d,f):a.type==e.EMITTER&&(b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f))),this._total>0},collideSpriteVsTilemapLayer:function(a,b,c,d,e){if(this._mapData=b.getTiles(a.body.x,a.body.y,a.body.width,a.body.height,!0),this._mapData.length>1)for(var f=1;ff;f++)this._potentials[f].sprite.group==b&&(this.separate(a.body,this._potentials[f]),this._result&&d&&(this._result=d.call(e,a,this._potentials[f].sprite)),this._result&&(this._total++,c&&c.call(e,a,this._potentials[f].sprite)))}},collideGroupVsGroup:function(a,b,c,d,e){if(0!=a.length&&0!=b.length&&a._container.first._iNext){var f=a._container.first._iNext;do f.exists&&this.collideSpriteVsGroup(f,b,c,d,e),f=f._iNext;while(f!=a._container.last._iNext)}},separate:function(a,b){this._result=this.separateX(a,b)||this.separateY(a,b)},separateX:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS,0==a.deltaX()&&0==b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(this._overlap=a.x+a.width-b.x,this._overlap>this._maxOverlap||0==a.allowCollision.right||0==b.allowCollision.left?this._overlap=0:(a.touching.right=!0,b.touching.left=!0)):a.deltaX()this._maxOverlap||0==a.allowCollision.left||0==b.allowCollision.right?this._overlap=0:(a.touching.left=!0,b.touching.right=!0)),0!=this._overlap)?(a.overlapX=this._overlap,b.overlapX=this._overlap,a.customSeparateX||b.customSeparateX?!0:(this._velocity1=a.velocity.x,this._velocity2=b.velocity.x,a.immovable||b.immovable?a.immovable?b.immovable||(b.x+=this._overlap,b.velocity.x=this._velocity1-this._velocity2*b.bounce.x):(a.x=a.x-this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x=a.x-this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.x=this._average+this._newVelocity1*a.bounce.x,b.velocity.x=this._average+this._newVelocity2*b.bounce.x),!0)):!1)},separateY:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS,0==a.deltaY()&&0==b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(this._overlap=a.y+a.height-b.y,this._overlap>this._maxOverlap||0==a.allowCollision.down||0==b.allowCollision.up?this._overlap=0:(a.touching.down=!0,b.touching.up=!0)):a.deltaY()this._maxOverlap||0==a.allowCollision.up||0==b.allowCollision.down?this._overlap=0:(a.touching.up=!0,b.touching.down=!0)),0!=this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y,a.sprite.active&&a.moves&&a.deltaY()b.deltaY()&&(a.x+=b.x-b.lastX)):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateTile:function(a,b){this._result=this.separateTileX(a,b,!0)||this.separateTileY(a,b,!0)},separateTileX:function(a,b,c){return a.immovable||0==a.deltaX()||0==e.Rectangle.intersects(a.hullX,b)?!1:(this._overlap=0,this._maxOverlap=a.deltaAbsX()+this.OVERLAP_BIAS,a.deltaX()<0?(this._overlap=b.right-a.hullX.x,this._overlap>this._maxOverlap||0==a.allowCollision.left||0==b.tile.collideRight?this._overlap=0:a.touching.left=!0):(this._overlap=a.hullX.right-b.x,this._overlap>this._maxOverlap||0==a.allowCollision.right||0==b.tile.collideLeft?this._overlap=0:a.touching.right=!0),0!=this._overlap?(c&&(a.x=a.deltaX()<0?a.x+this._overlap:a.x-this._overlap,a.velocity.x=0==a.bounce.x?0:-a.velocity.x*a.bounce.x,a.updateHulls()),!0):!1)},separateTileY:function(a,b,c){return a.immovable||0==a.deltaY()||0==e.Rectangle.intersects(a.hullY,b)?!1:(this._overlap=0,this._maxOverlap=a.deltaAbsY()+this.OVERLAP_BIAS,a.deltaY()<0?(this._overlap=b.bottom-a.hullY.y,this._overlap>this._maxOverlap||0==a.allowCollision.up||0==b.tile.collideDown?this._overlap=0:a.touching.up=!0):(this._overlap=a.hullY.bottom-b.y,this._overlap>this._maxOverlap||0==a.allowCollision.down||0==b.tile.collideUp?this._overlap=0:a.touching.down=!0),0!=this._overlap?(c&&(a.y=a.deltaY()<0?a.y+this._overlap:a.y-this._overlap,a.velocity.y=0==a.bounce.y?0:-a.velocity.y*a.bounce.y,a.updateHulls()),!0):!1)},moveToObject:function(a,b,c,d){return c=c||60,d=d||0,this._angle=Math.atan2(b.y-a.y,b.x-a.x),d>0&&(c=this.distanceBetween(a,b)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*c,a.body.velocity.y=Math.sin(this._angle)*c,this._angle},moveToPointer:function(a,b,c,d){return b=b||60,c=c||this.game.input.activePointer,d=d||0,this._angle=this.angleToPointer(a,c),d>0&&(b=this.distanceToPointer(a,c)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*b,a.body.velocity.y=Math.sin(this._angle)*b,this._angle},moveToXY:function(a,b,c,d,e){return d=d||60,e=e||0,this._angle=Math.atan2(c-a.y,b-a.x),e>0&&(d=this.distanceToXY(a,b,c)/(e/1e3)),a.body.velocity.x=Math.cos(this._angle)*d,a.body.velocity.y=Math.sin(this._angle)*d,this._angle +},velocityFromAngle:function(a,b,c){return b=b||60,c=c||new e.Point,c.setTo(Math.cos(this.game.math.degToRad(a))*b,Math.sin(this.game.math.degToRad(a))*b)},velocityFromRotation:function(a,b,c){return b=b||60,c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,c){return b=b||60,c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerateToObject:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleBetween(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToPointer:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof b&&(b=this.game.input.activePointer),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleToPointer(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToXY:function(a,b,c,d,e,f){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=1e3),"undefined"==typeof f&&(f=1e3),this._angle=this.angleToXY(a,b,c),a.body.acceleration.setTo(Math.cos(this._angle)*d,Math.sin(this._angle)*d),a.body.maxVelocity.setTo(e,f),this._angle},distanceBetween:function(a,b){return this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXY:function(a,b,c){return this._dx=a.x-b,this._dy=a.y-c,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=a.worldX-b.x,this._dy=a.worldY-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},angleBetween:function(a,b){return this._dx=b.x-a.x,this._dy=b.y-a.y,Math.atan2(this._dy,this._dx)},angleToXY:function(a,b,c){return this._dx=b-a.x,this._dy=c-a.y,Math.atan2(this._dy,this._dx)},angleToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=b.worldX-a.x,this._dy=b.worldY-a.y,Math.atan2(this._dy,this._dx)}},e.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.offset=new e.Point,this.x=a.x,this.y=a.y,this.preX=a.x,this.preY=a.y,this.preRotation=a.angle,this.screenX=a.x,this.screenY=a.y,this.sourceWidth=a.currentFrame.sourceSizeW,this.sourceHeight=a.currentFrame.sourceSizeH,this.width=a.currentFrame.sourceSizeW,this.height=a.currentFrame.sourceSizeH,this.halfWidth=Math.floor(a.currentFrame.sourceSizeW/2),this.halfHeight=Math.floor(a.currentFrame.sourceSizeH/2),this._sx=a.scale.x,this._sy=a.scale.y,this.velocity=new e.Point,this.acceleration=new e.Point,this.drag=new e.Point,this.gravity=new e.Point,this.bounce=new e.Point,this.maxVelocity=new e.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.skipQuadTree=!1,this.quadTreeIDs=[],this.quadTreeIndex=-1,this.allowCollision={none:!1,any:!0,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.rotation=0,this.allowRotation=!0,this.allowGravity=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.hullX=new e.Rectangle,this.hullY=new e.Rectangle,this.embedded=!1,this.collideWorldBounds=!1},e.Physics.Arcade.Body.prototype={updateBounds:function(a,b,c,d){(c!=this._sx||d!=this._sy)&&(this.width=this.sourceWidth*c,this.height=this.sourceHeight*d,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this._sx=c,this._sy=d)},preUpdate:function(){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.embedded=!1,this.screenX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.screenY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.moves&&(this.game.physics.updateMotion(this),this.collideWorldBounds&&this.checkWorldBounds(),this.updateHulls()),0==this.skipQuadTree&&0==this.allowCollision.none&&this.sprite.visible&&this.sprite.alive&&(this.quadTreeIDs=[],this.quadTreeIndex=-1,this.game.physics.quadTree.insert(this))},postUpdate:function(){0==this.deltaX()&&0==this.deltaY()&&0==this.sprite.deltaX()&&0==this.sprite.deltaY(),this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),this.sprite.x+=this.deltaX(),this.sprite.y+=this.deltaY(),this.allowRotation&&(this.sprite.angle+=this.deltaZ())},updateHulls:function(){this.hullX.setTo(this.x,this.preY,this.width,this.height),this.hullY.setTo(this.preX,this.y,this.width,this.height)},checkWorldBounds:function(){this.xthis.game.world.bounds.right&&(this.x=this.game.world.bounds.right-this.width,this.velocity.x*=-this.bounce.x),this.ythis.game.world.bounds.bottom&&(this.y=this.game.world.bounds.bottom-this.height,this.velocity.y*=-this.bounce.y)},setSize:function(a,b,c,d){c=c||this.offset.x,d=d||this.offset.y,this.sourceWidth=a,this.sourceHeight=b,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(c,d)},reset:function(){this.velocity.setTo(0,0),this.acceleration.setTo(0,0),this.angularVelocity=0,this.angularAcceleration=0,this.preX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.x-this.preX},deltaY:function(){return this.y-this.preY},deltaZ:function(){return this.rotation-this.preRotation}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),e.Particles=function(){this.emitters={},this.ID=0},e.Particles.prototype={add:function(a){return this.emitters[a.name]=a,a},remove:function(a){delete this.emitters[a.name]},update:function(){for(var a in this.emitters)this.emitters[a].exists&&this.emitters[a].update()}},e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(a,b,c,d){this.maxParticles=d||50,e.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=e.EMITTER,this.x=0,this.y=0,this.width=1,this.height=1,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.minRotation=-360,this.maxRotation=360,this.gravity=2,this.particleClass=null,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this._quantity=0,this._timer=0,this._counter=0,this._explode=!0,this.on=!1,this.exists=!0,this.emitX=b,this.emitY=c},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.Particles.Arcade.Emitter.prototype.update=function(){if(this.on)if(this._explode){this._counter=0;do this.emitParticle(),this._counter++;while(this._counter=this._timer&&(this.emitParticle(),this._counter++,this._quantity>0&&this._counter>=this._quantity&&(this.on=!1),this._timer=this.game.time.now+this.frequency)},e.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,d,f){"undefined"==typeof b&&(b=0),c=c||this.maxParticles,d=d||0,"undefined"==typeof f&&(f=!1);for(var g,h=0,i=a,j=0;c>h;)null==this.particleClass&&("object"==typeof a&&(i=this.game.rnd.pick(a)),"object"==typeof b&&(j=this.game.rnd.pick(b)),g=new e.Sprite(this.game,0,0,i,j)),d>0?(g.body.allowCollision.any=!0,g.body.allowCollision.none=!1):g.body.allowCollision.none=!0,g.body.collideWorldBounds=f,g.exists=!1,g.visible=!1,g.anchor.setTo(.5,.5),this.add(g),h++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){this.on=!1,this.alive=!1,this.exists=!1},e.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=!0,this.exists=!0},e.Particles.Arcade.Emitter.prototype.start=function(a,b,c,d){"boolean"!=typeof a&&(a=!0),b=b||0,c=c||250,d=d||0,this.revive(),this.visible=!0,this.on=!0,this._explode=a,this.lifespan=b,this.frequency=c,a?this._quantity=d:this._quantity+=d,this._counter=0,this._timer=this.game.time.now+c},e.Particles.Arcade.Emitter.prototype.emitParticle=function(){var a=this.getFirstExists(!1);if(null!=a){if(this.width>1||this.height>1?a.reset(this.game.rnd.integerInRange(this.left,this.right),this.game.rnd.integerInRange(this.top,this.bottom)):a.reset(this.emitX,this.emitY),a.lifespan=this.lifespan,a.body.bounce.setTo(this.bounce.x,this.bounce.y),a.body.velocity.x=this.minParticleSpeed.x!=this.maxParticleSpeed.x?this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x):this.minParticleSpeed.x,a.body.velocity.y=this.minParticleSpeed.y!=this.maxParticleSpeed.y?this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y):this.minParticleSpeed.y,a.body.gravity.y=this.gravity,a.body.angularVelocity=this.minRotation!=this.maxRotation?this.game.rnd.integerInRange(this.minRotation,this.maxRotation):this.minRotation,1!==this.minParticleScale||1!==this.maxParticleScale){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);a.scale.setTo(b,b)}a.body.drag.x=this.particleDrag.x,a.body.drag.y=this.particleDrag.y,a.body.angularDrag=this.angularDrag}},e.Particles.Arcade.Emitter.prototype.setSize=function(a,b){this.width=a,this.height=b},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b},e.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b},e.Particles.Arcade.Emitter.prototype.at=function(a){this.emitX=a.center.x,this.emitY=a.center.y},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.height/2)}}),e.Tile=function(a,b,c,d,e,f){this.tileset=a,this.index=b,this.width=e,this.height=f,this.x=c,this.y=d,this.mass=1,this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.separateX=!0,this.separateY=!0,this.collisionCallback=null,this.collisionCallbackContext=this},e.Tile.prototype={setCollisionCallback:function(a,b){this.collisionCallbackContext=b,this.collisionCallback=a},destroy:function(){this.tileset=null},setCollision:function(a,b,c,d){this.collideLeft=a,this.collideRight=b,this.collideUp=c,this.collideDown=d,this.collideNone=a||b||c||d?!1:!0},resetCollision:function(){this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1}},Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.y+this.height}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.x+this.width}}),e.Tilemap=function(a,b){this.game=a,this.layers,"string"==typeof b?(this.key=b,this.layers=a.cache.getTilemapData(b).layers,this.calculateIndexes()):this.layers=[],this.currentLayer=0,this.debugMap=[],this.dirty=!1,this._results=[],this._tempA=0,this._tempB=0},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.prototype={create:function(a,b,c){for(var d=[],f=0;c>f;f++){d[f]=[];for(var g=0;b>g;g++)d[f][g]=0}this.currentLayer=this.layers.push({name:a,width:b,height:c,alpha:1,visible:!0,tileMargin:0,tileSpacing:0,format:e.Tilemap.CSV,data:d,indexes:[]}),this.dirty=!0},calculateIndexes:function(){for(var a=0;a=0&&b=0&&c=0&&a=0&&b=0&&a=0&&b=0&&b=0&&ca&&(a=0),0>b&&(b=0),c>this.layers[e].width&&(c=this.layers[e].width),d>this.layers[e].height&&(d=this.layers[e].height),this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,layer:e});for(var f=b;b+d>f;f++)for(var g=a;a+c>g;g++)this._results.push({x:g,y:f,index:this.layers[e].data[f][g]});return this._results},paste:function(a,b,c,d){if("undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=0),"undefined"==typeof d&&(d=this.currentLayer),c&&!(c.length<2)){for(var e=c[1].x-a,f=c[1].y-b,g=1;g1?this.debugMap[this.layers[this.currentLayer].data[c][d]]?b.push("background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]):b.push("background: #ffffff"):b.push("background: rgb(0, 0, 0)");a+="\n"}b[0]=a,console.log.apply(console,b)},destroy:function(){this.removeAllLayers(),this.game=null}},e.TilemapLayer=function(a,b,c,f,g,h,i,j){this.game=a,this.canvas=e.Canvas.create(f,g),this.context=this.canvas.getContext("2d"),this.baseTexture=new d.BaseTexture(this.canvas),this.texture=new d.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,f,g,"tilemaplayer",a.rnd.uuid()),e.Sprite.call(this,this.game,b,c,this.texture,this.textureFrame),this.type=e.TILEMAPLAYER,this.fixedToCamera=!0,this.tileset=null,this.tileWidth=0,this.tileHeight=0,this.tileMargin=0,this.tileSpacing=0,this.widthInPixels=0,this.heightInPixels=0,this.renderWidth=f,this.renderHeight=g,this._ga=1,this._dx=0,this._dy=0,this._dw=0,this._dh=0,this._tx=0,this._ty=0,this._results=[],this._tw=0,this._th=0,this._tl=0,this._maxX=0,this._maxY=0,this._startX=0,this._startY=0,this.tilemap=null,this.layer=null,this.index=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this.dirty=!0,(h instanceof e.Tileset||"string"==typeof h)&&this.updateTileset(h),i instanceof e.Tilemap&&this.updateMapData(i,j)},e.TilemapLayer.prototype=e.Utils.extend(!0,e.Sprite.prototype,d.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.update=function(){this.scrollX=this.game.camera.x,this.scrollY=this.game.camera.y,this.render()},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.widthInPixels,this.heightInPixels)},e.TilemapLayer.prototype.updateTileset=function(a){if(a instanceof e.Tileset)this.tileset=a;else{if("string"!=typeof a)return;this.tileset=this.game.cache.getTileset("tiles")}this.tileWidth=this.tileset.tileWidth,this.tileHeight=this.tileset.tileHeight,this.tileMargin=this.tileset.tileMargin,this.tileSpacing=this.tileset.tileSpacing,this.updateMax()},e.TilemapLayer.prototype.updateMapData=function(a,b){"undefined"==typeof b&&(b=0),a instanceof e.Tilemap&&(this.tilemap=a,this.layer=this.tilemap.layers[b],this.index=b,this.updateMax(),this.tilemap.dirty=!0)},e.TilemapLayer.prototype.getTileX=function(a){var b=this.tileWidth*this.scale.x;return this.game.math.snapToFloor(a,b)/b},e.TilemapLayer.prototype.getTileY=function(a){var b=this.tileHeight*this.scale.y;return this.game.math.snapToFloor(a,b)/b},e.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},e.TilemapLayer.prototype.getTiles=function(a,b,c,d,e){if(null!==this.tilemap){"undefined"==typeof e&&(e=!1),0>a&&(a=0),0>b&&(b=0),c>this.widthInPixels&&(c=this.widthInPixels),d>this.heightInPixels&&(d=this.heightInPixels);var f=this.tileWidth*this.scale.x,g=this.tileHeight*this.scale.y;this._tx=this.game.math.snapToFloor(a,f)/f,this._ty=this.game.math.snapToFloor(b,g)/g,this._tw=(this.game.math.snapToCeil(c,f)+f)/f,this._th=(this.game.math.snapToCeil(d,g)+g)/g,this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,tx:this._tx,ty:this._ty,tw:this._tw,th:this._th});for(var h=0,i=null,j=0,k=0,l=this._ty;lthis.layer.width&&(this._maxX=this.layer.width),this._maxY>this.layer.height&&(this._maxY=this.layer.height),this.widthInPixels=this.layer.width*this.tileWidth,this.heightInPixels=this.layer.height*this.tileHeight),this.dirty=!0},e.TilemapLayer.prototype.render=function(){if(this.tilemap&&this.tilemap.dirty&&(this.dirty=!0),this.dirty&&this.tileset&&this.tilemap&&this.visible){this._prevX=this._dx,this._prevY=this._dy,this._dx=-(this._x-this._startX*this.tileWidth),this._dy=-(this._y-this._startY*this.tileHeight),this._tx=this._dx,this._ty=this._dy,this.context.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=this._startY;a0?this.deltaX():-this.deltaX()},e.TilemapLayer.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},e.TilemapLayer.prototype.deltaX=function(){return this._dx-this._prevX},e.TilemapLayer.prototype.deltaY=function(){return this._dy-this._prevY},Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._x},set:function(a){a!==this._x&&a>=0&&this.layer&&(this._x=a,this._x>this.widthInPixels-this.renderWidth&&(this._x=this.widthInPixels-this.renderWidth),this._startX=this.game.math.floor(this._x/this.tileWidth),this._startX<0&&(this._startX=0),this._startX+this._maxX>this.layer.width&&(this._startX=this.layer.width-this._maxX),this.dirty=!0)}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._y},set:function(a){a!==this._y&&a>=0&&this.layer&&(this._y=a,this._y>this.heightInPixels-this.renderHeight&&(this._y=this.heightInPixels-this.renderHeight),this._startY=this.game.math.floor(this._y/this.tileHeight),this._startY<0&&(this._startY=0),this._startY+this._maxY>this.layer.height&&(this._startY=this.layer.height-this._maxY),this.dirty=!0)}}),e.TilemapParser={tileset:function(a,b,c,d,f,g,h){var i=a.cache.getTilesetImage(b);if(null==i)return null;var j=i.width,k=i.height;0>=c&&(c=Math.floor(-j/Math.min(-1,c))),0>=d&&(d=Math.floor(-k/Math.min(-1,d)));var l=Math.round(j/c),m=Math.round(k/d),n=l*m;if(-1!==f&&(n=f),0==j||0==k||c>j||d>k||0===n)return console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"),null;for(var o=g,p=g,q=new e.Tileset(i,b,c,d,g,h),r=0;n>r;r++)q.addTile(new e.Tile(q,r,o,p,c,d)),o+=c+h,o===j&&(o=g,p+=d+h);return q},parse:function(a,b,c){return c===e.Tilemap.CSV?this.parseCSV(b):c===e.Tilemap.TILED_JSON?this.parseTiledJSON(b):void 0},parseCSV:function(a){a=a.trim();for(var b=[],c=a.split("\n"),d=c.length,e=0,f=0;fa)for(var g=a;b>=g;g++)this.tiles[g].setCollision(c,d,e,f)},setCollision:function(a,b,c,d,e){this.tiles[a]&&this.tiles[a].setCollision(b,c,d,e)}},Object.defineProperty(e.Tileset.prototype,"total",{get:function(){return this.tiles.length}}),d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,c=this.context;c.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable&&0!=a.alpha){if(a instanceof d.Sprite){var f=a.texture.frame;f&&(c.globalAlpha=a.worldAlpha,a.texture.trimmed?c.setTransform(b[0],b[3],b[1],b[4],b[2]+a.texture.trim.x,b[5]+a.texture.trim.y):c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.drawImage(a.texture.baseTexture.source,f.x,f.y,f.width,f.height,a.anchor.x*-f.width,a.anchor.y*-f.height,f.width,f.height))}else if(a instanceof d.Strip)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)a.renderCanvas(this);else if(a instanceof d.Graphics)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.CanvasGraphics.renderGraphics(a,c);else if(a instanceof d.FilterBlock)if(a.open){c.save();var g=a.mask.alpha,h=a.mask.worldTransform;c.setTransform(h[0],h[3],h[1],h[4],h[2],h[5]),a.mask.worldAlpha=.5,c.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(a.mask,c),c.clip(),a.mask.worldAlpha=g}else c.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},d.WebGLBatch.prototype.update=function(){this.gl;for(var a,b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r=0,s=this.head;s;){if(s.vcount===d.visibleCount){if(b=s.texture.frame.width,c=s.texture.frame.height,e=s.anchor.x,f=s.anchor.y,g=b*(1-e),h=b*-e,i=c*(1-f),j=c*-f,k=8*r,a=s.worldTransform,l=a[0],m=a[3],n=a[1],o=a[4],p=a[2],q=a[5],s.texture.trimmed&&(p+=s.texture.trim.x,q+=s.texture.trim.y),this.verticies[k+0]=l*h+n*j+p,this.verticies[k+1]=o*j+m*h+q,this.verticies[k+2]=l*g+n*j+p,this.verticies[k+3]=o*j+m*g+q,this.verticies[k+4]=l*g+n*i+p,this.verticies[k+5]=o*i+m*g+q,this.verticies[k+6]=l*h+n*i+p,this.verticies[k+7]=o*i+m*h+q,s.updateFrame||s.texture.updateFrame){this.dirtyUVS=!0;var t=s.texture,u=t.frame,v=t.baseTexture.width,w=t.baseTexture.height;this.uvs[k+0]=u.x/v,this.uvs[k+1]=u.y/w,this.uvs[k+2]=(u.x+u.width)/v,this.uvs[k+3]=u.y/w,this.uvs[k+4]=(u.x+u.width)/v,this.uvs[k+5]=(u.y+u.height)/w,this.uvs[k+6]=u.x/v,this.uvs[k+7]=(u.y+u.height)/w,s.updateFrame=!1}if(s.cacheAlpha!=s.worldAlpha){s.cacheAlpha=s.worldAlpha;var x=4*r;this.colors[x]=this.colors[x+1]=this.colors[x+2]=this.colors[x+3]=s.worldAlpha,this.dirtyColors=!0}}else k=8*r,this.verticies[k+0]=0,this.verticies[k+1]=0,this.verticies[k+2]=0,this.verticies[k+3]=0,this.verticies[k+4]=0,this.verticies[k+5]=0,this.verticies[k+6]=0,this.verticies[k+7]=0;r++,s=s.__next}},e}); \ No newline at end of file diff --git a/examples/_site/examples.json b/examples/_site/examples.json index 19c6c41b..e13a5bb5 100644 --- a/examples/_site/examples.json +++ b/examples/_site/examples.json @@ -520,6 +520,10 @@ "file": "bitmap+fonts.js", "title": "bitmap fonts" }, + { + "file": "hello+arial.js", + "title": "hello arial" + }, { "file": "kern+of+duty.js", "title": "kern of duty" diff --git a/examples/_site/view_full.html b/examples/_site/view_full.html index 11eb14b0..f8c2cd99 100644 --- a/examples/_site/view_full.html +++ b/examples/_site/view_full.html @@ -167,7 +167,7 @@
diff --git a/examples/index.html b/examples/index.html index 9ecc2085..c164a413 100644 --- a/examples/index.html +++ b/examples/index.html @@ -52,7 +52,7 @@