diff --git a/build/kiwi.d.ts b/build/kiwi.d.ts index 42f0635f..4839b673 100644 --- a/build/kiwi.d.ts +++ b/build/kiwi.d.ts @@ -10356,13 +10356,13 @@ declare module Kiwi.Animations { * @method start * @public */ - start(): Tween; + start(): this; /** * Stops the Tween from running and removes it from the manager. * @method stop * @public */ - stop(): Tween; + stop(): this; /** * Sets the game and the manager of this tween. * @method setParent @@ -10418,7 +10418,7 @@ declare module Kiwi.Animations { * @param context {Any} The context the method is to have when called. * @public */ - onUpdate(callback: any, context: any): Tween; + onUpdate(callback: any, context: any): this; /** * Defines a method that is to be called when this tween is finished. * @method onComplete @@ -10426,7 +10426,7 @@ declare module Kiwi.Animations { * @param context {Any} The context the method is to have when called. * @public */ - onComplete(callback: any, context: any): Tween; + onComplete(callback: any, context: any): this; /** * The update loop is executed every frame whilst the tween is running. * @method update @@ -16282,7 +16282,7 @@ declare module Kiwi.Geom { * @return {Kiwi.Geom.Matrix} This object. * @public */ - setFromTransform(tx: number, ty: number, scaleX: number, scaleY: number, rotation: number): Matrix; + setFromTransform(tx: number, ty: number, scaleX: number, scaleY: number, rotation: number): this; /** * Set matrix values from transform values, with rotation point data included * @method setFromOffsetTransform @@ -16297,7 +16297,7 @@ declare module Kiwi.Geom { * @public * @since 1.0.1 */ - setFromOffsetTransform(tx: number, ty: number, scaleX: number, scaleY: number, rotation: number, rotPointX: number, rotPointY: number): Matrix; + setFromOffsetTransform(tx: number, ty: number, scaleX: number, scaleY: number, rotation: number, rotPointX: number, rotPointY: number): this; /** * Prepend values to this matrix, paramters supplied individually. * @method prepend @@ -21588,7 +21588,7 @@ declare module Kiwi.Utils { * @return {Kiwi.Utils.Color} This object with the new color set * @public */ - set(...params: any[]): Color; + set(...params: any[]): this; /** * Red channel, stored as a normalized value between 0 and 1. * This is most compatible with graphics hardware. diff --git a/build/kiwi.js b/build/kiwi.js index afa7e54c..2ccebfdc 100644 --- a/build/kiwi.js +++ b/build/kiwi.js @@ -496,7 +496,8 @@ var Kiwi; this.states.update(); this.pluginManager.update(); this._frame++; - this._lastTime = this.raf.currentTime - (this._delta % this._interval); + this._lastTime = + this.raf.currentTime - (this._delta % this._interval); } // Graphics MUST be drawn every frame to avert frame buffer issues // under some clients @@ -853,8 +854,7 @@ var Kiwi; r: this._color.r, g: this._color.g, b: this._color.b, - a: this._color.a - }; + a: this._color.a }; }, enumerable: true, configurable: true @@ -1153,6 +1153,7 @@ var Kiwi; } } if (this._game.deviceTargetOption == Kiwi.TARGET_COCOON) { + // This has no effect in WebGL, and is thus handled separately. switch (this._scaleType) { case Kiwi.Stage.SCALE_FIT: this.canvas.style.cssText = "idtkscale:ScaleAspectFit"; @@ -1576,9 +1577,7 @@ var Kiwi; var plugins = []; for (var i = 0; i < PluginManager._availablePlugins.length; i++) { plugins.push({ - name: PluginManager._availablePlugins[i].name, - version: PluginManager._availablePlugins[i].version - }); + name: PluginManager._availablePlugins[i].name, version: PluginManager._availablePlugins[i].version }); } return plugins; }, @@ -1882,6 +1881,7 @@ var Kiwi; if (this._cameras.length === 0) { return false; } + //render each camera for (var i = 0; i < this._cameras.length; i++) { this._cameras[i].render(); } @@ -2867,6 +2867,7 @@ var Kiwi; for (var _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } + //Loop through the arguments for (var i = 0; i < args.length; i++) { if (this._tags.indexOf(args[i]) == -1) { this._tags.push(args[i]); @@ -3133,22 +3134,19 @@ var Kiwi; * @method preUpdate * @public */ - Component.prototype.preUpdate = function () { - }; + Component.prototype.preUpdate = function () { }; /** * If the component is being added to a State rather than a Game Object then over-ride its update method to perform required tasks. * @method update * @public */ - Component.prototype.update = function () { - }; + Component.prototype.update = function () { }; /** * Components can postUpdate, that is run an update after the parent has updated. This is to be overriden by subclasses. * @method postUpdate * @public */ - Component.prototype.postUpdate = function () { - }; + Component.prototype.postUpdate = function () { }; /** * Destroys this component and all of the properties that exist on it. * @method destroy @@ -4275,6 +4273,7 @@ var Kiwi; for (var _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } + //Loop through the arguments for (var i = 0; i < args.length; i++) { if (this._tags.indexOf(args[i]) == -1) { this._tags.push(args[i]); @@ -4333,6 +4332,7 @@ var Kiwi; if (this._tempRemoveChildren !== null) destroyChildren = this._tempRemoveChildren; if (destroyChildren == true) { + //Remove all of the children. for (var i = 0; i < this.members.length; i++) { this.members[i].destroy(true); } @@ -4364,11 +4364,10 @@ var Kiwi; * @module Kiwi * */ -var __extends = this.__extends || function (d, b) { +var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Kiwi; (function (Kiwi) { @@ -4466,8 +4465,7 @@ var Kiwi; * @method preload * @public */ - State.prototype.preload = function () { - }; + State.prototype.preload = function () { }; /** * This method is progressively called whilst loading files and is executed each time a file has been loaded. * This can be used to create a 'progress' bar during the loading stage of a game. @@ -4477,15 +4475,13 @@ var Kiwi; * @param file {Kiwi.Files.File} The last file to have been loaded. * @public */ - State.prototype.loadProgress = function (percent, bytesLoaded, file) { - }; + State.prototype.loadProgress = function (percent, bytesLoaded, file) { }; /** * Gets executed when the game is finished loading and it is about to 'create' the state. * @method loadComplete * @public */ - State.prototype.loadComplete = function () { - }; + State.prototype.loadComplete = function () { }; /** * The game loop that gets executed while the game is loading. * @method loadUpdate @@ -4550,15 +4546,13 @@ var Kiwi; * @method postRender * @public */ - State.prototype.postRender = function () { - }; + State.prototype.postRender = function () { }; /** * Called just before this State is going to be Shut Down and another one is going to be switched too. * @method shutDown * @public */ - State.prototype.shutDown = function () { - }; + State.prototype.shutDown = function () { }; /* *-------------- * Loading Methods @@ -4700,11 +4694,13 @@ var Kiwi; State.prototype.destroy = function (deleteAll) { if (deleteAll === void 0) { deleteAll = true; } if (deleteAll == true) { + //destroy all of the tracking list while (this._trackingList.length > 0) { //If the item is a group then we don't want it to destroy it's children, as this method will do that eventually anyway. this._trackingList[0].destroy(true, false); } this._trackingList = []; + //destroy all of the groups members. Usually they would be apart of the trackingList while (this.members.length > 0) { //If the item is a group then we don't want it to destroy it's children, as this method will do that eventually anyway. this.members[0].destroy(true, false); @@ -5168,6 +5164,8 @@ var Kiwi; } bindings = this._bindings.slice(0); //clone array in case add/remove items during dispatch this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch. + //execute all callbacks until end of the list or until a callback returns `false` or stops propagation + //reverse loop since listeners with higher priority will be added at the end of the list do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false); @@ -5863,12 +5861,13 @@ var Kiwi; w: this._canvas.width, h: this._canvas.height, hitboxes: [{ - x: this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_LEFT ? 0 : this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_CENTER ? -this._alignWidth * 0.5 : -this._alignWidth, - y: 0, - w: this.width, - h: this.height - }] - }; + x: this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_LEFT ? 0 : + this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_CENTER ? + -this._alignWidth * 0.5 : -this._alignWidth, + y: 0, + w: this.width, + h: this.height + }] }; this._tempDirty = false; this.atlas.dirty = true; }; @@ -5952,7 +5951,12 @@ var Kiwi; m.transformPoint(this._pt3); m.transformPoint(this._pt4); //Append to the xyuv and alpha arrays - vertexItems.push(this._pt1.x, this._pt1.y, 0, 0, this.alpha, this._pt2.x, this._pt2.y, this._canvas.width, 0, this.alpha, this._pt3.x, this._pt3.y, this._canvas.width, this._canvas.height, this.alpha, this._pt4.x, this._pt4.y, 0, this._canvas.height, this.alpha); + vertexItems.push(this._pt1.x, this._pt1.y, 0, 0, this.alpha, + //Top Left Point + this._pt2.x, this._pt2.y, this._canvas.width, 0, this.alpha, + //Top Right Point + this._pt3.x, this._pt3.y, this._canvas.width, this._canvas.height, this.alpha, //Bottom Right Point + this._pt4.x, this._pt4.y, 0, this._canvas.height, this.alpha); //Add to the batch! this.glRenderer.concatBatch(vertexItems); }; @@ -6180,6 +6184,7 @@ var Kiwi; if (Kiwi.Utils.Common.isString(atlas)) { atlas = this.state.textures[atlas]; } + //Does the JSON exist? switch (typeof tileMapData) { case 'string': if (this.game.fileStore.exists(tileMapData) == false) { @@ -6211,14 +6216,17 @@ var Kiwi; this.tileHeight = (json.tileheight == undefined) ? 32 : json.tileheight; this.width = json.width; this.height = json.height; + //Add the properties for (var prop in json.properties) { this.properties[prop] = json.properties[prop]; } //Generate the Tiles needed. if (json.tilesets !== "undefined" && startingCell !== -1) this._generateTypesFromTileset(json.tilesets, atlas, startingCell); + //Generate the layers we need for (var i = 0; i < json.layers.length; i++) { var layerData = json.layers[i]; + //Check what type it is. switch (json.layers[i].type) { case "tilelayer": var w = (layerData.width !== undefined) ? layerData.width : this.width; @@ -6249,6 +6257,7 @@ var Kiwi; * @private */ TileMap.prototype._generateTypesFromTileset = function (tilesetData, atlas, startingCell) { + //Loop through the tilesets for (var i = 0; i < tilesetData.length; i++) { var tileset = tilesetData[i]; //Tileset Information @@ -6260,6 +6269,7 @@ var Kiwi; var ih = tileset.imageheight - m; //Drawing offsets var offset = (tileset.tileoffset == undefined) ? { x: 0, y: 0 } : tileset.tileoffset; + //Calculate how many tiles there are in this tileset and thus how many different tile type there can be. for (var y = m; y < ih; y += th) { for (var x = m; x < iw; x += tw) { //Does the cell exist? Then use that. @@ -6270,6 +6280,7 @@ var Kiwi; startingCell++; //Increase the cell to use by one. } } + //Add tile properties for (var tp in tileset.tileproperties) { var tileType = this.tileTypes[(parseInt(tileset.firstgid) + parseInt(tp))]; tileType.properties = tileset.tileproperties[tp]; @@ -6620,8 +6631,7 @@ var Kiwi; get: function () { return null; }, - set: function (val) { - }, + set: function (val) { }, enumerable: true, configurable: true }); @@ -6986,6 +6996,7 @@ var Kiwi; width = this.width - x; if (y + height > this.height) height = this.height - y; + //Loop through and of the tiles. for (var j = y; j < y + height; j++) { for (var i = x; i < x + width; i++) { //Get the tile index. @@ -7197,6 +7208,7 @@ var Kiwi; var h = Kiwi.Utils.GameMath.snapToCeil(b.height, this.tileHeight) / this.tileHeight; //Add one, because we want to include the very end tile. var tiles = this.getCollidableTiles(x, y, w + 1, h + 1, collisionType); + //Loop through the tiles and make sure they are actually overlapping with the Entity. for (var i = 0; i < tiles.length; i++) { var t = tiles[i]; if (t.x + worldX > b.right || t.x + this.tileWidth + worldX < b.left || t.y + worldY > b.bottom || t.y + this.tileHeight + worldY < b.top) { @@ -7301,6 +7313,7 @@ var Kiwi; var m = t.getConcatenatedMatrix(); //Find which ones we need to render. this._calculateBoundaries(camera, m); + //Loop through the tiles. for (var y = this._startY; y < this._maxY; y++) { for (var x = this._startX; x < this._maxX; x++) { //Get the tile type @@ -7323,7 +7336,11 @@ var Kiwi; m.transformPoint(this._corner3); m.transformPoint(this._corner4); //Append to the xyuv array - vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha); + vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, //Top Left Point + this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, //Top Right Point + this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, //Bottom Right Point + this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha //Bottom Left Point + ); } } //Concat points to the Renderer. @@ -7412,9 +7429,8 @@ var Kiwi; TileMapLayerIsometric.prototype.getIndexFromCoords = function (x, y) { //Not within the bounds? var halfWidth = this.widthInPixels * 0.5; - if (x > this.x + halfWidth || x < this.x - halfWidth) - return -1; - if (y > this.y + this.heightInPixels || y < this.y) + var halfHeight = this.heightInPixels * 0.5; + if (Math.abs(x) > halfWidth - halfWidth * Math.abs(y - halfHeight) / halfHeight) return -1; var point = this.screenToChart({ x: x, y: y }); return this.getIndexFromXY(point.x, point.y); @@ -7452,10 +7468,12 @@ var Kiwi; TileMapLayerIsometric.prototype.screenToChart = function (scrPt, tileW, tileH) { if (tileW === void 0) { tileW = this.tileWidth; } if (tileH === void 0) { tileH = this.tileHeight; } - var column = Math.floor(scrPt.x / (tileW * 0.5)); - var row = Math.floor((scrPt.y - column * (tileH / 2)) / tileH); + var xht = scrPt.x / (tileW * 0.5); + var yht = scrPt.y / (tileH * 0.5); + var col = Math.floor((xht + yht) * 0.5); + var row = Math.floor((yht - xht) * 0.5); return { - x: column + row, + x: col, y: row }; }; @@ -7511,6 +7529,7 @@ var Kiwi; var m = t.getConcatenatedMatrix(); //Find which ones we need to render. this._calculateBoundaries(camera, m); + //Loop through the tiles. for (var y = this._startY; y < this._maxY; y++) { for (var x = this._startX; x < this._maxX; x++) { //Get the tile type @@ -7541,7 +7560,11 @@ var Kiwi; m.transformPoint(this._corner3); m.transformPoint(this._corner4); //Append to the xyuv array - vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha); + vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, //Top Left Point + this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, //Top Right Point + this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, //Bottom Right Point + this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha //Bottom Left Point + ); } } //Concat points to the Renderer. @@ -7840,6 +7863,8 @@ var Kiwi; this.onChange.dispatch(name, this.currentAnimation); } else if (inheritFromTexture) { + //Check to see if that animation exists on the atlas. + //If so create a new version of it. for (var i = 0; i < this._atlas.sequences.length; i++) { if (this._atlas.sequences[i].name === name) { this.currentAnimation = this.createFromSequence(this._atlas.sequences[i], false); @@ -8028,8 +8053,10 @@ var Kiwi; */ get: function () { if (this.autoUpdate == true && this.entity.atlas !== null && this.entity.atlas.cells && this.entity.atlas.cells[0].hitboxes) { - this._hitboxOffset.x = this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].x || 0; - this._hitboxOffset.y = this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].y || 0; + this._hitboxOffset.x = + this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].x || 0; + this._hitboxOffset.y = + this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].y || 0; } return this._hitboxOffset; }, @@ -8490,9 +8517,7 @@ var Kiwi; * @type Kiwi.Signal * @public */ - get: function () { - return this._onDragStarted; - }, + get: function () { return this._onDragStarted; }, enumerable: true, configurable: true }); @@ -8504,9 +8529,7 @@ var Kiwi; * @type Kiwi.Signal * @public */ - get: function () { - return this._onDragStopped; - }, + get: function () { return this._onDragStopped; }, enumerable: true, configurable: true }); @@ -8618,9 +8641,7 @@ var Kiwi; * @type boolean * @public */ - get: function () { - return (this._isDragging !== null); - }, + get: function () { return (this._isDragging !== null); }, enumerable: true, configurable: true }); @@ -9625,7 +9646,8 @@ var Kiwi; if (gameObject.components.hasComponent('Box') == false) return; var box = gameObject.components.getComponent('Box'); - var result = (box.worldHitbox.x + box.worldHitbox.width > this.box.worldHitbox.x) && (box.worldHitbox.x < this.box.worldHitbox.x + this.box.worldHitbox.width) && (box.worldHitbox.y + box.worldHitbox.height > this.box.worldHitbox.y) && (box.worldHitbox.y < this.box.worldHitbox.y + this.box.worldHitbox.height); + var result = (box.worldHitbox.x + box.worldHitbox.width > this.box.worldHitbox.x) && (box.worldHitbox.x < this.box.worldHitbox.x + this.box.worldHitbox.width) && + (box.worldHitbox.y + box.worldHitbox.height > this.box.worldHitbox.y) && (box.worldHitbox.y < this.box.worldHitbox.y + this.box.worldHitbox.height); if (result) { if (separateObjects) ArcadePhysics.separate(this.owner, gameObject); @@ -9929,6 +9951,7 @@ var Kiwi; ArcadePhysics.overlapsArrayGroup = function (array, group, separateObjects) { if (separateObjects === void 0) { separateObjects = true; } var result = false; + //loop through the array for (var i = 0; i < array.length; i++) { if (typeof array[i].childType !== "undefined") { if (array[i].childType() === Kiwi.GROUP) { @@ -11238,6 +11261,7 @@ var Kiwi; this.data[dataFile.key] = dataFile; break; default: + //Image file is of unknown type and was not added to data library break; } }; @@ -13062,7 +13086,9 @@ var Kiwi; this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; this.fileSystem = !!window['requestFileSystem']; this.worker = !!window['Worker']; - if ('ontouchstart' in document.documentElement || (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 0) || (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 0)) { + if ('ontouchstart' in document.documentElement || + (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 0) || + (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 0)) { this.touch = true; } if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) { @@ -13147,8 +13173,7 @@ var Kiwi; } } } - catch (e) { - } + catch (e) { } }; /** * @@ -13482,6 +13507,7 @@ var Kiwi; this.textures[imageFile.key] = this._buildTextureAtlas(imageFile); break; default: + //Image file is of unknown type and was not added to texture library break; } }; @@ -15194,14 +15220,17 @@ var Kiwi; this._onStartCallbackFired = true; } var elapsed = (time - this._startTime) / this._duration; - elapsed = elapsed > 1 ? 1 : elapsed < 0 ? 0 : elapsed; + elapsed = elapsed > 1 ? 1 : + elapsed < 0 ? 0 : + elapsed; var value = this._easingFunction(elapsed); for (var property in this._valuesStart) { var start = this._valuesStart[property]; var end = this._valuesEnd[property]; // Add checks for object, array, numeric up front if (end instanceof Array) { - this._object[property] = this._interpolationFunction(end, value); + this._object[property] = + this._interpolationFunction(end, value); } else { if (typeof this._object[property] === "function") { @@ -15217,7 +15246,8 @@ var Kiwi; } if (elapsed === 1) { this.isRunning = false; - if (this._onCompleteCallback !== null && this._onCompleteCalled === false) { + if (this._onCompleteCallback !== null && + this._onCompleteCalled === false) { this._onCompleteCalled = true; this._onCompleteCallback.call(this._onCompleteContext, this._object); } @@ -15827,7 +15857,10 @@ var Kiwi; this._batches = []; var batchIndex; for (var i = 0; i < this._sequence.length; i++) { - if (!this._sequence[i].isBatchRenderer || this._sequence[i].renderer !== currentRenderer || this._sequence[i].shader !== currentShader || this._sequence[i].texture !== currentTexture) { + if (!this._sequence[i].isBatchRenderer || + this._sequence[i].renderer !== currentRenderer || + this._sequence[i].shader !== currentShader || + this._sequence[i].texture !== currentTexture) { //create a new batch var batchIndex = this._batches.push(new Array()) - 1; currentRenderer = this._sequence[i].renderer; @@ -15865,6 +15898,7 @@ var Kiwi; } // Clear renderer for fresh data this._currentRenderer.clear(gl, { camMatrix: this.camMatrix }); + // Call render functions for (var i = 0; i < batch.length; i++) batch[i].entity.renderGL(gl, camera); // Upload textures @@ -16594,14 +16628,10 @@ var Kiwi; * @public */ GLArrayBuffer.squareVertices = [ - 0, - 0, - 100, - 0, - 100, - 100, - 0, - 100 + 0, 0, + 100, 0, + 100, 100, + 0, 100 ]; /** * @@ -16612,14 +16642,10 @@ var Kiwi; * @public */ GLArrayBuffer.squareUVs = [ - 0, - 0, - .1, - 0, - .1, - .1, - 0, - .1 + 0, 0, + .1, 0, + .1, .1, + 0, .1 ]; /** * @@ -16630,10 +16656,7 @@ var Kiwi; * @public */ GLArrayBuffer.squareCols = [ - 1, - 1, - 1, - 1 + 1, 1, 1, 1 ]; return GLArrayBuffer; })(); @@ -16884,7 +16907,12 @@ var Kiwi; GLBlendMode.prototype.isIdentical = function (blendMode) { if (this == blendMode) return (true); - if (this._srcRGB == blendMode._srcRGB && this._dstRGB == blendMode._dstRGB && this._srcAlpha == blendMode._srcAlpha && this._dstAlpha == blendMode._dstAlpha && this._modeRGB == blendMode._modeRGB && this._modeAlpha == blendMode._modeAlpha) + if (this._srcRGB == blendMode._srcRGB + && this._dstRGB == blendMode._dstRGB + && this._srcAlpha == blendMode._srcAlpha + && this._dstAlpha == blendMode._dstAlpha + && this._modeRGB == blendMode._modeRGB + && this._modeAlpha == blendMode._modeAlpha) return (true); return (false); }; @@ -16980,12 +17008,8 @@ var Kiwi; * @public */ GLElementArrayBuffer.square = [ - 0, - 1, - 2, - 0, - 2, - 3 + 0, 1, 2, + 0, 2, 3 ]; return GLElementArrayBuffer; })(); @@ -17981,7 +18005,8 @@ var Kiwi; var frameDelta, i, repeats; if (this._isPlaying) { // How many frames do we move, ahead or behind? - frameDelta = ((this.clock.elapsed() - this._lastFrameElapsed) / this._speed) % (this.length + 1); + frameDelta = ((this.clock.elapsed() - + this._lastFrameElapsed) / this._speed) % (this.length + 1); if (this._reverse) { frameDelta *= -1; } @@ -18008,7 +18033,8 @@ var Kiwi; } else if (this._frameIndex < 0) { repeats = Math.ceil(Math.abs(this._frameIndex) / this.length); - this._frameIndex = (this.length + this._frameIndex % this.length) % this.length; + this._frameIndex = (this.length + + this._frameIndex % this.length) % this.length; if (this._onLoop != null) { for (i = 0; i < repeats; i++) { this._onLoop.dispatch(); @@ -18017,7 +18043,8 @@ var Kiwi; } } else if (this._frameIndex < 0) { - this._frameIndex = (this.length + this._frameIndex % this.length) % this.length; + this._frameIndex = (this.length + + this._frameIndex % this.length) % this.length; // Execute the stop on the parent // to allow the isPlaying boolean to remain consistent this._parent.stop(); @@ -20340,6 +20367,7 @@ var Kiwi; break; } } + //Loop through the fingers and check to see that none of them are down. for (var i = 0; i < this._fingers.length; i++) { if (this._fingers[i].active === true) { this.isDown = true; @@ -20366,6 +20394,7 @@ var Kiwi; break; } } + //loop through the fingers and check to see that none of them are down. for (var i = 0; i < this._fingers.length; i++) { if (this._fingers[i].active) { this.isDown = true; @@ -20467,6 +20496,7 @@ var Kiwi; Touch.prototype.onTouchEnter = function (event) { //Stop corresponding mouse events from firing. event.preventDefault(); + // For touch enter and leave its a list of the touch points that have entered or left the target for (var i = 0; i < event.changedTouches.length; i++) { this._enterFinger(event.changedTouches[i], event.changedTouches[i].identifier); } @@ -20481,6 +20511,7 @@ var Kiwi; Touch.prototype.onTouchLeave = function (event) { //Stops corresponding mouse events from firing event.preventDefault(); + // For touch enter and leave its a list of the touch points that have entered or left the target for (var i = 0; i < event.changedTouches.length; i++) { this._leaveFinger(event.changedTouches[i], event.changedTouches[i].identifier); } @@ -22283,11 +22314,16 @@ var Kiwi; Intersect.lineToLine = function (line1, line2, output) { if (output === void 0) { output = new Geom.IntersectResult; } output.result = false; - var denom = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2); + var denom = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - + (line1.y1 - line1.y2) * (line2.x1 - line2.x2); if (denom !== 0) { output.result = true; - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * + (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * + (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; } return output; }; @@ -22313,15 +22349,21 @@ var Kiwi; Intersect.lineToLineSegment = function (line1, seg, output) { if (output === void 0) { output = new Geom.IntersectResult; } output.result = false; - var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 - seg.x2); + var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - + (line1.y1 - line1.y2) * (seg.x1 - seg.x2); if (denom !== 0) { - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * + (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * + (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; var maxX = Math.max(seg.x1, seg.x2); var minX = Math.min(seg.x1, seg.x2); var maxY = Math.max(seg.y1, seg.y2); var minY = Math.min(seg.y1, seg.y2); - if ((output.x <= maxX && output.x >= minX) === true && (output.y <= maxY && output.y >= minY) === true) { + if ((output.x <= maxX && output.x >= minX) === true && + (output.y <= maxY && output.y >= minY) === true) { output.result = true; } } @@ -22354,7 +22396,8 @@ var Kiwi; var minX = Math.min(x1, x2); var maxY = Math.max(y1, y2); var minY = Math.min(y1, y2); - if (output.x <= maxX && output.x >= minX && output.y <= maxY && output.y >= minY) { + if (output.x <= maxX && output.x >= minX && + output.y <= maxY && output.y >= minY) { output.result = true; } } @@ -22501,7 +22544,10 @@ var Kiwi; output.result = false; Intersect.lineToLineSegment(line1, line2, output); if (output.result === true) { - if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { + if (!(output.x >= Math.min(line1.x1, line1.x2) && + output.x <= Math.max(line1.x1, line1.x2) && + output.y >= Math.min(line1.y1, line1.y2) && + output.y <= Math.max(line1.y1, line1.y2))) { output.result = false; } } @@ -22524,7 +22570,8 @@ var Kiwi; output.result = false; Intersect.lineToRay(line1, ray, output); if (output.result === true) { - if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { + if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) + && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { output.result = false; } } @@ -22557,7 +22604,8 @@ var Kiwi; } else { // Worst case - segment doesn't traverse center, so no perpendicular connection. - if (Intersect.circleContainsPoint(circle, { x: seg.x1, y: seg.y1 }).result || Intersect.circleContainsPoint(circle, { x: seg.x2, y: seg.y2 }).result) { + if (Intersect.circleContainsPoint(circle, { x: seg.x1, y: seg.y1 }).result || + Intersect.circleContainsPoint(circle, { x: seg.x2, y: seg.y2 }).result) { output.result = true; } } @@ -22751,7 +22799,8 @@ var Kiwi; return output; } // If circle centroid is within the rect, it overlaps. - if (circleRelativeX <= halfRectWidth || circleRelativeY <= rect.height / 2) { + if (circleRelativeX <= halfRectWidth || + circleRelativeY <= rect.height / 2) { output.result = true; return output; } @@ -22760,7 +22809,8 @@ var Kiwi; // own radius of this ideal corner, it overlaps. cornerDistX = circleRelativeX - halfRectWidth; cornerDistY = circleRelativeY - halfRectHeight; - output.result = cornerDistX * cornerDistX + cornerDistY * cornerDistY <= circle.radius * circle.radius; + output.result = cornerDistX * cornerDistX + cornerDistY * cornerDistY <= + circle.radius * circle.radius; return output; }; /** @@ -23378,7 +23428,12 @@ var Kiwi; * @public */ Matrix.prototype.equals = function (matrix) { - return (this.a === matrix.a && this.b === matrix.b && this.c === matrix.c && this.d === matrix.d && this.tx === matrix.tx && this.ty === matrix.ty); + return (this.a === matrix.a && + this.b === matrix.b && + this.c === matrix.c && + this.d === matrix.d && + this.tx === matrix.tx && + this.ty === matrix.ty); }; return Matrix; })(); @@ -24969,7 +25024,9 @@ var Kiwi; // Get local matrix this._cachedConcatenatedMatrix.copyFrom(this._matrix); // Apply parent transform - if (this._parent && !this._parent.ignoreChild && !this.ignoreParent) { + if (this._parent && + !this._parent.ignoreChild && + !this.ignoreParent) { this._cachedConcatenatedMatrix.tx -= this._parent.anchorPointX; this._cachedConcatenatedMatrix.ty -= this._parent.anchorPointY; this._cachedConcatenatedMatrix.prependMatrix(this.getParentMatrix()); @@ -26704,6 +26761,7 @@ var Kiwi; } } else { + //remove some for (var i = this.counter.max; i < this._icons.length; i++) { this._removeIcon(this._icons[i]); this._icons[i].destroy(); @@ -26712,6 +26770,7 @@ var Kiwi; } } } + //display them all! for (var i = 0; i < this._icons.length; i++) { if (i > (this.counter.current - 1)) { this._icons[i].style.display = 'none'; @@ -28924,6 +28983,7 @@ var Kiwi; this.audio[audioFile.key] = audioFile; break; default: + //Audio file is of unknown type and was not added to audio library break; } }; @@ -32447,6 +32507,7 @@ var Kiwi; m = n; n = r; } + //now start loop while (true) { r = m % n; if (!r) @@ -33229,106 +33290,21 @@ var Kiwi; */ this._data = { lipsum: [ - "lorem", - "ipsum", - "dolor", - "sit", - "amet", - "consectetur", - "adipiscing", - "elit", - "nunc", - "sagittis", - "tortor", - "ac", - "mi", - "pretium", - "sed", - "convallis", - "massa", - "pulvinar", - "curabitur", - "non", - "turpis", - "velit", - "vitae", - "rutrum", - "odio", - "aliquam", - "sapien", - "orci", - "tempor", - "sed", - "elementum", - "sit", - "amet", - "tincidunt", - "sed", - "risus", - "etiam", - "nec", - "lacus", - "id", - "ante", - "hendrerit", - "malesuada", - "donec", - "porttitor", - "magna", - "eget", - "libero", - "pharetra", - "sollicitudin", - "aliquam", - "mattis", - "mattis", - "massa", - "et", - "porta", - "morbi", - "vitae", - "magna", - "augue", - "vestibulum", - "at", - "lectus", - "sed", - "tellus", - "facilisis", - "tincidunt", - "suspendisse", - "eros", - "magna", - "consequat", - "at", - "sollicitudin", - "ac", - "vestibulum", - "vel", - "dolor", - "in", - "egestas", - "lacus", - "quis", - "lacus", - "placerat", - "et", - "molestie", - "ipsum", - "scelerisque", - "nullam", - "sit", - "amet", - "tortor", - "dui", - "aenean", - "pulvinar", - "odio", - "nec", - "placerat", - "fringilla", - "neque", - "dolor" + "lorem", "ipsum", "dolor", "sit", "amet", "consectetur", + "adipiscing", "elit", "nunc", "sagittis", "tortor", "ac", "mi", + "pretium", "sed", "convallis", "massa", "pulvinar", "curabitur", + "non", "turpis", "velit", "vitae", "rutrum", "odio", "aliquam", + "sapien", "orci", "tempor", "sed", "elementum", "sit", "amet", + "tincidunt", "sed", "risus", "etiam", "nec", "lacus", "id", "ante", + "hendrerit", "malesuada", "donec", "porttitor", "magna", "eget", + "libero", "pharetra", "sollicitudin", "aliquam", "mattis", "mattis", + "massa", "et", "porta", "morbi", "vitae", "magna", "augue", + "vestibulum", "at", "lectus", "sed", "tellus", "facilisis", + "tincidunt", "suspendisse", "eros", "magna", "consequat", "at", + "sollicitudin", "ac", "vestibulum", "vel", "dolor", "in", "egestas", + "lacus", "quis", "lacus", "placerat", "et", "molestie", "ipsum", + "scelerisque", "nullam", "sit", "amet", "tortor", "dui", "aenean", + "pulvinar", "odio", "nec", "placerat", "fringilla", "neque", "dolor" ] }; this.sow(seeds); @@ -33714,7 +33690,8 @@ var Kiwi; } else { this._isSetTimeOut = false; - this._rafId = window.requestAnimationFrame(function () { return _this.RAFUpdate(); }); + this._rafId = + window.requestAnimationFrame(function () { return _this.RAFUpdate(); }); } this.isRunning = true; }; @@ -34699,9 +34676,7 @@ var Kiwi; for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { - this.constructor = d; - } + function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; diff --git a/build/kiwi.min.js b/build/kiwi.min.js index 3e547c6a..72eb220c 100644 --- a/build/kiwi.min.js +++ b/build/kiwi.min.js @@ -1,11 +1,11 @@ -var Kiwi;!function(a){var b=function(){function b(b,c,d,e){var f=this;if(void 0===b&&(b=""),void 0===c&&(c="KiwiGame"),void 0===d&&(d=null),void 0===e&&(e={}),this._startup=null,this.audio=null,this.fileStore=null,this.input=null,this.cameras=null,this.pluginManager=null,this.loader=null,this.raf=null,this.stage=null,this.states=null,this.time=null,this.tweens=null,this.rnd=null,this._frameRate=60,this._interval=1e3/60,this._delta=0,this._frame=0,a.Log.setDefaultsFromParams(e.log),a.Log.log("Kiwi.Game: "+c+" is booting using Kiwi.js "+a.VERSION,"#version"),null===a.DEVICE&&(a.DEVICE=new a.System.Device),"undefined"!==e.debug&&"number"==typeof e.debug)switch(e.debug){case a.DEBUG_ON:this._debugOption=e.debug,a.Log.log(" Kiwi.Game: Debugging turned ON.","#debugging");break;case a.DEBUG_OFF:this._debugOption=e.debug,a.Log.log(" Kiwi.Game: Debugging turned OFF.","#debugging");break;default:this._debugOption=a.DEBUG_ON,a.Log.error(" Kiwi.Game: Debug option passed, but is not a valid option. Turned ON by default.","#debugging")}else this._debugOption=a.DEBUG_ON,a.Log.log(" Kiwi.Game: Debug option not specified. Turned ON by default.","#debugging");if("undefined"!==e.bootCallback&&(this.bootCallbackOption=e.bootCallback),"undefined"!==e.deviceTarget&&"number"==typeof e.deviceTarget)switch(e.deviceTarget){case a.TARGET_BROWSER:this._deviceTargetOption=e.deviceTarget,a.Log.log(" Kiwi.Game: Targeting BROWSERS.","#target");break;case a.TARGET_COCOON:this._deviceTargetOption=e.deviceTarget,a.Log.log(" Kiwi.Game: Targeting COCOONJS.","#target");break;default:this._deviceTargetOption=a.TARGET_BROWSER,a.Log.error(" Kiwi.Game: Target device specified, but is not a valid option. Defaulting to BROWSER.","#target")}else this._deviceTargetOption=a.TARGET_BROWSER,a.Log.log(" Kiwi.Game: Targeted device not specified. Defaulting to BROWSER.","#target");var g=a.RENDERER_WEBGL,h=a.RENDERER_CANVAS;if("undefined"!==e.renderer&&"number"==typeof e.renderer)switch(e.renderer){case a.RENDERER_CANVAS:this._renderOption=e.renderer,a.Log.log(" Kiwi.Game: Rendering using CANVAS.","#renderer","#canvas");break;case a.RENDERER_WEBGL:a.DEVICE.webGL?(this._renderOption=e.renderer,a.Log.log(" Kiwi.Game: Rendering using WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: WEBGL renderer requested but device does not support WEBGL. Rendering using CANVAS.","#renderer","#canvas"));break;case a.RENDERER_AUTO:a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer auto-detected WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer auto-detected CANVAS.","#renderer","#canvas"));break;default:a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer specified, but is not a valid option. Defaulting to WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer specified, but is not a valid option. WEBGL renderer sought by default but device does not support WEBGL. Defaulting to CANVAS.","#renderer","#canvas"))}else a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer not specified. Defaulting to WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer not specified. WEBGL renderer sought by default but device does not support WEBGL. Defaulting to CANVAS.","#renderer","#canvas"));this.id=a.GameManager.register(this),this._startup=new a.System.Bootstrap,this.audio=new a.Sound.AudioManager(this),this.fileStore=new a.Files.FileStore(this),this.input=new a.Input.InputManager(this);var i=a.Stage.DEFAULT_WIDTH,j=a.Stage.DEFAULT_HEIGHT;if("undefined"!==e.width&&"number"==typeof e.width&&(i=e.width),"undefined"!==e.height&&"number"==typeof e.height&&(j=e.height),a.Log.log(" Kiwi.Game: Stage Dimensions: "+i+"x"+j,"#dimensions"),a.Utils.Common.isUndefined(e.scaleType))a.Log.log(" Kiwi.Game: Stage scaling not specified, defaulting to NONE.","#scaling"),e.scaleType=0;else switch(e.scaleType){case a.Stage.SCALE_FIT:a.Log.log(" Kiwi.Game: Stage scaling set to FIT.","#scaling");break;case a.Stage.SCALE_STRETCH:a.Log.log(" Kiwi.Game: Stage scaling set to STRETCH.","#scaling");break;case a.Stage.SCALE_NONE:a.Log.log(" Kiwi.Game: Stage scaling set to NONE.","#scaling");break;default:a.Log.log(" Kiwi.Game: Stage specified, but is not a valid option. Set to NONE.","#scaling"),e.scaleType=0}this.stage=new a.Stage(this,c,i,j,e.scaleType),this.renderer=null,this.cameras=new a.CameraManager(this),this._deviceTargetOption!==a.TARGET_COCOON&&(this.huds=new a.HUD.HUDManager(this)),this.loader=new a.Files.Loader(this),this.states=new a.StateManager(this),this.rnd=new a.Utils.RandomDataGenerator([Date.now.toString()]),this.time=new a.Time.ClockManager(this),this.tweens=new a.Animations.Tweens.TweenManager(this),null!==d?this.states.addState(d,!0):a.Log.log(" Kiwi.Game: Default State not passed.","#state"),this.pluginManager=new a.PluginManager(this,e.plugins),this.deviceTargetOption===a.TARGET_BROWSER?this._startup.boot(b,function(){return f._start()}):(""!==b&&a.Log.log(" Kiwi.Game: Not Targetting a BROWSER. DOM Parent parameter ignored.","#dom"),this._start())}return Object.defineProperty(b.prototype,"renderOption",{get:function(){return this._renderOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"deviceTargetOption",{get:function(){return this._deviceTargetOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"debugOption",{get:function(){return this._debugOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"debug",{get:function(){return this._debugOption===a.DEBUG_ON},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Game"},Object.defineProperty(b.prototype,"frame",{get:function(){return this._frame},set:function(b){this._frame=a.Utils.GameMath.truncate(b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"idealFrame",{get:function(){return this.time.elapsed()/(1e3/this._frameRate)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameRate",{get:function(){return this._frameRate},set:function(a){a>0&&(this._frameRate=a,this._interval=1e3/this._frameRate,this.time.setMasterInterval(this._interval))},enumerable:!0,configurable:!0}),b.prototype._start=function(){var b=this;this.stage.boot(this._startup),this.stage.renderer||a.Log.error(" Kiwi.Game: Could not create rendering context","#renderer"),this._renderOption===a.RENDERER_WEBGL&&this.stage.ctx&&(this._renderOption=a.RENDERER_CANVAS),this.renderer=this.stage.renderer,this.renderer.boot(),this.cameras.boot(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.boot(),this.time.boot(),this.input.boot(),this.audio.boot(),this.fileStore.boot(),this.loader.boot(),this.states.boot(),this.pluginManager.boot(),this._lastTime=Date.now(),this.raf=new a.Utils.RequestAnimationFrame(function(){return b._loop()}),this.raf.start(),this.bootCallbackOption&&(a.Log.log(" Kiwi.Game: invoked boot callback","#boot"),this.bootCallbackOption(this))},b.prototype._loop=function(){this._delta=this.raf.currentTime-this._lastTime,this._delta>this._interval&&(this.time.update(),this.audio.update(),this.input.update(),this.tweens.update(),this.cameras.update(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.update(),this.states.update(),this.pluginManager.update(),this._frame++,this._lastTime=this.raf.currentTime-this._delta%this._interval),null!==this.states.current&&(this.cameras.render(),this.states.postRender())},b}();a.Game=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(b,c,d,e,f){this._scaleType=a.Stage.SCALE_NONE,this.offset=new a.Geom.Point,this._color=new a.Utils.Color,this.container=null,this._game=b,this.name=c,this.domReady=!1,this._alpha=1,this._x=0,this._y=0,this._width=d,this._height=e,this.color="ffffff",this._game.deviceTargetOption===a.TARGET_COCOON&&(this.color="000000"),this._scale=new a.Geom.Point(1,1),this._scaleType=f,this.onResize=new a.Signal,this.onWindowResize=new a.Signal,this.onFocus=new a.Signal,this.onBlur=new a.Signal,this.onVisibilityChange=new a.Signal,this._renderer=null}return b.prototype.objType=function(){return"Stage"},Object.defineProperty(b.prototype,"scaleType",{get:function(){return this._scaleType},set:function(a){this._scaleType=a,this._scaleContainer()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"alpha",{get:function(){return this._alpha},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.container.style.opacity=String(a.Utils.GameMath.clamp(b,1,0))),this._alpha=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.left=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.left=String(b+"px")),this._x=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.top=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.top=String(b+"px")),this._y=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleX",{get:function(){return this._scale.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleY",{get:function(){return this._scale.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"color",{get:function(){return this._color.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._color.set.apply(this._color,b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b}},set:function(a){this._color.r255=a.r,this._color.g255=a.g,this._color.b255=a.b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbaColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b,a:255*this._color.a}},set:function(a){this._color.r255=a.r,this._color.g255=a.g,this._color.b255=a.b,this._color.a255=a.a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"normalizedColor",{get:function(){return{r:this._color.r,g:this._color.g,b:this._color.b,a:this._color.a}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"renderer",{get:function(){return this._renderer},enumerable:!0,configurable:!0}),b.prototype.boot=function(b){var c=this,d=this;this.domReady=!0,this.container=b.container,this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.offset=this.getOffsetPoint(this.container),this._x=this.offset.x,this._y=this.offset.y,window.addEventListener("resize",function(a){return c._windowResized(a)},!0),this._createFocusEvents()),this._createCompositeCanvas(),this._game.deviceTargetOption===a.TARGET_COCOON?(this._scaleContainer(),window.addEventListener("orientationchange",function(a){return d._orientationChanged(a)},!0)):this._calculateContainerScale()},b.prototype.getOffsetPoint=function(b,c){void 0===c&&(c=new a.Geom.Point);var d=b.getBoundingClientRect(),e=b.clientTop||document.body.clientTop||0,f=b.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||b.scrollTop||document.body.scrollTop,h=window.pageXOffset||b.scrollLeft||document.body.scrollLeft;return c.setTo(d.left+h-f,d.top+g-e)},b.prototype._windowResized=function(){this._calculateContainerScale(),this.onWindowResize.dispatch()},b.prototype._orientationChanged=function(){this.onResize.dispatch(window.innerWidth,window.innerHeight)},b.prototype._calculateContainerScale=function(){this._scaleContainer(),this._scaleContainer(),this.offset=this.getOffsetPoint(this.container),this._scale.x=this._width/this.container.clientWidth,this._scale.y=this._height/this.container.clientHeight},b.prototype._createCompositeCanvas=function(){this._game.deviceTargetOption==a.TARGET_COCOON?this.canvas=document.createElement(navigator.isCocoonJS?"screencanvas":"canvas"):(this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%"),this.canvas.id=this._game.id+"compositeCanvas",this.canvas.style.position="absolute",this.canvas.width=this.width,this.canvas.height=this.height,this._game.renderOption===a.RENDERER_CANVAS?(this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null):this._game.renderOption===a.RENDERER_WEBGL&&(this.gl=this.canvas.getContext("webgl"),this.gl||(this.gl=this.canvas.getContext("experimental-webgl"),this.gl?a.Log.warn("Kiwi.Stage: 'webgl' context is not available. Using 'experimental-webgl'","#renderer"):(a.Log.warn("Kiwi.Stage: WebGL rendering is not available despite the device apparently supporting it. Reverting to CANVAS.","#renderer"),this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null)),this.gl&&(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.ctx=null)),this.ctx?this._renderer=new a.Renderers.CanvasRenderer(this._game):this.gl&&(this._renderer=new a.Renderers.GLRenderManager(this._game)),this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.appendChild(this.canvas):document.body.appendChild(this.canvas)},b.prototype.resize=function(b,c){this.canvas.height=c,this.canvas.width=b,this._height=c,this._width=b,this._game.deviceTargetOption===a.TARGET_BROWSER&&this._calculateContainerScale(),this.onResize.dispatch(this._width,this._height)},b.prototype.setRGBColor=function(a,b,c){return this.rgbColor={r:a,g:b,b:c},this.rgbColor},b.prototype.createDebugCanvas=function(){0!=a.Utils.Common.isUndefined(this.debugCanvas)&&(this._game.deviceTargetOption===a.TARGET_COCOON&&a.Log.log("Debug canvas not supported in cocoon, creating canvas and context anyway","#debug-canvas"),this.debugCanvas=document.createElement("canvas"),this.debugCanvas.id=this._game.id+"debugCanvas",this.debugCanvas.style.position="absolute",this.debugCanvas.width=this.width,this.debugCanvas.height=this.height,this.debugCanvas.style.width="100%",this.debugCanvas.style.height="100%",this.dctx=this.debugCanvas.getContext("2d"),this.clearDebugCanvas(),this._game.deviceTargetOption===a.TARGET_BROWSER&&this.container.appendChild(this.debugCanvas))},b.prototype.clearDebugCanvas=function(a){this.dctx.fillStyle=a||"rgba(255,0,0,.2)",this.dctx.clearRect(0,0,this.width,this.height),this.dctx.fillRect(0,0,this.width,this.height)},b.prototype.toggleDebugCanvas=function(){this.debugCanvas.style.display="none"===this.debugCanvas.style.display?"block":"none"},b.prototype._scaleContainer=function(){if(this._game.deviceTargetOption==a.TARGET_BROWSER){var b=this.container.clientWidth;this.container.style.width=String(this._width+"px"),this.container.style.height=String(this._height+"px"),this._scaleType==a.Stage.SCALE_NONE&&(this.container.style.maxWidth="",this.container.style.minWidth=""),(this._scaleType==a.Stage.SCALE_STRETCH||this._scaleType==a.Stage.SCALE_FIT)&&(this.container.style.minWidth="100%",this.container.style.maxWidth="100%"),this._scaleType==a.Stage.SCALE_STRETCH?(this.container.style.minHeight="100%",this.container.style.maxHeight="100%"):(this.container.style.minHeight="",this.container.style.maxHeight=""),this._scaleType==a.Stage.SCALE_FIT&&(this.container.style.height=String(b/this._width*this._height)+"px")}if(this._game.deviceTargetOption==a.TARGET_COCOON)switch(this._scaleType){case a.Stage.SCALE_FIT:this.canvas.style.cssText="idtkscale:ScaleAspectFit";break;case a.Stage.SCALE_STRETCH:this.canvas.style.cssText="idtkscale:ScaleToFill";break;case a.Stage.SCALE_NONE:this.canvas.style.cssText=""}},Object.defineProperty(b.prototype,"visibility",{get:function(){return this._visibility?!document[this._visibility]:!0},enumerable:!0,configurable:!0}),b.prototype._checkVisibility=function(a){return"focus"===a.type||"pageshow"===a.type?void this.onFocus.dispatch(a):"pagehide"===a.type||"blur"===a.type?void this.onBlur.dispatch(a):"visibilitychange"===a.type||"mozvisibilitychange"===a.type||"webkitvisibilitychange"===a.type||"msvisibilitychange"===a.type?void this.onVisibilityChange.dispatch():void 0},b.prototype._createFocusEvents=function(){this._visibility="hidden",this._visibilityChange=this._checkVisibility.bind(this),"hidden"in document?document.addEventListener("visibilitychange",this._visibilityChange):(this._visibility="mozHidden")in document?document.addEventListener("mozvisibilitychange",this._visibilityChange):(this._visibility="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",this._visibilityChange):(this._visibility="msHidden")in document?document.addEventListener("msvisibilitychange",this._visibilityChange):this._visibility=null,window.addEventListener("pageshow",this._visibilityChange),window.addEventListener("pagehide",this._visibilityChange),window.addEventListener("focus",this._visibilityChange),window.addEventListener("blur",this._visibilityChange)},b.DEFAULT_WIDTH=800,b.DEFAULT_HEIGHT=600,b.SCALE_NONE=0,b.SCALE_FIT=1,b.SCALE_STRETCH=2,b}();a.Stage=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function a(a,b){this._components={},this._type=a,this._owner=b}return a.prototype.objType=function(){return"ComponentManager"},a.prototype.hasComponent=function(a){return this._components[a]?!0:!1},a.prototype.hasActiveComponent=function(a){return this._components[a]&&this._components[a].active===!0?!0:!1},a.prototype.getComponent=function(a){return this._components[a]?this._components[a]:null},a.prototype.add=function(a){return this._components[a.name]=a,a},a.prototype.addBatch=function(){for(var a=[],b=0;bf.majorVersion?a.Log.warn(" Kiwi.PluginManager: This major version of Kiwi is greater than that required by '"+d+"'. It is unknown whether this plugin will work with this version of Kiwi","#plugin"):a.Utils.Version.greaterOrEqual(a.VERSION,a.Plugins[d].minimumKiwiVersion)?a.Log.log(" Kiwi.PluginManager: Kiwi version meets minimum version requirements for '"+d+"'.","#plugin"):a.Log.warn(" Kiwi.PluginManager: Kiwi version ("+a.VERSION+") does not meet minimum version requirements for the plugin ("+a.Plugins[d].minimumKiwiVersion+").","#plugin")}else a.Log.warn(" Kiwi.PluginManager: '"+d+"' is missing the minimumKiwiVersion property. It is unknown whether '"+d+"' will work with this version of Kiwi","#plugin");else a.Log.log(" Kiwi.PluginManager: Plugin '"+d+"' appears to be invalid. No property with that name exists on the Kiwi.Plugins object or the Plugin is not registered. Check that the js file containing the plugin has been included. This plugin will be ignored","#plugin");else a.Log.log(" Kiwi.PluginManager: The supplied plugin name at index "+c+"is not a string and will be ignored","#plugin")}this._plugins=b;for(var c=0;c=a&&(a=0),a>1&&(a=1),this._alpha=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){this._visible=a},enumerable:!0,configurable:!0}),b.prototype.scaleToWidth=function(a){this.scale=a/this.width},b.prototype.scaleToHeight=function(a){this.scale=a/this.height},b.prototype.centerAnchorPoint=function(){this.anchorPointX=.5*this.width,this.anchorPointY=.5*this.height},Object.defineProperty(b.prototype,"cellIndex",{get:function(){return this._cellIndex},set:function(b){if(null!==this.atlas){var c=this.atlas.cells[b];void 0!==c?(this._cellIndex=b,this.width=c.w,this.height=c.h):a.Log.error("Could not the set the cellIndex of a Entity, to cell that does not exist on its TextureAtlas.","#entity","#cellIndex")}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"exists",{get:function(){return this._exists},set:function(a){this._exists=a},enumerable:!0,configurable:!0}),b.prototype.addTag=function(){for(var a=[],b=0;b-1&&(this.members.splice(c,1),a.parent=null,b&&a.destroy())}return a},b.prototype.removeChildAt=function(a){if(this.members[a]){var b=this.members[a];return this.removeChild(b)}return null},b.prototype.removeChildren=function(a,b,c){void 0===a&&(a=0),void 0===b&&(b=2147483647),void 0===c&&(c=!1),b-=a;for(var d=this.members.splice(a,b),e=0;e=0;c--){if(this.members[c].hasTag(b))return this.members[c];if(this.members[c].childType()==a.GROUP){var d=this.members[c].getLastChildByTag(b);if(d)return d}}return null},b.prototype.setChildIndex=function(a,b){return a.parent!==this||this.getChildIndex(a)===b?!1:(this.removeChild(a),this.addChildAt(a,b),!0)},b.prototype.swapChildren=function(a,b){if(a.parent!==this||b.parent!==this)return!1;var c=this.getChildIndex(a),d=this.getChildIndex(b);return-1!==c&&-1!==d&&c!==d?(this.members[c]=b,this.members[d]=a,!0):!1},b.prototype.swapChildrenAt=function(a,b){var c=this.getChildAt(a),d=this.getChildAt(b);return null!==c&&null!==d?c==d||c.parent!==this||d.parent!==this?!1:(this.members[a]=d,this.members[b]=c,!0):!1},b.prototype.replaceChild=function(a,b){if(a===b)return!1;var c=this.getChildIndex(a);return c>-1?(b.parent&&b.parent.removeChild(b),this.removeChildAt(c),this.addChildAt(b,c),b.parent=null,!0):!1},b.prototype.forEach=function(a,b){for(var c=[],d=2;d0&&this.members.forEach(function(d){return b.apply(a,[d].concat(c))})},b.prototype.forEachAlive=function(a,b){for(var c=[],d=2;d0&&this.members.forEach(function(d){d.exists&&b.apply(a,[d].concat(c))})},b.prototype.setAll=function(a,b,c){if(null===a)for(var d=0;d0)for(var a=0;a-1&&this._trackingList.splice(b,1)},c.prototype.destroyUnused=function(){for(var a=0,b=0;b0;)this._trackingList[0].destroy(!0,!1);for(this._trackingList=[];this.members.length>0;)this.members[0].destroy(!0,!1);this.members=[]}},c.prototype._destroyChildren=function(b){if(b.childType()==a.GROUP)for(var c=0;c0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.Sprite=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f){return void 0===e&&(e=0),void 0===f&&(f=0),b.call(this,c,e,f),this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),a.Utils.Common.isString(d)&&(d=this.state.textures[d]),"undefined"==typeof d?(a.Log.error("A Texture Atlas was not passed when instantiating a new Static Image.","#static-image","#texture"),this.visible=!1,void(this.active=!1)):(this.atlas=d,this.cellIndex=this.atlas.cellIndex,this.width=d.cells[this.cellIndex].w,this.height=d.cells[this.cellIndex].h,this.transform.rotPointX=this.width/2,this.transform.rotPointY=this.height/2,void(this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))))}return __extends(c,b),c.prototype.objType=function(){return"StaticImage"},c.prototype.render=function(a){if(b.prototype.render.call(this,a),this.alpha>0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.StaticImage=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h,i,j){void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g="#000000"),void 0===h&&(h=32),void 0===i&&(i="normal"),void 0===j&&(j="sans-serif"),b.call(this,c,e,f),this._tempDirty=!0,this._pt1=new a.Geom.Point(0,0),this._pt2=new a.Geom.Point(0,0),this._pt3=new a.Geom.Point(0,0),this._pt4=new a.Geom.Point(0,0),this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),this._text=d,this._fontWeight=i,this._fontSize=h,this._fontColor=new a.Utils.Color(g),this._fontFamily=j,this._textAlign="left",this._baseline="top",this._tempDirty=!0,this._canvas=document.createElement("canvas"),this._canvas.width=2,this._canvas.height=2,this._ctx=this._canvas.getContext("2d"),this.atlas=new a.Textures.SingleImage(this.game.rnd.uuid(),this._canvas),this.state.textureLibrary.add(this.atlas),this.atlas.dirty=!0,this._alignWidth=0,this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))}return __extends(c,b),c.prototype.objType=function(){return"Textfield"},Object.defineProperty(c.prototype,"text",{get:function(){return this._text},set:function(a){this._text=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"color",{get:function(){return"#"+this._fontColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._fontColor.set.apply(this._fontColor,b),this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(a){this._fontWeight=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontSize",{get:function(){return this._fontSize},set:function(a){this._fontSize=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(a){this._fontFamily=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"textAlign",{get:function(){return this._textAlign},set:function(a){this._textAlign=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),c.prototype._renderText=function(){this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily;var b=this._ctx.measureText(this._text),c=b.width,d=1.3*this._fontSize;if(this._alignWidth=c,-1==a.Utils.Common.base2Sizes.indexOf(c)){for(var e=0;c>a.Utils.Common.base2Sizes[e];)e++;c=a.Utils.Common.base2Sizes[e]}if(-1==a.Utils.Common.base2Sizes.indexOf(d)){for(var e=0;d>a.Utils.Common.base2Sizes[e];)e++;d=a.Utils.Common.base2Sizes[e]}this._canvas.width=c,this._canvas.height=d,this._ctx.clearRect(0,0,c,d),this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily,this._ctx.fillStyle=this.color.slice(0,7),this._ctx.textBaseline=this._baseline,this._ctx.fillText(this._text,0,0),this.width=this._alignWidth,this.height=this._canvas.height,this.atlas.cells[0]={x:0,y:0,w:this._canvas.width,h:this._canvas.height,hitboxes:[{x:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_LEFT?0:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_CENTER?.5*-this._alignWidth:-this._alignWidth,y:0,w:this.width,h:this.height}]},this._tempDirty=!1,this.atlas.dirty=!0},c.prototype.render=function(){if(this.alpha>0&&this.visible){var b=this.game.stage.ctx;b.save();var c=this.transform;this.alpha>0&&this.alpha<=1&&(b.globalAlpha=this.alpha),this._tempDirty&&this._renderText();var d=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:d=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:d=.5*this._alignWidth;break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:d=this._alignWidth}var e=c.getConcatenatedMatrix();b.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),b.drawImage(this._canvas,0,0,this._canvas.width,this._canvas.height,-c.rotPointX-d,-c.rotPointY,this._canvas.width,this._canvas.height),b.restore()}},c.prototype.renderGL=function(b,c,d){void 0===d&&(d=null),this._tempDirty&&this._renderText();var e=[],f=this.transform,g=f.getConcatenatedMatrix(),h=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:h=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:h=-(.5*this._alignWidth);break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:h=-this._alignWidth}this._pt1.setTo(h-f.rotPointX,0-f.rotPointY),this._pt2.setTo(this._canvas.width+h-f.rotPointX,0-f.rotPointY),this._pt3.setTo(this._canvas.width+h-f.rotPointX,this._canvas.height-f.rotPointY),this._pt4.setTo(h-f.rotPointX,this._canvas.height-f.rotPointY),g.transformPoint(this._pt1),g.transformPoint(this._pt2),g.transformPoint(this._pt3),g.transformPoint(this._pt4),e.push(this._pt1.x,this._pt1.y,0,0,this.alpha,this._pt2.x,this._pt2.y,this._canvas.width,0,this.alpha,this._pt3.x,this._pt3.y,this._canvas.width,this._canvas.height,this.alpha,this._pt4.x,this._pt4.y,0,this._canvas.height,this.alpha),this.glRenderer.concatBatch(e)},c.TEXT_ALIGN_CENTER="center",c.TEXT_ALIGN_RIGHT="right",c.TEXT_ALIGN_LEFT="left",c}(a.Entity);b.TextField=c,b.Textfield=a.GameObjects.TextField}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=-1),this.allowCollisions=a.Components.ArcadePhysics.NONE,this.properties={},this.tilemap=b,this.index=c,this.cellIndex=d,this.offset=new a.Geom.Point(0,0) -}return b.prototype.objType=function(){return"TileType"},b}();b.TileType=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function c(b,c,d,e){void 0===e&&(e=0),this.tileWidth=0,this.tileHeight=0,this.width=0,this.height=0,this.properties={},this.tileTypes=[],this.createTileType(-1),this.layers=[],this.state=b,this.game=b.game,void 0!==c&&void 0!==d?this.createFromFileStore(c,d,e):(void 0!==c||void 0!==d)&&a.Log.warn("You must pass BOTH the TileMapDataKey and TextureAtlas inorder to create a TileMap from the File Store.","#tilemap")}return Object.defineProperty(c.prototype,"widthInPixels",{get:function(){return this.width*this.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"heightInPixels",{get:function(){return this.height*this.tileHeight},enumerable:!0,configurable:!0}),c.prototype.createFromFileStore=function(c,d,e){void 0===e&&(e=0);var f=null;switch(a.Utils.Common.isString(d)&&(d=this.state.textures[d]),typeof c){case"string":if(0==this.game.fileStore.exists(c))return a.Log.error("The JSON file you have told to use for a TileMap does not exist.","#tilemap","#json"),!1;f=JSON.parse(this.game.fileStore.getFile(c).data);break;case"object":f=c.isData&&c.dataType===a.Files.File.JSON?a.Utils.Common.isString(c.parse)?JSON.parse(c.data):c.data:c;break;default:a.Log.error("The type of TileMapData passed could not be idenified. Please either pass a name of JSON file to use OR an object to be used.","#tilemap")}this.orientation=void 0==f.orientation?b.ORTHOGONAL:f.orientation,this.tileWidth=void 0==f.tilewidth?32:f.tilewidth,this.tileHeight=void 0==f.tileheight?32:f.tileheight,this.width=f.width,this.height=f.height;for(var g in f.properties)this.properties[g]=f.properties[g];"undefined"!==f.tilesets&&-1!==e&&this._generateTypesFromTileset(f.tilesets,d,e);for(var h=0;hl;l+=h)for(var m=f;i>m;m+=g){var n=void 0==b.cells[c]?-1:c,o=this.createTileType(n);o.offset.x=k.x,o.offset.y=k.y,c++}for(var p in e.tileproperties){var o=this.tileTypes[parseInt(e.firstgid)+parseInt(p)];o.properties=e.tileproperties[p]}}},c.prototype.setTo=function(a,b,c,d){this.tileWidth=a,this.tileHeight=b,this.width=c,this.height=d},c.prototype.createTileType=function(a){void 0===a&&(a=-1);var c=new b.TileType(this,this.tileTypes.length,a);return this.tileTypes.push(c),c},c.prototype.createTileTypes=function(a){for(var b=[],c=0;c=d;d++)c.push(this.createTileType(d));return c},c.prototype.setCell=function(a,b){this.tileTypes[a].cellIndex=b},c.prototype.setCellsByRange=function(a,b,c){for(var d=a;a+c>d;d++)this.tileTypes[d].cellIndex=b,b++},c.prototype.createNewLayer=function(c,d,e,f,g,h,i,j,k,l){if(void 0===e&&(e=[]),void 0===f&&(f=this.width),void 0===g&&(g=this.height),void 0===h&&(h=0),void 0===i&&(i=0),void 0===j&&(j=this.tileWidth),void 0===k&&(k=this.tileHeight),void 0===l&&(l=this.orientation),e.lengthc||c>=this._data.length?-1:c},c.prototype.getTileFromXY=function(a,b){var c=this.getIndexFromXY(a,b);return-1!==c?this.tilemap.tileTypes[this._data[c]]:null},c.prototype.getIndexesByType=function(a){for(var b=[],c=0;cg;g++)for(var f=b;b+d>f;f++){var h=this.getIndexFromXY(f,g);-1!==h&&(this._data[h]=this.game.rnd.pick(a))}},c.prototype.fill=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height);for(var f=c;c+e>f;f++)for(var g=b;b+d>g;g++){var h=this.getIndexFromXY(g,f);-1!==h&&(this._data[h]=a)}},c.prototype.replaceTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&this._data[i]==a&&(this._data[i]=b)}},c.prototype.swapTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&(this._data[i]==a?this._data[i]=b:this._data[i]==b&&(this._data[i]=a))}},c.prototype.getOverlappingTiles=function(b,c){return void 0===c&&(c=a.Components.ArcadePhysics.ANY),[]},c.prototype.getCollidableTiles=function(b,c,d,e,f){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height),void 0===f&&(f=a.Components.ArcadePhysics.ANY);var g=[];if(!(b>this.width||c>this.height)){0>b&&(b=0),0>c&&(c=0),b+d>this.width&&(d=this.width-b),c+e>this.height&&(e=this.height-c);for(var h=c;c+e>h;h++)for(var i=b;b+d>i;i++){var j=this.getIndexFromXY(i,h);if(-1!==j){var k=this.tileData[j];(this.tilemap.tileTypes[k].allowCollisions&f)!==a.Components.ArcadePhysics.NONE&&g.push({index:j,type:k,x:i*this.tileWidth,y:h*this.tileHeight})}}return g}},c.prototype.update=function(){b.prototype.update.call(this)},c.prototype._calculateBoundaries=function(){this._startX=0,this._startY=0,this._maxX=this.width,this._maxY=this.height},c.prototype.render=function(){},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null)},c.prototype.chartToScreen=function(a,b,c){return void 0===b&&(b=this.tileWidth/2),void 0===c&&(c=this.tileHeight),{x:a.x*b-a.y*b,y:a.x*c/2+a.y*c/2}},c.prototype.screenToChart=function(a,b,c){void 0===b&&(b=this.tileWidth/2),void 0===c&&(c=this.tileHeight);var d=Math.floor(a.x/b),e=Math.floor((a.y-d*(c/2))/c);return{x:d+e,y:e}},c}(a.Entity);b.TileMapLayer=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(c){function d(a,d,e,f,g,h,i,j,k,l){void 0===i&&(i=0),void 0===j&&(j=0),void 0===k&&(k=0),void 0===l&&(l=0),c.call(this,a,d,e,f,g,h,i,j,k,l),this.orientation=b.ORTHOGONAL}return __extends(d,c),d.prototype.objType=function(){return"TileMapLayer"},d.prototype.getIndexFromCoords=function(b,c){if(b>this.transform.worldX+this.widthInPixels||c>this.transform.worldY+this.heightInPixels||be+this.widthInPixels||d.rightf+this.heightInPixels)return[];for(var g=d.x-e,h=d.y-f,i=a.Utils.GameMath.snapToFloor(g,this.tileWidth)/this.tileWidth,j=a.Utils.GameMath.snapToFloor(h,this.tileHeight)/this.tileHeight,k=a.Utils.GameMath.snapToCeil(d.width,this.tileWidth)/this.tileWidth,l=a.Utils.GameMath.snapToCeil(d.height,this.tileHeight)/this.tileHeight,m=this.getCollidableTiles(i,j,k+1,l+1,c),n=0;nd.right||o.x+this.tileWidth+ed.bottom||o.y+this.tileHeight+f0&&this.alpha<=1&&(b.globalAlpha=this.alpha);var c=this.transform,d=c.getConcatenatedMatrix();b.transform(d.a,d.b,d.c,d.d,d.tx,d.ty),this._calculateBoundaries(a,d);for(var e=this._startY;ethis.x+c||athis.y+this.heightInPixels||b0&&this.alpha<=1&&(b.globalAlpha=this.alpha);var c=this.transform,d=c.getConcatenatedMatrix();b.transform(d.a,d.b,d.c,d.d,d.tx,d.ty),this._calculateBoundaries(a,d);for(var e=this._startY;e1)&&(this._nowEntered=b),this.isDown===!1&&b.frameDuration<2&&(this._nowDown=b),this._dragEnabled&&0==this.isDragging&&1==this.isDown&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top,this._nowDragging=b)):this.isDown===!0?this._nowLeft=b:this.withinBounds===!0&&this._withinBounds.id==b.id&&(this._nowLeft=b))},c.prototype._updateMouse=function(){this._evaluateMousePointer(this.game.input.mouse.cursor),null!==this._nowLeft&&this._onLeft.dispatch(this.owner,this._nowLeft),null!==this._nowEntered&&this._onEntered.dispatch(this.owner,this._nowEntered),null!==this._nowDown&&this.isDown===!1&&(this._onDown.dispatch(this.owner,this._nowDown),this._isDown=this._nowDown,this._isUp=!1),1==this._dragEnabled&&this.isDragging===!1&&null!==this._nowDragging&&(this._onDragStarted.dispatch(this.owner,this._nowDragging),this._isDragging=this._nowDragging),this.isDown===!0&&null!==this._nowUp&&this._isDown.id===this._nowUp.id&&(this._onUp.dispatch(this.owner,this._nowUp),this.isDragging===!0&&this._isDragging.id==this._nowUp.id&&(this._isDragging=null,this._onDragStopped.dispatch(this.owner,this._nowUp)),this._isDown=null,this._isUp=!0)},c.prototype._evaluateMousePointer=function(b){this._tempPoint=this.game.cameras.defaultCamera.transformPoint(b.point),a.Geom.Intersect.pointToRectangle(this._tempPoint,this._box.worldHitbox).result?(this._dragEnabled&&this.isDragging===!1&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top),this.withinBounds===!1&&(this._nowEntered=b,this._withinBounds=b,this._outsideBounds=!1,this._justEntered=!0)):this.withinBounds===!0&&this.isDragging===!1&&(this._nowLeft=b,this._withinBounds=null,this._outsideBounds=!0),b.isDown===!0?(this._justEntered&&(this._isDown=b,this._isUp=!1,this._tempDragDisabled=!0),this.withinBounds===!0&&this.isDown===!1&&null===this._nowDown&&(this._nowDown=b),this._dragEnabled===!0&&0==this.isDragging&&this._tempDragDisabled===!1&&1==this.isDown&&(this._nowDragging=b)):(this._tempDragDisabled===!0&&(this._tempDragDisabled=!1),this.isDown===!0&&(this._nowUp=b)),this._justEntered&&(this._justEntered=!1)},c.prototype.destroy=function(){b.prototype.destroy.call(this),this.enabled=!1,delete this._box,delete this._isDown,delete this._isUp,delete this._isDragging,delete this._dragEnabled,this._onDown&&this._onDown.dispose(),delete this._onDown,this._onDragStarted&&this._onDragStarted.dispose(),delete this._onDragStarted,this._onUp&&this._onUp.dispose(),delete this._onUp,this._onLeft&&this._onLeft.dispose(),delete this._onLeft,this._onEntered&&this._onEntered.dispose(),delete this._onEntered,this._onDragStopped&&this._onDragStopped.dispose(),delete this._onDragStopped,delete this._dragDistance},c}(a.Component);b.Input=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b,"Sound"),this._audio=[]}return __extends(b,a),b.prototype.objType=function(){return"Sound"},b.prototype.addSound=function(a,b,c,d){if(void 0===c&&(c=1),void 0===d&&(d=!1),1!=this._validate(a)){var e=this.game.audio.add(b,c,d);return this._audio[a]=e,e}},b.prototype.removeSound=function(a){0!=this._validate(a)&&(this._audio[a].stop(),this._audio[a].destroy(),delete this._audio[a])},b.prototype.getSound=function(a){return 0!=this._validate(a)?this._audio[a]:void 0},b.prototype._validate=function(a){return void 0===this._audio[a]?!1:!0},b.prototype.play=function(a){0!=this._validate(a)&&this._audio[a].play()},b.prototype.stop=function(a){0!=this._validate(a)&&this._audio[a].stop()},b.prototype.pause=function(a){0!=this._validate(a)&&this._audio[a].pause()},b.prototype.resume=function(a){0!=this._validate(a)&&this._audio[a].resume()},b.prototype.destroy=function(){a.prototype.destroy.call(this);for(var b in this._audio)this._audio[b].stop(),this._audio[b].destroy(),delete this._audio[b];delete this._audio},b}(a.Component);b.Sound=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(d,e){b.call(this,d,"ArcadePhysics"),this._callbackFunction=null,this._callbackContext=null,this.parent=d,this.box=e,this.transform=this.parent.transform,this.last=new a.Geom.Point(this.transform.worldX,this.transform.worldY),this.mass=1,this.elasticity=0,this.immovable=!1,this.moves=!0,this.touching=c.NONE,this.wasTouching=c.NONE,this.allowCollisions=c.ANY,this.velocity=new a.Geom.Point,this.acceleration=new a.Geom.Point,this.drag=new a.Geom.Point,this.maxVelocity=new a.Geom.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e4}return __extends(c,b),c.prototype.isTouching=function(a){return(this.touching&a)==a},c.prototype.solid=function(a){return void 0!==a&&(this.allowCollisions=a?c.ANY:c.NONE),(this.allowCollisions&c.ANY)>c.NONE},c.prototype.setCallback=function(a,b){this._callbackFunction=a,this._callbackContext=b},c.prototype.rotateToVelocity=function(){var a=Math.atan2(this.velocity.y,this.velocity.x);return this.transform.rotation=a,a},c.separate=function(a,b){var c=this.separateX(a,b),d=this.separateY(a,b);return c||d},c.separateX=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldX-e.last.x,i=f.transform.worldX-f.last.x;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x-(h>0?h:0),e.last.y+e.box.hitboxOffset.y,l.width+(h>0?h:-h),l.height),o=new a.Geom.Rectangle(m.x-(i>0?i:0),f.last.y+f.box.hitboxOffset.y,m.width+(i>0?i:-i),m.height);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.x+l.width-m.x,!(g>p)&&e.allowCollisions&c.RIGHT&&f.allowCollisions&c.LEFT?(e.touching|=c.RIGHT,f.touching|=c.LEFT):g=0):(g=l.x-m.width-m.x,!(-g>p)&&e.allowCollisions&c.LEFT&&f.allowCollisions&c.RIGHT?(e.touching|=c.LEFT,f.touching|=c.RIGHT):g=0)}if(0!=g){var q=e.velocity.x,r=f.velocity.x;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.x=f.transform.x+g,f.velocity.x=q-r*f.elasticity):(e.transform.x=e.transform.x-g,e.velocity.x=r-q*e.elasticity);else{g*=.5,e.transform.x=e.transform.x-g,f.transform.x=f.transform.x+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.x=u+s*e.elasticity,f.velocity.x=u+t*f.elasticity}return!0}return!1},c.separateY=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldY-e.last.y,i=f.transform.worldY-f.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x,l.y-(h>0?h:0),l.width,l.height+j),o=new a.Geom.Rectangle(m.x,m.y-(i>0?i:0),m.width,m.height+k);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.y+l.height-m.y,!(g>p)&&e.allowCollisions&c.DOWN&&f.allowCollisions&c.UP?(e.touching|=c.DOWN,f.touching|=c.UP):g=0):(g=l.y-m.height-m.y,!(-g>p)&&e.allowCollisions&c.UP&&f.allowCollisions&c.DOWN?(e.touching|=c.UP,f.touching|=c.DOWN):g=0),0!=g){var q=e.velocity.y,r=f.velocity.y;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.y=f.transform.y+g,f.velocity.y=q-r*f.elasticity,b.active&&e.moves&&i>h&&(f.transform.x=f.transform.worldX+b.transform.worldX-e.last.x)):(e.transform.y=e.transform.y-g,e.velocity.y=r-q*e.elasticity,d.active&&f.moves&&h>i&&(e.transform.x=e.transform.worldX+d.transform.worldX-f.last.x));else{g*=.5,e.transform.y=e.transform.y-g,f.transform.y=f.transform.y+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.y=u+s*e.elasticity,f.velocity.y=u+t*f.elasticity}return!0}}return!1},c.separateTiles=function(a,b,c){if(0==a.components.hasComponent("ArcadePhysics"))return!1;if(a.components.getComponent("ArcadePhysics").immovable)return!1;for(var d=!1,e=!1,f=0;f0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=g.transform.worldX+e.x,r=new a.Geom.Rectangle(n.x-(h>0?h:0),f.last.y+f.box.hitboxOffset.y,n.width+(h>0?h:-h),n.height),s=new a.Geom.Rectangle(q-(i>0?i:0),g.last.y+e.y,d.tileWidth+(i>0?i:-i),d.tileHeight);if(r.x+r.width>s.x&&r.xs.y&&r.y-1i?(l=n.x+n.width-q,!(l>m)&&f.allowCollisions&c.RIGHT&&o[p[e.index]].allowCollisions&c.LEFT?f.touching|=c.RIGHT:l=0):(l=n.x-d.tileWidth-q,!(-l>m)&&f.allowCollisions&c.LEFT&&o[p[e.index]].allowCollisions&c.RIGHT?f.touching|=c.LEFT:l=0),0!=l)){var t=f.velocity.x,u=g.velocity.x;return f.transform.x=f.transform.x-l,f.velocity.x=u-t*f.elasticity,!0}return!1},c.separateTilesY=function(b,d,e){var f=b.components.getComponent("ArcadePhysics"),g=d.components.getComponent("ArcadePhysics"),h=f.transform.worldY-f.last.y,i=g.transform.worldY-g.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=d.transform.worldY+e.y,r=new a.Geom.Rectangle(n.x,n.y-(h>0?h:0),n.width,n.height+j),s=new a.Geom.Rectangle(g.transform.worldX+e.x,q-(i>0?i:0),d.tileWidth,d.tileHeight+k);if(r.x+r.width>s.x&&r.xs.y&&r.yi?(l=n.y+n.height-q,!(l>m)&&f.allowCollisions&c.DOWN&&o[p[e.index]].allowCollisions&c.UP?f.touching|=c.DOWN:l=0):(l=n.y-d.tileHeight-q,!(-l>m)&&f.allowCollisions&c.UP&&o[p[e.index]].allowCollisions&c.DOWN?f.touching|=c.UP:l=0),0!=l)){var t=f.velocity.y,u=g.velocity.y;return f.transform.y=f.transform.y-l,f.velocity.y=u-t*f.elasticity,!0}return!1},c.prototype.overlapsTiles=function(b,d,e){if(void 0===d&&(d=!1),void 0===e&&(e=a.Components.ArcadePhysics.ANY),this.parent.childType()!==a.TILE_LAYER)return!1;var f=this.parent.getOverlappingTiles(b,e);return f.length>0?(d&&c.separateTiles(b,this.parent,f),!0):!1},c.prototype.overlaps=function(a,b){if(void 0===b&&(b=!1),0!=a.components.hasComponent("Box")){var d=a.components.getComponent("Box"),e=d.worldHitbox.x+d.worldHitbox.width>this.box.worldHitbox.x&&d.worldHitbox.xthis.box.worldHitbox.y&&d.worldHitbox.y0?a-=d:0>a+d?a+=d:a=0),0!=a&&1e4!=e&&(a>e?a=e:-e>a&&(a=-e)),a},c.prototype.updateMotion=function(){var a,b;b=(c.computeVelocity(this.angularVelocity,this.angularAcceleration,this.angularDrag,this.maxAngular)-this.angularVelocity)/2,this.angularVelocity+=b,this.transform.rotation+=this.angularVelocity*c.updateInterval,this.angularVelocity+=b,b=(c.computeVelocity(this.velocity.x,this.acceleration.x,this.drag.x,this.maxVelocity.x)-this.velocity.x)/2,this.velocity.x+=b,a=this.velocity.x*c.updateInterval,this.velocity.x+=b,this.transform.x=this.transform.x+a,b=(c.computeVelocity(this.velocity.y,this.acceleration.y,this.drag.y,this.maxVelocity.y)-this.velocity.y)/2,this.velocity.y+=b,a=this.velocity.y*c.updateInterval,this.velocity.y+=b,this.transform.y=this.transform.y+a},c.prototype.update=function(){this.last.x=this.transform.worldX,this.last.y=this.transform.worldY,this.moves&&this.updateMotion(),this.wasTouching=this.touching,this.touching=c.NONE},c.prototype.destroy=function(){b.prototype.destroy.call(this),delete this.transform,delete this.owner,delete this._callbackContext,delete this._callbackFunction},c.prototype.objType=function(){return"ArcadePhysics"},c.collide=function(a,b,d){return void 0===d&&(d=!0),c.overlaps(a,b,d)},c.collideGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsObjectGroup(a,b,d)},c.collideGroupGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsGroupGroup(a,b,d)},c.overlaps=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlaps(b,c)},c.overlapsObjectGroup=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlapsGroup(b,c)},c.overlapsGroupGroup=function(b,d,e){void 0===e&&(e=!0);for(var f=!1,g=b.members,h=0;h=this._loadingList.length&&(this._queueLoading=!1,this.clearQueue(),this.onQueueComplete.dispatch()))},b.prototype._startLoadingQueue=function(){return this._loadingQueue.length<=0?(a.Log.log("Kiwi.Files.Loader: No queued files to load.","#loading"),!1):this._loadingQueue[0].loading?!1:(this._loadingQueue[0].onComplete.addOnce(this._queueFileComplete,this,1),this._loadingQueue[0].load(),!0)},b.prototype._queueFileComplete=function(b){var c=this._loadingQueue.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingQueue.","#loading","#error"):(this._loadingQueue.splice(c,1),void this._startLoadingQueue())},b.prototype._startLoadingParallel=function(a){a.loading||(a.onComplete.add(this._parallelFileComplete,this,1),a.load())},b.prototype._startLoadingAllParallel=function(){for(var a=this._loadingParallel.length;a--;)this._startLoadingParallel(this._loadingParallel[a])},b.prototype._parallelFileComplete=function(b){var c=this._loadingParallel.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingParallel.","#loading","#error"):void this._loadingParallel.splice(c,1)},Object.defineProperty(b.prototype,"bytesTotal",{get:function(){return this._bytesTotal},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bytesLoaded",{get:function(){return this._bytesLoaded},enumerable:!0,configurable:!0}),b.prototype.calculateQueuedSize=function(b,c){return void 0===c&&(c=null),this._queueLoading?void a.Log.warn("Kiwi.Files.Loader: Cannot calculate the size of the files in the filequeue whilst they are loading. "):(this.onSizeCallback=b,this.onSizeContext=c,this._currentFileIndex=0,this._bytesTotal=0,this._queueLoading=!0,void this._calculateNextFileSize())},b.prototype._calculateNextFileSize=function(){if(this._currentFileIndex>=this._loadingList.length)return this._queueLoading=!1,void this.onSizeCallback.call(this.onSizeContext,this._bytesTotal);var a=this._loadingList[this._currentFileIndex];if(a.detailsReceived)this._detailsReceived();else{var b=a.loadDetails(this._detailsReceived,this);b||this._detailsReceived()}},b.prototype._detailsReceived=function(){var a=this._loadingList[this._currentFileIndex];a.detailsReceived&&(this._bytesTotal+=a.size),this._currentFileIndex++,this._calculateNextFileSize()},b.prototype.addImage=function(b,c,d,e,f,g,h){void 0===h&&(h=!0);var i={type:a.Files.File.IMAGE,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var j=b;i.key=j.key,i.url=j.url,i.metadata={width:j.width,height:j.height,offsetX:j.offsetX,offsetY:j.offsetY},j.xhrLoading&&(i.xhrLoading=j.xhrLoading),j.state&&(i.state=j.state),j.tags&&(i.tags=j.tags)}else!h&&this.game.states.current&&(i.state=this.game.states.current),i.key=b,i.url=c,i.metadata={width:d,height:e,offsetX:f,offsetY:g};var k=new a.Files.TextureFile(this.game,i);return this.addFileToQueue(k),k},b.prototype.addSpriteSheet=function(b,c,d,e,f,g,h,i,j,k,l,m){void 0===m&&(m=!0);var n={type:a.Files.File.SPRITE_SHEET,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var o=b;n.key=o.key,n.url=o.url,n.metadata={frameWidth:o.frameWidth,frameHeight:o.frameHeight,numCells:o.numCells,rows:o.rows,cols:o.cols,sheetOffsetX:o.sheetOffsetX,sheetOffsetY:o.sheetOffsetY,cellOffsetX:o.cellOffsetX,cellOffsetY:o.cellOffsetY},o.xhrLoading&&(n.xhrLoading=o.xhrLoading),o.state&&(n.state=o.state),o.tags&&(n.tags=o.tags)}else!m&&this.game.states.current&&(n.state=this.game.states.current),n.key=b,n.url=c,n.metadata={frameWidth:d,frameHeight:e,numCells:f,rows:g,cols:h,sheetOffsetX:i,sheetOffsetY:j,cellOffsetX:k,cellOffsetY:l};var p=new a.Files.TextureFile(this.game,n);return this.addFileToQueue(p),p},b.prototype.addTextureAtlas=function(b,c,d,e,f){void 0===f&&(f=!0);var g={type:a.Files.File.TEXTURE_ATLAS,key:b,url:c,fileStore:this.game.fileStore,metadata:{jsonID:d}},h={type:a.Files.File.JSON,key:d,url:e,fileStore:this.game.fileStore,metadata:{imageID:b}};if(!f&&this.game.states.current&&(g.state=this.game.states.current,h.state=this.game.states.current),a.Utils.Common.isObject(b)){var i=b;g.key=i.textureAtlasKey,g.url=i.textureAtlasURL,h.key=i.jsonKey,h.url=i.jsonURL,g.metadata.jsonID=h.key,h.metadata.imageID=g.key,i.state&&(g.state=i.state,h.state=i.state),i.xhrLoading&&(g.xhrLoading=i.xhrLoading),i.tags&&(h.tags=i.tags,g.tags=i.tags)}var j=new a.Files.TextureFile(this.game,g),k=new a.Files.DataFile(this.game,h);return this.addFileToQueue(j),this.addFileToQueue(k),j},b.prototype.addAudio=function(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!0);var f={type:a.Files.File.AUDIO,key:null,url:null,state:null,fileStore:this.game.fileStore};a.Utils.Common.isObject(b)?(f=b,f.type=a.Files.File.AUDIO,f.fileStore=this.game.fileStore):(f.key=b,f.url=c,!d&&this.game.states.current&&(f.state=this.game.states.current));var g,h,i=0;for(g=a.Utils.Common.isString(f.url)?[f.url]:f.url;i-1?(this.name=a.substr(a.lastIndexOf("/")+1),this.path=a.substr(0,a.lastIndexOf("/")+1)):(this.path="",this.name=a),this.extension=a.substr(a.lastIndexOf(".")+1).toLowerCase()},b.prototype.objType=function(){return"File"},Object.defineProperty(b.prototype,"loadInParallel",{get:function(){return this._loadInParallel},enumerable:!0,configurable:!0}),b.prototype.load=function(b,c,d,e,f){return this.loading?void a.Log.error("Kiwi.Files.File: File loading is in progress. Cannot be told to load again.","#loading"):(a.Log.log("Kiwi.Files.File: Starting to load '"+this.name+"'","#file","#loading"),b&&this.onComplete.add(b),c&&this.onProgress.add(c),d&&(this.fileStore=d),"undefined"!=typeof e&&(this.maxLoadAttempts=e),"undefined"!=typeof f&&(this.timeOutDelay=f),this._start(),void this._load())},b.prototype._load=function(){this.attemptCounter++,this.xhrLoader("GET","text")},b.prototype.loadProgress=function(){this.onProgress.dispatch(this)},b.prototype.loadSuccess=function(){this.complete||(this.success=!0,this.hasError=!1,this._stop(),this.fileStore&&this.fileStore.addFile(this.key,this),this.onComplete.dispatch(this))},b.prototype.loadError=function(b){this.attemptCounter>=this.maxLoadAttempts?(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'. Trying Again","#loading"),this.hasError=!0,this.success=!1,this.error=b,this._stop(),this.onComplete.dispatch(this)):(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'","#loading"),this._load())},b.prototype.xhrLoader=function(a,b,c){var d=this;void 0===a&&(a="GET"),void 0===b&&(b="text"),void 0===c&&(c=this.timeOutDelay),this._xhr=new XMLHttpRequest,this._xhr.open(a,this.URL,!0),null!==c&&(this._xhr.timeout=c),this._xhr.responseType=b,this._xhr.onload=function(a){return d.xhrOnLoad(a)},this._xhr.onerror=function(a){return d.loadError(a)},this._xhr.onprogress=function(a){return d.xhrOnProgress(a)};var e=this;this._xhr.onreadystatechange=function(){e.readyState=e._xhr.readyState},this._xhr.onloadstart=function(a){e.timeStarted=a.timeStamp,e.lastProgress=a.timeStamp},this._xhr.ontimeout=function(){e.hasTimedOut=!0 -},this._xhr.onloadend=function(a){e.xhrOnLoad(a)},this._xhr.send()},b.prototype.xhrOnProgress=function(a){this.bytesLoaded=parseInt(a.loaded),this.bytesTotal=parseInt(a.total),this.percentLoaded=Math.round(this.bytesLoaded/this.bytesTotal*100),this.onProgress.dispatch(this)},b.prototype.xhrOnLoad=function(a){this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.status&&200===this.status||!this.status&&this._xhr.response?(this._getXhrHeaderInfo(),this.buffer=this._xhr.response,this.processXhr(this._xhr.response)):this.loadError(a)},b.prototype.processXhr=function(a){this.data=a,this.loadSuccess()},b.prototype._start=function(){this.attemptCounter=0,this.loading=!0,this.timeStarted=Date.now(),this.percentLoaded=0},b.prototype._stop=function(){this.loading=!1,this.complete=!0,this.percentLoaded=100,this.timeFinished=Date.now(),this.duration=this.timeFinished-this.timeStarted},b.prototype.loadDetails=function(b,c){return void 0===b&&(b=null),void 0===c&&(c=null),this.loading?(a.Log.error("Kiwi.Files.File: Cannot get the file details whilst the file is already loading"),!1):(b&&(this.headCompleteCallback=b),c&&(this.headCompleteContext=c),this.xhrHeadRequest(),!0)},b.prototype._getXhrHeaderInfo=function(){this._xhr&&(this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.type=this._xhr.getResponseHeader("Content-Type"),this.size=parseInt(this._xhr.getResponseHeader("Content-Length")),this.lastModified=this._xhr.getResponseHeader("Last-Modified"),this.ETag=this._xhr.getResponseHeader("ETag"),this.detailsReceived=!0)},b.prototype.xhrHeadRequest=function(){var a=this;this._xhr=new XMLHttpRequest,this._xhr.open("HEAD",this.fileURL,!0),null!==this.timeOutDelay&&(this._xhr.timeout=this.timeOutDelay),this._xhr.onload=function(b){return a.xhrHeadOnLoad(b)},this._xhr.onerror=function(b){return a.xhrHeadOnError(b)},this._xhr.send()},b.prototype.xhrHeadOnError=function(){this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!1)},b.prototype.xhrHeadOnLoad=function(){200===this._xhr.status?(this._getXhrHeaderInfo(),this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!0)):this.xhrHeadOnError(null)},b.prototype.addTag=function(a){-1==this._tags.indexOf(a)&&this._tags.push(a)},b.prototype.removeTag=function(a){var b=this._tags.indexOf(a);-1!=b&&this._tags.splice(b,1)},b.prototype.hasTag=function(a){return-1==this._tags.indexOf(a)?!1:!0},Object.defineProperty(b.prototype,"isTexture",{get:function(){return a.Files.TextureFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isAudio",{get:function(){return a.Files.AudioFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isData",{get:function(){return a.Files.DataFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this.fileStore&&this.fileStore.removeFile(this.key),this.onComplete.dispose(),this.onProgress.dispose(),delete this.fileStore,delete this._xhr,delete this.data,delete this.buffer,delete this.game,delete this.error,delete this.headCompleteCallback,delete this.headCompleteContext,delete this.onComplete,delete this.onProgress,delete this.ownerState},Object.defineProperty(b.prototype,"fileName",{get:function(){return this.name},set:function(a){this.name=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"filePath",{get:function(){return this.path},set:function(a){this.path=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileExtension",{get:function(){return this.extension},set:function(a){this.extension=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileURL",{get:function(){return this.URL},set:function(a){this.URL=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileType",{get:function(){return this.type},set:function(a){this.type=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileSize",{get:function(){return this.size},set:function(a){this.size=a},enumerable:!0,configurable:!0}),b.prototype.getFileDetails=function(a,b,c){void 0===a&&(a=null),void 0===c&&(c=null),c&&(this.timeOutDelay=c),this.loadDetails(a,null)},b.TIMEOUT_DELAY=null,b.MAX_LOAD_ATTEMPTS=2,b.IMAGE=0,b.SPRITE_SHEET=1,b.TEXTURE_ATLAS=2,b.AUDIO=3,b.JSON=4,b.XML=5,b.BINARY_DATA=6,b.TEXT_DATA=7,b.UNKNOWN=8,b}();b.File=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._size=0,this._game=a,this._files={}}return a.prototype.objType=function(){return"FileStore"},a.prototype.boot=function(){},a.prototype.getFile=function(a){return this._files[a]},a.prototype.getFilesByTag=function(a){var b={};for(var c in this._files)this._files[c].hasTag(a)&&(b[c]=this._files[c]);return b},a.prototype.removeFilesByTag=function(a){var b=0;for(var c in this._files)this._files[c].hasTag(a)&&(this.removeFile(c),b++);return b},Object.defineProperty(a.prototype,"keys",{get:function(){var a=new Array;for(var b in this._files)a.push(b);return a},enumerable:!0,configurable:!0}),a.prototype.size=function(){return this._size},a.prototype.addFile=function(a,b){return this._files[a]?!1:(this._files[a]=b,this._size++,!0)},a.prototype.exists=function(a){return this._files[a]?!0:!1},a.prototype.removeStateFiles=function(a){for(var b in this._files)this._files[b].ownerState===a&&this.removeFile(b)},a.prototype.removeGlobalFiles=function(){for(var a in this._files)this._files[a].ownerState||this.removeFile(a)},a.prototype.removeFile=function(a,b){void 0===b&&(b=!1);var c=this._files[a];return c?(this._files[a]=null,delete this._files[a],b&&c.destroy(),!0):!1},a.prototype.removeAllFiles=function(){for(var a in this._files)this.removeFile(a)},a}();a.FileStore=b}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){this.isReady=!1,this.container=null,this.input=null}return b.prototype.objType=function(){return"Bootstrap"},b.prototype.boot=function(a,b,c){var d=this;void 0===b&&(b=null),void 0===c&&(c=!0),this._callback=b,this._domParent=a,this._createContainer=c,"complete"===document.readyState||"interactive"===document.readyState?this.ready():(document.addEventListener("DOMContentLoaded",function(){return d.ready()},!1),window.addEventListener("load",function(){return d.ready()},!1))},b.prototype.ready=function(){var b=this;this.isReady!==!0&&(document.body?(this.isReady=!0,this._createContainer===!0&&(""===this._domParent?(a.Log.log(" Kiwi.Game: No DOM parent specified. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer("KiwiGame"+Date.now().toString()),document.body.appendChild(this.container)):document.querySelector(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.querySelector(this._domParent),this._setupContainer()):document.getElementById(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.getElementById(this._domParent),this._setupContainer()):(a.Log.log(" Kiwi.Game: The element '"+this._domParent+"' could not be found. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer(this._domParent),document.body.appendChild(this.container))),null!==this._callback&&this._callback()):window.setTimeout(function(){return b.ready()},13))},b.prototype._setupContainer=function(b){void 0===b&&(b=""),b&&(this.container.id=b),this.container.style.width=a.Stage.DEFAULT_WIDTH+"px",this.container.style.height=a.Stage.DEFAULT_HEIGHT+"px",this.container.style.position="relative",this.container.style.overflow="hidden"},b}();b.Bootstrap=c}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.blob=!1,this.touch=!1,this.pointerEnabled=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.ieMobile=!1,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.mp3=!1,this.wav=!1,this.m4a=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkDevice(),this._checkFeatures(),this._checkOS()}return a.prototype.objType=function(){return"Device"},a.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 Phone/.test(a)?this.windowsPhone=!0:/Windows/.test(a)&&(this.windows=!0)},a.prototype._checkFeatures=function(){"undefined"!=typeof window.Blob&&(this.blob=!0),this.canvas=!!window.CanvasRenderingContext2D,this.webGL=!!window.WebGLRenderingContext;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.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0)&&(this.touch=!0),(window.navigator.pointerEnabled||window.navigator.msPointerEnabled)&&(this.pointerEnabled=!0)},a.prototype._checkBrowser=function(){{var a=navigator.userAgent;navigator.appName}/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),/IEMobile/.test(a)&&(this.ieMobile=!0)):/Trident/.test(a)?(this.ie=!0,/rv:(\d+\.\d+)\)/.test(a),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)},a.prototype._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/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))}catch(c){}},a.prototype._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")},a.prototype.getAll=function(){var a="";return a=a.concat("Device\n"),a=a.concat("iPhone : "+this.iPhone+"\n"),a=a.concat("iPhone4 : "+this.iPhone4+"\n"),a=a.concat("iPad : "+this.iPad+"\n"),a=a.concat("\n"),a=a.concat("Operating System\n"),a=a.concat("iOS: "+this.iOS+"\n"),a=a.concat("Android: "+this.android+"\n"),a=a.concat("ChromeOS: "+this.chromeOS+"\n"),a=a.concat("Linux: "+this.linux+"\n"),a=a.concat("MacOS: "+this.macOS+"\n"),a=a.concat("Windows: "+this.windows+"\n"),a=a.concat("\n"),a=a.concat("Browser\n"),a=a.concat("Arora: "+this.arora+"\n"),a=a.concat("Chrome: "+this.chrome+"\n"),a=a.concat("Epiphany: "+this.epiphany+"\n"),a=a.concat("Firefox: "+this.firefox+"\n"),a=a.concat("Internet Explorer: "+this.ie+" ("+this.ieVersion+")\n"),a=a.concat("Mobile Safari: "+this.mobileSafari+"\n"),a=a.concat("Midori: "+this.midori+"\n"),a=a.concat("Opera: "+this.opera+"\n"),a=a.concat("Safari: "+this.safari+"\n"),a=a.concat("\n"),a=a.concat("Features\n"),a=a.concat("Blob: "+this.blob+"\n"),a=a.concat("Canvas: "+this.canvas+"\n"),a=a.concat("File: "+this.file+"\n"),a=a.concat("FileSystem: "+this.fileSystem+"\n"),a=a.concat("LocalStorage: "+this.localStorage+"\n"),a=a.concat("WebGL: "+this.webGL+"\n"),a=a.concat("Worker: "+this.worker+"\n"),a=a.concat("Touch: "+this.touch+"\n"),a=a.concat("\n"),a=a.concat("Audio\n"),a=a.concat("Audio Data: "+this.canvas+"\n"),a=a.concat("Web Audio: "+this.canvas+"\n"),a=a.concat("Can play OGG: "+this.canvas+"\n"),a=a.concat("Can play MP3: "+this.canvas+"\n"),a=a.concat("Can play M4A: "+this.canvas+"\n"),a=a.concat("Can play WAV: "+this.canvas+"\n")},a}();a.Device=b}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e){this.dirty=!1,this.cellIndex=0,this.name=a,this.cells=c||new Array,this.sequences=e||new Array,this.image=d,this._type=b}return b.prototype.objType=function(){return"TextureAtlas"},Object.defineProperty(b.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),b.prototype.createGLTextureWrapper=function(b,c){this.glTextureWrapper=new a.Renderers.GLTextureWrapper(b,this),c.registerTextureWrapper(b,this.glTextureWrapper)},b.prototype.enableGL=function(a,b,c){b.updateTextureSize(a,new Float32Array([this.image.width,this.image.height])),c.useTexture(a,this.glTextureWrapper),this.dirty&&this.refreshTextureGL(a)},b.prototype.refreshTextureGL=function(a){this.glTextureWrapper&&this.glTextureWrapper.refreshTexture(a),this.dirty=!1},b.prototype.readJSON=function(b){var c=JSON.parse(b);void 0!==c.name&&(this.name=c.name);for(var d=0;d=this.numCells||(b.push({x:d,y:e,w:this.cellWidth,h:this.cellHeight,hitboxes:[{x:0,y:0,w:this.cellWidth,h:this.cellHeight}]}),c.push(f++),d+=this.cellOffsetX+this.cellWidth);d=this.sheetOffsetX,e+=this.cellOffsetY+this.cellHeight}return this.sequences=new Array,this.sequences.push(new a.Animations.Sequence("default",c)),b},c}(b.TextureAtlas);b.SpriteSheet=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h){this.width=e||d.width,this.height=f||d.height,this.offsetX=g||0,this.offsetY=h||0,b.call(this,c,a.Textures.TextureAtlas.SINGLE_IMAGE,this.generateAtlasCells(),d)}return __extends(c,b),c.prototype.objType=function(){return"SingleImage"},c.prototype.generateAtlasCells=function(){return[{x:this.offsetX,y:this.offsetY,w:this.width,h:this.height,hitboxes:[{x:0,y:0,w:this.width,h:this.height}]}]},c}(b.TextureAtlas);b.SingleImage=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Back"},a.In=function(a){var b=1.70158;return a*a*((b+1)*a-b)},a.Out=function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},a.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)},a}();a.Back=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"Bounce"},b.In=function(b){return 1-a.Animations.Tweens.Easing.Bounce.Out(1-b)},b.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},b.InOut=function(b){return.5>b?.5*a.Animations.Tweens.Easing.Bounce.In(2*b):.5*a.Animations.Tweens.Easing.Bounce.Out(2*b-1)+.5},b}();b.Bounce=c}(c=b.Easing||(b.Easing={}))}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Circular"},a.In=function(a){return 1-Math.sqrt(1-a*a)},a.Out=function(a){return Math.sqrt(1- --a*a)},a.InOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},a}();a.Circular=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Cubic"},a.In=function(a){return a*a*a},a.Out=function(a){return--a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},a}();a.Cubic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Elastic"},a.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(2*(a-b)*Math.PI/d)))},a.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(2*(a-b)*Math.PI/d)+1)},a.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(2*(a-b)*Math.PI/d):c*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d)*.5+1)},a}();a.Elastic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Exponential"},a.In=function(a){return 0===a?0:Math.pow(1024,a-1)},a.Out=function(a){return 1===a?1:1-Math.pow(2,-10*a)},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)},a}();a.Exponential=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Linear"},a.None=function(a){return a},a}();a.Linear=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quadratic"},a.In=function(a){return a*a},a.Out=function(a){return a*(2-a)},a.InOut=function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)},a}();a.Quadratic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quartic"},a.In=function(a){return a*a*a*a},a.Out=function(a){return 1- --a*a*a*a},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)},a}();a.Quartic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quintic"},a.In=function(a){return a*a*a*a*a},a.Out=function(a){return--a*a*a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)},a}();a.Quintic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Sinusoidal"},a.In=function(a){return 1-Math.cos(a*Math.PI/2)},a.Out=function(a){return Math.sin(a*Math.PI/2)},a.InOut=function(a){return.5*(1-Math.cos(Math.PI*a))},a}();a.Sinusoidal=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(a,b){this._game=a,this._tweens=[],this.clock=b||this._game.time.clock}return b.prototype.objType=function(){return"TweenManager"},b.prototype.getAll=function(){return this._tweens},b.prototype.removeAll=function(){this._tweens.length=0},b.prototype.create=function(b){var c=new a.Animations.Tween(b,this._game);return this.validateClock(),c.manager=this,c},b.prototype.add=function(a){return a.setParent(this._game),a.manager=this,this.validateClock(),this._tweens.push(a),a},b.prototype.remove=function(a){var b=this._tweens.indexOf(a);return-1!==b&&this._tweens.splice(b,1),a},b.prototype.update=function(){var a=0,b=this._tweens.length;if(0===this._tweens.length)return!1;for(;b>a;)this._tweens[a].update(1e3*this.clock.elapsed())?a++:(this._tweens.splice(a,1),b--);return!0},b.prototype.validateClock=function(){this.clock||(this.clock=this._game.time.clock,this.clock||a.Log.error("Tween manager could not find valid clock!"))},b}();b.TweenManager=c}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){void 0===c&&(c=null),this._game=null,this._manager=null,this._object=null,this._valuesStart={},this._valuesEnd={},this._duration=1e3,this._delayTime=0,this._startTime=null,this._easingFunction=a.Animations.Tweens.Easing.Linear.None,this._interpolationFunction=a.Utils.GameMath.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartContext=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onUpdateContext=null,this._onCompleteCallback=null,this._onCompleteCalled=!1,this._onCompleteContext=null,this.isRunning=!1,this._object=b,null!==c&&(this._game=c,this._manager=this._game.tweens),this.isRunning=!1}return b.prototype.objType=function(){return"Tween"},Object.defineProperty(b.prototype,"manager",{get:function(){return this._manager},set:function(a){this._manager=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"object",{get:function(){return this._object},set:function(a){var b,c={};this._object=a;for(b in this._valuesEnd)a[b]&&(c[b]=this._valuesEnd[b]);this._valuesEnd=c},enumerable:!0,configurable:!0}),b.prototype.to=function(a,b,c,d){return void 0===b&&(b=1e3),void 0===c&&(c=null),void 0===d&&(d=!1),this._duration=b,this._valuesEnd=a,null!==c&&(this._easingFunction=c),d===!0?this.start():this},b.prototype.start=function(){var a;if(null!==this._game&&null!==this._object){this.isRunning=!0,this._manager.add(this),this._onStartCallbackFired=!1,this._onCompleteCalled=!1,this._startTime=1e3*this._manager.clock.elapsed()+this._delayTime;for(var a in this._valuesEnd)if(null!==this._object[a]&&a in this._object){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]="function"==typeof this._object[a]?this._object[a]():this._object[a]}return this}},b.prototype.stop=function(){return null!==this._manager&&this._manager.remove(this),this.isRunning=!1,this},b.prototype.setParent=function(a){this._game=a,this._manager=this._game.tweens},b.prototype.delay=function(a){return this._delayTime=a,this},b.prototype.easing=function(a){return this._easingFunction=a,this},b.prototype.interpolation=function(a){return this._interpolationFunction=a,this},b.prototype.chain=function(a){return this._chainedTweens.push(a),this},b.prototype.onStart=function(a,b){return this._onStartCallback=a,this._onStartContext=b,this},b.prototype.onUpdate=function(a,b){return this._onUpdateCallback=a,this._onUpdateContext=b,this},b.prototype.onComplete=function(a,b){return this._onCompleteCallback=a,this._onCompleteContext=b,this},b.prototype.update=function(a){if(a1?1:0>b?0:b;var c=this._easingFunction(b);for(var d in this._valuesStart){var e=this._valuesStart[d],f=this._valuesEnd[d];f instanceof Array?this._object[d]=this._interpolationFunction(f,c):"function"==typeof this._object[d]?this._object[d](e+(f-e)*c):this._object[d]=e+(f-e)*c}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateContext,this._object,c),1===b){this.isRunning=!1,null!==this._onCompleteCallback&&this._onCompleteCalled===!1&&(this._onCompleteCalled=!0,this._onCompleteCallback.call(this._onCompleteContext,this._object));for(var g=0;gg){var i=e*g;f.x=(d-i)/2,d=i}else{var j=d/g;f.y=(e-j)/2,e=j}break;case a.Stage.SCALE_STRETCH:break;case a.Stage.SCALE_NONE:d=this._game.stage.width,e=this._game.stage.height}b.viewport(f.x,f.y,d,e)},c.prototype.initState=function(a){this._textureManager.clearTextures(this._game.stage.gl),this._textureManager.uploadTextureLibrary(this._game.stage.gl,a.textureLibrary)},c.prototype.endState=function(){this._textureManager.clearTextures(this._game.stage.gl),a.Log.log("Ending WebGL on State","#renderer","#webgl")},c.prototype.render=function(b){var c=this._game.stage.gl,d=this._game.stage.normalizedColor;if(c.clearColor(d.r*d.a,d.g*d.a,d.b*d.a,d.a),c.clear(c.COLOR_BUFFER_BIT),this._currentRenderer=null,0!=this._game.states.current.members.length){this.numDrawCalls=0,this._textureManager.numTextureWrites=0,this._entityCount=0;var e=b.transform.getConcatenatedMatrix(),f=b.transform;this._camMatrixOffset.identity(),this._camMatrixOffset.translate(-f.anchorPointX,-f.anchorPointY),this._camMatrixOffset.prependMatrix(e),this.camMatrix[0]=this._camMatrixOffset.a,this.camMatrix[1]=this._camMatrixOffset.b,this.camMatrix[3]=this._camMatrixOffset.c,this.camMatrix[4]=this._camMatrixOffset.d,this.camMatrix[6]=this._camMatrixOffset.tx,this.camMatrix[7]=this._camMatrixOffset.ty,this._game.deviceTargetOption==a.TARGET_COCOON&&this._switchBlendMode(c,this._currentBlendMode),this.collateRenderSequence(),this.collateBatches(),this.renderBatches(c,b)}},c.prototype.collateRenderSequence=function(){this._sequence=[];var a=this._game.states.current;this.collateChild(a)},c.prototype.collateChild=function(b){if(b.visible)if(b.childType()===a.GROUP)for(var c=0;c=b)return!0;return!1},b.DEFAULT_MAX_TEX_MEM_MB=1024,b}();b.GLTextureManager=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this._created=!1,this._uploaded=!1,this.items=d||a.squareVertices,this.itemSize=c||2,this.numItems=this.items.length/this.itemSize,this.createBuffer(b),e&&this.uploadBuffer(b,this.items)}return Object.defineProperty(a.prototype,"created",{get:function(){return this._created},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"uploaded",{get:function(){return this._uploaded},enumerable:!0,configurable:!0}),a.prototype.clear=function(){this.items=new Array},a.prototype.createBuffer=function(a){return this.buffer=a.createBuffer(),this._created=!0,!0},a.prototype.uploadBuffer=function(a,b){this.items=b,this.numItems=this.items.length/this.itemSize;var c=new Float32Array(this.items);return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,c,a.DYNAMIC_DRAW),this._uploaded=!0,!0},a.prototype.deleteBuffer=function(a){return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.deleteBuffer(this.buffer),this.uploaded=!1,this.created=!1,!0},a.squareVertices=[0,0,100,0,100,100,0,100],a.squareUVs=[0,0,.1,0,.1,.1,0,.1],a.squareCols=[1,1,1,1],a}();a.GLArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){this.gl=a,this.dirty=!0,this._srcRGB=a.SRC_ALPHA,this._dstRGB=a.ONE_MINUS_SRC_ALPHA,this._srcAlpha=a.ONE,this._dstAlpha=a.ONE,this._modeRGB=a.FUNC_ADD,this._modeAlpha=a.FUNC_ADD,"undefined"==typeof b&&(b=null),b&&this.readConfig(b)}return a.prototype.readConfig=function(a){void 0!==a.mode?this.setMode(a.mode):(a.srcRGB=this.makeConstant(a.srcRGB),"undefined"!=typeof a.srcRGB&&(this._srcRGB=a.srcRGB),a.dstRGB=this.makeConstant(a.dstRGB),"undefined"!=typeof a.dstRGB&&(this._dstRGB=a.dstRGB),a.srcAlpha=this.makeConstant(a.srcAlpha),"undefined"!=typeof a.srcAlpha&&(this._srcAlpha=a.srcAlpha),a.dstAlpha=this.makeConstant(a.dstAlpha),"undefined"!=typeof a.dstAlpha&&(this._dstAlpha=a.dstAlpha),a.modeRGB=this.makeConstant(a.modeRGB),"undefined"!=typeof a.modeRGB&&(this._modeRGB=a.modeRGB),a.modeAlpha=this.makeConstant(a.modeAlpha),"undefined"!=typeof a.modeAlpha&&(this._modeAlpha=a.modeAlpha)),this.dirty=!0},a.prototype.makeConstant=function(a){if("number"==typeof a)return a;switch("string"==typeof a&&(a=a.toUpperCase()),a){case"ZERO":a=this.gl.ZERO;break;case"ONE":a=this.gl.ONE;break;case"SRC_COLOR":case"SRC_COLOUR":a=this.gl.SRC_COLOR;break;case"ONE_MINUS_SRC_COLOR":case"ONE_MINUS_SRC_COLOUR":a=this.gl.ONE_MINUS_SRC_COLOR;break;case"DST_COLOR":case"DST_COLOUR":a=this.gl.DST_COLOR;break;case"ONE_MINUS_DST_COLOR":case"ONE_MINUS_DST_COLOUR":a=this.gl.ONE_MINUS_DST_COLOR;break;case"SRC_ALPHA":a=this.gl.SRC_ALPHA;break;case"ONE_MINUS_SRC_ALPHA":a=this.gl.ONE_MINUS_SRC_ALPHA;break;case"DST_ALPHA":a=this.gl.DST_ALPHA;break;case"ONE_MINUS_DST_ALPHA":a=this.gl.ONE_MINUS_DST_ALPHA;break;case"SRC_ALPHA_SATURATE":a=this.gl.SRC_ALPHA_SATURATE;break;case"CONSTANT_COLOR":case"CONSTANT_COLOUR":a=this.gl.CONSTANT_COLOR;break;case"ONE_MINUS_CONSTANT_COLOR":case"ONE_MINUS_CONSTANT_COLOUR":a=this.gl.ONE_MINUS_CONSTANT_COLOR;break;case"CONSTANT_ALPHA":a=this.gl.CONSTANT_ALPHA;break;case"ONE_MINUS_CONSTANT_ALPHA":a=this.gl.ONE_MINUS_CONSTANT_ALPHA;break;case"FUNC_ADD":a=this.gl.FUNC_ADD;break;case"FUNC_SUBTRACT":a=this.gl.FUNC_SUBTRACT;break;case"FUNC_REVERSE_SUBTRACT":a=this.gl.FUNC_REVERSE_SUBTRACT;break;default:a=void 0}return a},a.prototype.setMode=function(a){switch(a=a.toUpperCase()){case"ADDITIVE":case"ADD":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"SUBTRACT":case"SUBTRACTIVE":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_ADD;break;case"ERASE":case"ERASER":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_REVERSE_SUBTRACT;break;case"BLACK":case"BLACKEN":this._srcRGB=this.gl.ZERO,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"NORMAL":default:this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD}this.dirty=!0},a.prototype.isIdentical=function(a){return this==a?!0:this._srcRGB==a._srcRGB&&this._dstRGB==a._dstRGB&&this._srcAlpha==a._srcAlpha&&this._dstAlpha==a._dstAlpha&&this._modeRGB==a._modeRGB&&this._modeAlpha==a._modeAlpha?!0:!1},a.prototype.apply=function(a){a.blendEquationSeparate(this._modeRGB,this._modeAlpha),a.blendFuncSeparate(this._srcRGB,this._dstRGB,this._srcAlpha,this._dstAlpha),this.dirty=!1},a}();a.GLBlendMode=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this.indices=d||a.square,this.itemSize=c||1,this.numItems=this.indices.length/this.itemSize,e&&(this.buffer=this.init(b))}return a.prototype.clear=function(){this.indices=new Array},a.prototype.init=function(a){var b=a.createBuffer();return a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,b),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),b},a.prototype.refresh=function(a){return this.numItems=this.indices.length/this.itemSize,a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),this.buffer},a.square=[0,1,2,0,2,3],a}();a.GLElementArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=!1),this.loaded=!1,this._isBatchRenderer=!1,this.shaderManager=c,this._isBatchRenderer=d,this.loaded=!0,this.blendMode=new a.Renderers.GLBlendMode(b,{mode:"NORMAL"})}return b.prototype.enable=function(a,b){void 0===b&&(b=null)},b.prototype.disable=function(){},b.prototype.clear=function(){},b.prototype.draw=function(){},b.prototype.updateStageResolution=function(){},b.prototype.updateTextureSize=function(){},Object.defineProperty(b.prototype,"isBatchRenderer",{get:function(){return this._isBatchRenderer},enumerable:!0,configurable:!0}),b.RENDERER_ID="Renderer",b}();b.Renderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(c){function d(d,e,f){void 0===f&&(f=null),c.call(this,d,e,!0),this._shaderPairName="TextureAtlasShader",this._maxItems=1e3,this._pt1=new a.Geom.Point(0,0),this._pt2=new a.Geom.Point(0,0),this._pt3=new a.Geom.Point(0,0),this._pt4=new a.Geom.Point(0,0);var g=5;this._vertexBuffer=new b.GLArrayBuffer(d,g);var h=6;this._indexBuffer=new b.GLElementArrayBuffer(d,1,this._generateIndices(this._maxItems*h)),this.shaderPair=this.shaderManager.requestShader(d,this._shaderPairName)}return __extends(d,c),d.prototype.enable=function(a,b){void 0===b&&(b=null),this.shaderPair=this.shaderManager.requestShader(a,this._shaderPairName,!0),a.uniform1i(this.shaderPair.uniforms.uSampler.location,0),a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b.stageResolution),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.disable=function(a){a.disableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.disableVertexAttribArray(this.shaderPair.attributes.aAlpha)},d.prototype.clear=function(a,b){this._vertexBuffer.clear(),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.draw=function(a){this._vertexBuffer.uploadBuffer(a,this._vertexBuffer.items),a.enableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.vertexAttribPointer(this.shaderPair.attributes.aXYUV,4,a.FLOAT,!1,20,0),a.enableVertexAttribArray(this.shaderPair.attributes.aAlpha),a.vertexAttribPointer(this.shaderPair.attributes.aAlpha,1,a.FLOAT,!1,20,16),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indexBuffer.buffer),a.drawElements(a.TRIANGLES,this._vertexBuffer.items.length/20*6,a.UNSIGNED_SHORT,0)},d.prototype._generateIndices=function(a){for(var b=new Array,c=0;a>c;c++)b.push(4*c+0,4*c+1,4*c+2,4*c+0,4*c+2,4*c+3);return b},d.prototype.updateStageResolution=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b)},d.prototype.updateTextureSize=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uTextureSize.location,b)},d.prototype.setShaderPair=function(a){"string"==typeof a&&(this._shaderPairName=a)},d.prototype.addToBatch=function(a,b){if(!(b.alpha<=0)){var c=b.transform,d=c.getConcatenatedMatrix(),e=b.atlas.cells[b.cellIndex];this._pt1.setTo(0-c.rotPointX,0-c.rotPointY),this._pt2.setTo(e.w-c.rotPointX,0-c.rotPointY),this._pt3.setTo(e.w-c.rotPointX,e.h-c.rotPointY),this._pt4.setTo(0-c.rotPointX,e.h-c.rotPointY),d.transformPoint(this._pt1),d.transformPoint(this._pt2),d.transformPoint(this._pt3),d.transformPoint(this._pt4),this._vertexBuffer.items.push(this._pt1.x,this._pt1.y,e.x,e.y,b.alpha,this._pt2.x,this._pt2.y,e.x+e.w,e.y,b.alpha,this._pt3.x,this._pt3.y,e.x+e.w,e.y+e.h,b.alpha,this._pt4.x,this._pt4.y,e.x,e.y+e.h,b.alpha)}},d.prototype.concatBatch=function(a){this._vertexBuffer.items=this._vertexBuffer.items.concat(a)},d.RENDERER_ID="TextureAtlasRenderer",d}(b.Renderer);b.TextureAtlasRenderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.loaded=!1}return a.prototype.init=function(a){this.vertShader=this.compile(a,this.vertSource.join("\n"),a.VERTEX_SHADER),this.fragShader=this.compile(a,this.fragSource.join("\n"),a.FRAGMENT_SHADER),this.shaderProgram=this.attach(a,this.vertShader,this.fragShader),this.loaded=!0},a.prototype.attach=function(a,b,c){var d=a.createProgram();return a.attachShader(d,c),a.attachShader(d,b),a.linkProgram(d),d},a.prototype.compile=function(a,b,c){var d=a.createShader(c);return a.shaderSource(d,b),a.compileShader(d),a.getShaderParameter(d,a.COMPILE_STATUS)?d:null},a.prototype.setParam=function(a,b){this.uniforms[a].value=b,this.uniforms[a].dirty=!0},a.prototype.applyUniforms=function(a){for(var b in this.uniforms)this.applyUniform(a,b)},a.prototype.applyUniform=function(a,b){var c=this.uniforms[b];this.uniforms[b].dirty&&(a["uniform"+c.type](c.location,c.value),this.uniforms[b].dirty=!1)},a.prototype.initUniforms=function(a){for(var b in this.uniforms){var c=this.uniforms[b];c.location=a.getUniformLocation(this.shaderProgram,b),c.dirty=!0,c.value=null}},a.RENDERER_ID="ShaderPair",a}();a.ShaderPair=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.attributes={aXYUV:null,aAlpha:null},this.uniforms={uCamMatrix:{type:"mat3"},uResolution:{type:"2fv"},uTextureSize:{type:"2fv"},uSampler:{type:"1i"}},this.fragSource=["precision mediump float;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor.a *= vAlpha;","}"],this.vertSource=["attribute vec4 aXYUV;","attribute float aAlpha;","uniform mat3 uCamMatrix;","uniform vec2 uResolution;","uniform vec2 uTextureSize;","varying vec2 vTextureCoord;","varying float vAlpha;","void main(void) {"," vec2 pos = (uCamMatrix * vec3(aXYUV.xy,1)).xy; "," gl_Position = vec4((pos / uResolution * 2.0 - 1.0) * vec2(1, -1), 0, 1);"," vTextureCoord = aXYUV.zw / uTextureSize;"," vAlpha = aAlpha;","}"]}return __extends(b,a),b.prototype.init=function(b){a.prototype.init.call(this,b),this.attributes.aXYUV=b.getAttribLocation(this.shaderProgram,"aXYUV"),this.attributes.aAlpha=b.getAttribLocation(this.shaderProgram,"aAlpha"),this.initUniforms(b)},b}(a.ShaderPair);a.TextureAtlasShader=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d){this._frameIndex=0,this._startTime=null,this._reverse=!1,this._isPlaying=!1,this._onStop=null,this._onPlay=null,this._onUpdate=null,this._onLoop=null,this._onComplete=null,this.name=a,this._sequence=b,this._speed=b.speed,this._loop=b.loop,this._parent=d,this._clock=c,this._lastFrameElapsed=this.clock.elapsed()}return b.prototype.objType=function(){return"Animation"},Object.defineProperty(b.prototype,"loop",{get:function(){return this._loop},set:function(a){this._loop=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameIndex",{get:function(){return this._frameIndex},set:function(a){a=Math.floor(a),this._validateFrame(a)&&(this._frameIndex=a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"currentCell",{get:function(){return this._sequence.cells[this.frameIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"speed",{get:function(){return this._speed},set:function(a){this._speed=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clock",{get:function(){return this._clock?this._clock:this._parent.entity.clock},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"reverse",{get:function(){return this._reverse},set:function(a){this._reverse=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isPlaying",{get:function(){return this._isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onStop",{get:function(){return null==this._onStop&&(this._onStop=new a.Signal),this._onStop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onPlay",{get:function(){return null==this._onPlay&&(this._onPlay=new a.Signal),this._onPlay},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUpdate",{get:function(){return null==this._onUpdate&&(this._onUpdate=new a.Signal),this._onUpdate},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onLoop",{get:function(){return null==this._onLoop&&(this._onLoop=new a.Signal),this._onLoop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onComplete",{get:function(){return null==this._onComplete&&(this._onComplete=new a.Signal),this._onComplete},enumerable:!0,configurable:!0}),b.prototype._start=function(a){void 0===a&&(a=null),null!==a&&(this.frameIndex=a),(this.frameIndex>=this.length-1||this.frameIndex<0)&&(this.frameIndex=0),this._isPlaying=!0,this._startTime=this.clock.elapsed(),this._lastFrameElapsed=this.clock.elapsed(),null!==this._onPlay&&this._onPlay.dispatch()},b.prototype.play=function(){this.playAt(this._frameIndex)},b.prototype.playAt=function(a){this._start(a)},b.prototype.pause=function(){this.stop()},b.prototype.resume=function(){null!==this._startTime&&(this._isPlaying=!0)},b.prototype.stop=function(){this._isPlaying&&(this._isPlaying=!1,null!==this._onStop&&this._onStop.dispatch())},b.prototype.nextFrame=function(){this._frameIndex++,this._frameIndex>=this.length&&(this.frameIndex=0)},b.prototype.prevFrame=function(){this._frameIndex--,this._frameIndex<0&&(this.frameIndex=this.length-1)},b.prototype.update=function(){var a,b,c;if(this._isPlaying&&(a=(this.clock.elapsed()-this._lastFrameElapsed)/this._speed%(this.length+1),this._reverse&&(a*=-1),a=a>0?Math.floor(a):Math.ceil(a),0!==a)){if(this._frameIndex+=a,this._lastFrameElapsed=this.clock.elapsed(),this._loop){if(this._frameIndex>=this.length){if(c=Math.floor(this._frameIndex/this.length),this._frameIndex=this._frameIndex%this.length,null!=this._onLoop)for(b=0;c>b;b++)this._onLoop.dispatch()}else if(this._frameIndex<0&&(c=Math.ceil(Math.abs(this._frameIndex)/this.length),this._frameIndex=(this.length+this._frameIndex%this.length)%this.length,null!=this._onLoop))for(b=0;c>b;b++)this._onLoop.dispatch()}else{if(this._frameIndex<0)return this._frameIndex=(this.length+this._frameIndex%this.length)%this.length,void this._parent.stop();if(this._frameIndex>=this.length)return this._frameIndex=this._frameIndex%this.length,this._parent.stop(),void(null!=this._onComplete&&this._onComplete.dispatch())}this._parent.updateCellIndex(),null!==this._onUpdate&&this._onUpdate.dispatch()}},b.prototype._validateFrame=function(a){return a=0},Object.defineProperty(b.prototype,"length",{get:function(){return this._sequence.cells.length},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this._isPlaying=!1,delete this._clock,delete this._sequence,delete this._parent,this._onLoop&&this._onLoop.dispose(),this._onStop&&this._onStop.dispose(),this._onPlay&&this._onPlay.dispose(),this._onUpdate&&this._onUpdate.dispose(),delete this._onLoop,delete this._onStop,delete this._onPlay,delete this._onUpdate,delete this.frameIndex,delete this.loop,delete this._reverse,delete this._tick},b}();b.Animation=c}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c,d){void 0===c&&(c=.1),void 0===d&&(d=!0),this.name=a,this.cells=b,this.speed=c,this.loop=d}return a}();a.Sequence=b}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this.preventDefault=!1,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.timeUp=0,this.repeats=0,this._manager=a,this.game=this._manager.game,this.keyCode=b,c&&this.update(c)}return a.prototype.objType=function(){return"Key"},Object.defineProperty(a.prototype,"duration",{get:function(){return this.isDown&&(this.timeDown=this.game.time.now()),this.timeDownthis.game.time.now()?!0:!1},a.prototype.justReleased=function(a){return void 0===a&&(a=this._manager.justReleasedRate),this.isUp===!0&&this.timeUp+a>this.game.time.now()?!0:!1},a.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeUp=0,this.timeDown=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},a}();a.Key=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._keys=[],this.justPressedRate=200,this.justReleasedRate=200,this.game=a}return b.prototype.objType=function(){return"Keyboard"},Object.defineProperty(b.prototype,"keys",{get:function(){return this._keys},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this.onKeyUp=new a.Signal,this.onKeyDown=new a.Signal,this.onKeyDownOnce=new a.Signal,this.start()},b.prototype.update=function(){},b.prototype.start=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.addEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.addEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype.stop=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.removeEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.removeEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype._keyPressed=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),0==this._keys[b.keyCode].repeats&&this.onKeyDownOnce.dispatch(b.keyCode,this._keys[b.keyCode]),this.onKeyDown.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype._keyReleased=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),this.onKeyUp.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype.addKey=function(b,c){void 0===c&&(c=!1);var d=new a.Input.Key(this,b);return d.preventDefault=c,this._keys[b]=d},b.prototype.justPressed=function(a,b){return void 0===b&&(b=this.justPressedRate),this._keys[a]?this._keys[a].justPressed(b):!1},b.prototype.justReleased=function(a,b){return void 0===b&&(b=this.justReleasedRate),this._keys[a]?this._keys[a].justReleased(b):!1},b.prototype.isDown=function(a){return this._keys[a]?this._keys[a].isDown:!1},b.prototype.isUp=function(a){return this._keys[a]?this._keys[a].isUp:!1},b.prototype.reset=function(){for(var a in this._keys)this._keys[a].reset()},b}();b.Keyboard=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Keycodes"},a.A="A".charCodeAt(0),a.B="B".charCodeAt(0),a.C="C".charCodeAt(0),a.D="D".charCodeAt(0),a.E="E".charCodeAt(0),a.F="F".charCodeAt(0),a.G="G".charCodeAt(0),a.H="H".charCodeAt(0),a.I="I".charCodeAt(0),a.J="J".charCodeAt(0),a.K="K".charCodeAt(0),a.L="L".charCodeAt(0),a.M="M".charCodeAt(0),a.N="N".charCodeAt(0),a.O="O".charCodeAt(0),a.P="P".charCodeAt(0),a.Q="Q".charCodeAt(0),a.R="R".charCodeAt(0),a.S="S".charCodeAt(0),a.T="T".charCodeAt(0),a.U="U".charCodeAt(0),a.V="V".charCodeAt(0),a.W="W".charCodeAt(0),a.X="X".charCodeAt(0),a.Y="Y".charCodeAt(0),a.Z="Z".charCodeAt(0),a.ZERO="0".charCodeAt(0),a.ONE="1".charCodeAt(0),a.TWO="2".charCodeAt(0),a.THREE="3".charCodeAt(0),a.FOUR="4".charCodeAt(0),a.FIVE="5".charCodeAt(0),a.SIX="6".charCodeAt(0),a.SEVEN="7".charCodeAt(0),a.EIGHT="8".charCodeAt(0),a.NINE="9".charCodeAt(0),a.NUMPAD_0=96,a.NUMPAD_1=97,a.NUMPAD_2=98,a.NUMPAD_3=99,a.NUMPAD_4=100,a.NUMPAD_5=101,a.NUMPAD_6=102,a.NUMPAD_7=103,a.NUMPAD_8=104,a.NUMPAD_9=105,a.NUMPAD_MULTIPLY=106,a.NUMPAD_ADD=107,a.NUMPAD_ENTER=108,a.NUMPAD_SUBTRACT=109,a.NUMPAD_DECIMAL=110,a.NUMPAD_DIVIDE=111,a.F1=112,a.F2=113,a.F3=114,a.F4=115,a.F5=116,a.F6=117,a.F7=118,a.F8=119,a.F9=120,a.F10=121,a.F11=122,a.F12=123,a.F13=124,a.F14=125,a.F15=126,a.COLON=186,a.EQUALS=187,a.UNDERSCORE=189,a.QUESTION_MARK=191,a.TILDE=192,a.OPEN_BRACKET=219,a.BACKWARD_SLASH=220,a.CLOSED_BRACKET=221,a.QUOTES=222,a.BACKSPACE=8,a.TAB=9,a.CLEAR=12,a.ENTER=13,a.SHIFT=16,a.CONTROL=17,a.ALT=18,a.CAPS_LOCK=20,a.ESC=27,a.SPACEBAR=32,a.PAGE_UP=33,a.PAGE_DOWN=34,a.END=35,a.HOME=36,a.LEFT=37,a.UP=38,a.RIGHT=39,a.DOWN=40,a.INSERT=45,a.DELETE=46,a.HELP=47,a.NUM_LOCK=144,a -}();a.Keycodes=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this.game=a}return b.prototype.objType=function(){return"InputManager"},Object.defineProperty(b.prototype,"pointers",{get:function(){return this._pointers},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._pointers=[],this.mouse=new a.Input.Mouse(this.game),this.mouse.boot(),this.keyboard=new a.Input.Keyboard(this.game),this.keyboard.boot(),this.touch=new a.Input.Touch(this.game),this.touch.boot(),this.mouse.onDown.add(this._onDownEvent,this),this.mouse.onUp.add(this._onUpEvent,this),this.touch.touchDown.add(this._onDownEvent,this),this.touch.touchUp.add(this._onUpEvent,this),this._pointers=this.touch.fingers.slice(),this._pointers.push(this.mouse.cursor),this.isDown=!1,this.position=new a.Geom.Point,this.onDown=new a.Signal,this.onUp=new a.Signal},b.prototype._onDownEvent=function(a,b,c,d,e,f){this.onDown.dispatch(a,b,c,d,e,f)},b.prototype._onUpEvent=function(a,b,c,d,e,f){this.onUp.dispatch(a,b,c,d,e,f)},Object.defineProperty(b.prototype,"onPressed",{get:function(){return this.onDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onReleased",{get:function(){return this.onUp},enumerable:!0,configurable:!0}),b.prototype.update=function(){this.mouse.update(),this.keyboard.update(),this.touch.update(),this.touch.touchEnabled?this.position.setTo(this.touch.x,this.touch.y):this.position.setTo(this.mouse.x,this.mouse.y),this.isDown=this.mouse.isDown||this.touch.isDown},b.prototype.reset=function(){this.mouse.reset(),this.keyboard.reset(),this.touch.reset()},Object.defineProperty(b.prototype,"x",{get:function(){return this.position.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.position.y},enumerable:!0,configurable:!0}),b}();b.InputManager=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.preventContextMenu=!1,this._game=a}return b.prototype.objType=function(){return"Mouse"},Object.defineProperty(b.prototype,"cursor",{get:function(){return this._cursor},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this._cursor=new a.Input.MouseCursor(this._game),this._cursor.active=!0,this._cursor.id=1,this.onDown=new a.Signal,this.onUp=new a.Signal,this.onWheel=new a.Signal,this.onContext=new a.Signal,this.start()},Object.defineProperty(b.prototype,"isDown",{get:function(){return this._cursor.isDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isUp",{get:function(){return this._cursor.isUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"duration",{get:function(){return this._cursor.duration},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._cursor.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._cursor.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaX",{get:function(){return this._cursor.wheelDeltaX},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaY",{get:function(){return this._cursor.wheelDeltaY},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"ctrlKey",{get:function(){return this._cursor.ctrlKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"shiftKey",{get:function(){return this._cursor.shiftKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"altKey",{get:function(){return this._cursor.altKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"button",{get:function(){return this._cursor.button},enumerable:!0,configurable:!0}),b.prototype.update=function(){this._cursor.update()},b.prototype.start=function(){this._onMouseDownBind=this.onMouseDown.bind(this),this._onMouseMoveBind=this.onMouseMove.bind(this),this._onMouseUpBind=this.onMouseUp.bind(this),this._onMouseWheelBind=this.onMouseWheel.bind(this),this._onContextMenuBind=this.onContextMenu.bind(this),this._game.deviceTargetOption===a.TARGET_BROWSER?(this._domElement.addEventListener("mousedown",this._onMouseDownBind,!0),this._domElement.addEventListener("mousemove",this._onMouseMoveBind,!0),this._domElement.addEventListener("mouseup",this._onMouseUpBind,!0),this._domElement.addEventListener("mousewheel",this._onMouseWheelBind,!0),this._domElement.addEventListener("DOMMouseScroll",this._onMouseWheelBind,!0),this._domElement.addEventListener("contextmenu",this._onContextMenuBind,!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("mousedown",this._onMouseDownBind,!0),this._game.stage.canvas.addEventListener("mousemove",this._onMouseMoveBind,!0),this._game.stage.canvas.addEventListener("mouseup",this._onMouseUpBind,!0),this._game.stage.canvas.addEventListener("mousewheel",this._onMouseWheelBind,!0),this._game.stage.canvas.addEventListener("DOMMouseScroll",this._onMouseWheelBind,!0))},b.prototype.stop=function(){this._game.deviceTargetOption===a.TARGET_BROWSER?(this._domElement.removeEventListener("mousedown",this._onMouseDownBind,!0),this._domElement.removeEventListener("mousemove",this._onMouseMoveBind,!0),this._domElement.removeEventListener("mouseup",this._onMouseUpBind,!0),this._domElement.removeEventListener("mousewheel",this._onMouseWheelBind,!0),this._domElement.removeEventListener("DOMMouseScroll",this._onMouseWheelBind,!0),this._domElement.removeEventListener("contextmenu",this._onContextMenuBind,!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.removeEventListener("mousedown",this._onMouseDownBind,!0),this._game.stage.canvas.removeEventListener("mousemove",this._onMouseMoveBind,!0),this._game.stage.canvas.removeEventListener("mouseup",this._onMouseUpBind,!0),this._game.stage.canvas.removeEventListener("mousewheel",this._onMouseWheelBind,!0),this._game.stage.canvas.removeEventListener("DOMMouseScroll",this._onMouseWheelBind,!0)),delete this._onMouseDownBind,delete this._onMouseMoveBind,delete this._onMouseUpBind,delete this._onMouseWheelBind,delete this._onContextMenuBind},b.prototype.onMouseDown=function(a){this._cursor.start(a),this.onDown.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseMove=function(a){a.preventDefault(),this._cursor.move(a)},b.prototype.onMouseUp=function(a){this._cursor.stop(a),this.onUp.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseWheel=function(a){this._cursor.wheel(a),this.onWheel.dispatch(this._cursor.wheelDeltaX,this._cursor.wheelDeltaY,this._cursor)},b.prototype.justPressed=function(a){return void 0===a&&(a=this._cursor.justPressedRate),this._cursor.justPressed(a)},b.prototype.justReleased=function(a){return void 0===a&&(a=this._cursor.justReleasedRate),this._cursor.justReleased(a)},b.prototype.reset=function(){this._cursor.reset()},b.prototype.onContextMenu=function(a){this.preventContextMenu&&a.preventDefault(),this.onContext.dispatch(a)},b.LEFT_BUTTON=0,b.MIDDLE_BUTTON=1,b.RIGHT_BUTTON=2,b}();b.Mouse=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.isDown=!1,this.isUp=!0,this._maxPointers=10,this._game=a}return b.prototype.objType=function(){return"TouchManager"},Object.defineProperty(b.prototype,"fingers",{get:function(){return this._fingers},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onDown",{get:function(){return this.touchDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUp",{get:function(){return this.touchUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onCancel",{get:function(){return this.touchCancel},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this.finger1=new a.Input.Finger(this._game),this.finger2=new a.Input.Finger(this._game),this.finger3=new a.Input.Finger(this._game),this.finger4=new a.Input.Finger(this._game),this.finger5=new a.Input.Finger(this._game),this.finger6=new a.Input.Finger(this._game),this.finger7=new a.Input.Finger(this._game),this.finger8=new a.Input.Finger(this._game),this.finger9=new a.Input.Finger(this._game),this.finger10=new a.Input.Finger(this._game),this._fingers=[this.finger1,this.finger2,this.finger3,this.finger4,this.finger5,this.finger6,this.finger7,this.finger8,this.finger9,this.finger10],this.latestFinger=this.finger1,this.touchDown=new a.Signal,this.touchUp=new a.Signal,this.touchCancel=new a.Signal,this.start()},b.prototype.start=function(){var b=this;if(a.DEVICE.touch)if(this.touchEnabled=!0,this._onTouchStartBind=this.onTouchStart.bind(this),this._onTouchMoveBind=this.onTouchMove.bind(this),this._onTouchEndBind=this.onTouchEnd.bind(this),this._onTouchEnterBind=this.onTouchEnter.bind(this),this._onTouchLeaveBind=this.onTouchLeave.bind(this),this._onTouchCancelBind=this.onTouchCancel.bind(this),this._game.deviceTargetOption===a.TARGET_BROWSER)if(a.DEVICE.pointerEnabled){var c="pointerup",d="pointerdown",e="pointerenter",f="pointerleave",g="pointercancel",h="pointermove";if(window.PointerEvent);else if(window.MSPointerEvent)var c="MSPointerUp",d="MSPointerDown",e="MSPointerEnter",f="MSPointerLeave",g="MSPointerCancel",h="MSPointerMove";this._onTouchStartBind=this.onPointerStart.bind(this),this._onTouchMoveBind=this.onPointerMove.bind(this),this._onTouchEndBind=this.onPointerEnd.bind(this),this._onTouchEnterBind=this.onPointerEnter.bind(this),this._onTouchLeaveBind=this.onPointerLeave.bind(this),this._onTouchCancelBind=this.onPointerCancel.bind(this),this._domElement.addEventListener(c,this._onTouchStartBind,!1),this._domElement.addEventListener(h,this._onTouchMoveBind,!1),this._domElement.addEventListener(d,this._onTouchEndBind,!1),this._domElement.addEventListener(e,this._onTouchEnterBind,!1),this._domElement.addEventListener(f,this._onTouchLeaveBind,!1),this._domElement.addEventListener(g,this._onTouchCancelBind,!1)}else this._domElement.addEventListener("touchstart",this._onTouchStartBind,!1),this._domElement.addEventListener("touchmove",this._onTouchMoveBind,!1),this._domElement.addEventListener("touchend",this._onTouchEndBind,!1),this._domElement.addEventListener("touchenter",this._onTouchEnterBind,!1),this._domElement.addEventListener("touchleave",this._onTouchLeaveBind,!1),this._domElement.addEventListener("touchcancel",this._onTouchCancelBind,!1),document.addEventListener("touchmove",function(a){return b.consumeTouchMove(a)},!1);else this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("touchstart",this._onTouchStartBind,!1),this._game.stage.canvas.addEventListener("touchmove",this._onTouchMoveBind,!1),this._game.stage.canvas.addEventListener("touchend",this._onTouchEndBind,!1),this._game.stage.canvas.addEventListener("touchenter",this._onTouchEnterBind,!1),this._game.stage.canvas.addEventListener("touchleave",this._onTouchLeaveBind,!1),this._game.stage.canvas.addEventListener("touchcancel",this._onTouchCancelBind,!1));else this.touchEnabled=!1},b.prototype.consumeTouchMove=function(a){a.preventDefault()},Object.defineProperty(b.prototype,"x",{get:function(){return this.latestFinger.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.latestFinger.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"maximumPointers",{get:function(){return this._maxPointers},set:function(a){0>a&&(a=1),a>this._fingers.length&&(a=this._fingers.length),this._maxPointers=a},enumerable:!0,configurable:!0}),b.prototype._registerFinger=function(a,b){for(var c=0;cthis._game.time.now()?!0:!1},b.prototype.justReleased=function(a){return void 0===a&&(a=this.justReleasedRate),this.isUp===!0&&this.timeUp+a>this._game.time.now()?!0:!1},Object.defineProperty(b.prototype,"pressed",{get:function(){return this.timeDown>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"released",{get:function(){return this.timeUp>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),b.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.duration=0,this.frameDuration=0},b.prototype.update=function(){this.isDown===!0&&(this.frameDuration++,this.duration=this._game.time.now()-this.timeDown)},b}();b.Pointer=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments),this.wheelDeltaX=0,this.wheelDeltaY=0,this.preventDown=!0,this.preventUp=!0,this.preventWheel=!0}return __extends(b,a),b.prototype.objType=function(){return"MouseCursor"},b.prototype.start=function(b){this.preventDown&&b.preventDefault(),this.ctrlKey=b.ctrlKey,this.shiftKey=b.shiftKey,this.altKey=b.altKey,this.button=b.button,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.preventUp&&b.preventDefault(),this.move(b),a.prototype.stop.call(this,b)},b.prototype.wheel=function(a){this.preventWheel&&a.preventDefault(),this.wheelDeltaX=a.wheelDeltaX?a.wheelDeltaX:a.deltaX,this.wheelDeltaY=a.wheelDeltaY?a.wheelDeltaY:a.deltaY},b}(a.Pointer);a.MouseCursor=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b){a.call(this,b),this.circle.diameter=44}return __extends(b,a),b.prototype.objType=function(){return"Finger"},b.prototype.start=function(b){this.active=!0,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.active=!1,a.prototype.stop.call(this,b)},b.prototype.leave=function(a){this.withinGame=!1,this.move(a)},b.prototype.reset=function(){this.active=!1,a.prototype.reset.call(this)},b}(a.Pointer);a.Finger=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c,d){this.cx=0,this.cy=0,this.halfWidth=0,this.halfHeight=0,this.cx=a||0,this.cy=b||0,this.halfWidth=c/2||0,this.halfHeight=d/2||0}return b.prototype.objType=function(){return"AABB"},Object.defineProperty(b.prototype,"height",{get:function(){return 2*this.halfHeight},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return 2*this.halfWidth},enumerable:!0,configurable:!0}),b.prototype.draw=function(a){return a.beginPath(),a.moveTo(this.cx-this.halfWidth,this.cy),a.lineTo(this.cx+this.halfWidth,this.cy),a.moveTo(this.cx,this.cy-this.halfHeight),a.lineTo(this.cx,this.cy+this.halfHeight),a.stroke(),this},b.prototype.setPosition=function(a,b){return this.cx=a,this.cy=b,this},b.prototype.setPositionPoint=function(a){return this.cx=a.x,this.cy=a.y,this},b.prototype.toRect=function(){return new a.Rectangle(this.cx-this.halfWidth,this.cy-this.halfHeight,2*this.halfWidth,2*this.halfHeight)},b.prototype.fromRect=function(a){return this.halfWidth=a.width/2,this.halfHeight=a.height/2,this.cx=a.x+this.halfWidth,this.cy=a.y+this.halfHeight,this},b}();a.AABB=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),this._diameter=0,this._radius=0,this.x=0,this.y=0,this.setTo(a,b,c)}return b.prototype.objType=function(){return"Circle"},Object.defineProperty(b.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"circumference",{get:function(){return 2*Math.PI*this._radius},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){isNaN(a)||(athis.x?this.radius=a-this.x:(this._radius=0,this._diameter=0))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"top",{get:function(){return this.y-this._radius},set:function(a){a&&!isNaN(a)&&(a>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isEmpty",{get:function(){return this._diameter<=0?!0:!1},enumerable:!0,configurable:!0}),b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x,this.y,this._diameter)},b.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.diameter)},b.prototype.copyTo=function(a){return a.copyFrom(this)},b.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},b.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.diameter===a.diameter?!0:!1},b.prototype.intersects=function(a){return this.distanceTo(a,!1)=c&&d>=a&&b>=e&&f>=b?!0:!1},b.prototype.intersectLineLine=function(b){return a.Geom.Intersect.lineToLine(this,b)},b.prototype.perp=function(a,c,d){void 0===d&&(d=new b);var e;if(this.y1===this.y2)return d.setTo(a,c,a,this.y1),d;if(this.x1===this.x2)return d.setTo(a,c,this.x1,c),d;var f=c-this.perpSlope*a;return e=this.intersectLineLine(0!==a?{x1:a,y1:c,x2:0,y2:f}:{x1:a,y1:c,x2:1,y2:f+this.perpSlope}),d.setTo(a,c,e.x,e.y),d},b.prototype.toString=function(){return"[{Line (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}();b.Line=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=0),a.call(this,b,c,d,e)}return __extends(b,a),b.prototype.objType=function(){return"Ray"},b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x1,this.y1,this.x2,this.y2)},b.prototype.isPointOnRay=function(a,b){return(a-this.x1)*(this.y2-this.y1)===(this.x2-this.x1)*(b-this.y1)&&Math.atan2(b-this.y1,a-this.x1)==Math.atan2(this.y2-this.y1,this.x2-this.x1)?!0:!1},b.prototype.toString=function(){return"[{Ray (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}(a.Line);a.Ray=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(){}return c.prototype.objType=function(){return"Intersect"},c.distance=function(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))},c.distanceSquared=function(a,b,c,d){return(c-a)*(c-a)+(d-b)*(d-b)},c.lineToLine=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);return 0!==e&&(d.result=!0,d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e),d},c.lineToLineSegment=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);if(0!==e){d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e;var f=Math.max(c.x1,c.x2),g=Math.min(c.x1,c.x2),h=Math.max(c.y1,c.y2),i=Math.min(c.y1,c.y2);(d.x<=f&&d.x>=g)==!0&&(d.y<=h&&d.y>=i)==!0&&(d.result=!0)}return d},c.lineToRawSegment=function(a,c,d,e,f,g){void 0===g&&(g=new b.IntersectResult),g.result=!1;var h=(a.x1-a.x2)*(d-f)-(a.y1-a.y2)*(c-e);if(0!==h){g.x=((a.x1*a.y2-a.y1*a.x2)*(c-e)-(a.x1-a.x2)*(c*f-d*e))/h,g.y=((a.x1*a.y2-a.y1*a.x2)*(d-f)-(a.y1-a.y2)*(c*f-d*e))/h;var i=Math.max(c,e),j=Math.min(c,e),k=Math.max(d,f),l=Math.min(d,f);g.x<=i&&g.x>=j&&g.y<=k&&g.y>=l&&(g.result=!0)}return g},c.lineSegmentToRawSegment=function(a,d,e,f,g,h){void 0===h&&(h=new b.IntersectResult),h=c.lineToRawSegment(a,d,e,f,g,h);var i=Math.max(a.x1,a.x2),j=Math.min(a.x1,a.x2),k=Math.max(a.y1,a.y2),l=Math.min(a.y1,a.y2);return h.x<=i&&h.x>=j&&h.y<=k&&h.y>=l?h:(h.result=!1,h)},c.lineToRay=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);return 0!==e&&(d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e,d.result=!0,!(c.x1>=c.x2)&&d.x=c.y2)&&d.y=Math.min(a.x1,a.x2)&&e.x<=Math.max(a.x1,a.x2)&&e.y>=Math.min(a.y1,a.y2)&&e.y<=Math.max(a.y1,a.y2)||(e.result=!1)),e},c.lineSegmentToRay=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToRay(a,d,e),e.result===!0&&(e.x>=Math.min(a.x1,a.x2)&&e.x<=Math.max(a.x1,a.x2)&&e.y>=Math.min(a.y1,a.y2)&&e.y<=Math.max(a.y1,a.y2)||(e.result=!1)),e},c.lineSegmentToCircle=function(a,d,e){void 0===e&&(e=new b.IntersectResult),e.result=!1;var f=a.perp(d.x,d.y);if(f.length<=d.radius){var g=Math.max(a.x1,a.x2),h=Math.min(a.x1,a.x2),i=Math.max(a.y1,a.y2),j=Math.min(a.y1,a.y2); -f.x2<=g&&f.x2>=h&&f.y2<=i&&f.y2>=j?e.result=!0:(c.circleContainsPoint(d,{x:a.x1,y:a.y1}).result||c.circleContainsPoint(d,{x:a.x2,y:a.y2}).result)&&(e.result=!0)}return e},c.lineSegmentToRectangle=function(a,d,e){if(void 0===e&&(e=new b.IntersectResult),e.result=!1,d.contains(a.x1,a.y1)&&d.contains(a.x2,a.y2))e.x=(a.x1+a.x2)/2,e.y=(a.y1+a.y2)/2,e.result=!0;else{if(c.lineSegmentToRawSegment(a,d.x,d.y,d.right,d.y,e),e.result===!0)return e;if(c.lineSegmentToRawSegment(a,d.x,d.y,d.x,d.bottom,e),e.result===!0)return e;if(c.lineSegmentToRawSegment(a,d.x,d.bottom,d.right,d.bottom,e),e.result===!0)return e;c.lineSegmentToRawSegment(a,d.right,d.y,d.right,d.bottom,e)}return e},c.rayToCircle=function(d,e,f){void 0===f&&(f=new b.IntersectResult);var g=e.x-d.x1,h=e.y-d.y1;return f.result=!1,Math.sqrt(g*g+h*h)<=e.radius?(f.result=!0,f):Math.abs(a.Utils.GameMath.nearestAngleBetween(d.angle,Math.atan2(h,g)))>=Math.PI/2?f:(c.lineToCircle(d,e,f),f)},c.rayToRectangle=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToRectangle(a,d,e),e},c.rayToLineSegment=function(a,c,d,e,f,g,h,i,j){void 0===j&&(j=new b.IntersectResult),j.result=!1;var k,l,m;return(e-c)/(d-a)!=(i-g)/(h-f)&&(m=(d-a)*(i-g)-(e-c)*(h-f),0!=m&&(k=((c-g)*(h-f)-(a-f)*(i-g))/m,l=((c-g)*(d-a)-(a-f)*(e-c))/m,k>=0&&l>=0&&1>=l&&(j.result=!0,j.x=a+k*(d-a),c+k*(e-c)))),j},c.circleToCircle=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,e.result=(a.radius+d.radius)*(a.radius+d.radius)>=c.distanceSquared(a.x,a.y,d.x,d.y),e},c.circleToRectangle=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e,f,g,h,i,j,k,l;return i=c.width/2,g=Math.abs(a.x-c.x-i),k=a.radius+i,g>k?(d.result=!1,d):(j=c.height/2,h=Math.abs(a.y-c.y-j),l=a.radius+j,h>l?(d.result=!1,d):i>=g||h<=c.height/2?(d.result=!0,d):(e=g-i,f=h-j,d.result=e*e+f*f<=a.radius*a.radius,d))},c.circleContainsPoint=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,e.result=a.radius*a.radius>=c.distanceSquared(a.x,a.y,d.x,d.y),e},c.pointToRectangle=function(a,c,d){return void 0===d&&(d=new b.IntersectResult),d.result=!1,d.setTo(a.x,a.y),d.result=c.containsPoint(a),d},c.rectangleToRectangle=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=Math.max(a.x,c.x),f=Math.min(a.right,c.right),g=Math.max(a.y,c.y),h=Math.min(a.bottom,c.bottom);d.setTo(e,g,f-e,h-g,f-e,h-g);var i=d.x+.5*d.width,j=d.y+.5*d.height;return i>a.x&&ia.y&&j=b?!0:!1},a.prototype.equals=function(a){return this.x===a.x&&this.y===a.y?!0:!1},a.interpolate=function(b,c,d){var e=c.x-b.x,f=c.y-b.y;return new a(c.x-e*d,c.y-f*d)},a.prototype.offset=function(a,b){return this.x+=a,this.y+=b,this},a.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},a.prototype.subtract=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x-b.x,this.y-b.y)},a.prototype.getCSS=function(){return this.x+"px "+this.y+"px"},a.prototype.toString=function(){return"[{Point (x="+this.x+" y="+this.y+")}]"},a}();a.Point=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.x=0,this.y=0,this.width=0,this.height=0,this.setTo(a,b,c,d)}return c.prototype.objType=function(){return"Rectangle"},Object.defineProperty(c.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a&&(this.height=a=this.x&&a<=this.right&&b>=this.y&&b<=this.bottom?!0:!1},c.prototype.containsPoint=function(a){return this.contains(a.x,a.y)},c.prototype.containsRect=function(a){return a.volume>this.volume?!1:a.x>=this.x&&a.y>=this.y&&a.right<=this.right&&a.bottom<=this.bottom?!0:!1},c.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.width,a.height)},c.prototype.copyTo=function(a){return void 0===a&&(a=new c),a.copyFrom(this)},c.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.width===a.width&&this.height===a.height?!0:!1},c.prototype.inflate=function(a,b){return isNaN(a)||isNaN(b)||(this.x-=a,this.width+=2*a,this.y-=b,this.height+=2*b),this},c.prototype.inflatePoint=function(a){return this.inflate(a.x,a.y)},c.prototype.intersection=function(a,b){return void 0===b&&(b=new c),this.intersects(a)===!0&&(b.x=Math.max(a.x,this.x),b.y=Math.max(a.y,this.y),b.width=Math.min(a.right,this.right)-b.x,b.height=Math.min(a.bottom,this.bottom)-b.y),b},c.prototype.intersects=function(a){return a.x>this.right-1?!1:a.right-1this.bottom-1?!1:!0},c.prototype.overlap=function(a){var b={top:!1,bottom:!1,left:!1,right:!1,contains:!1,contained:!1},c=this.intersection(a);return c.isEmpty?b:(this.containsRect(a)&&(b.contains=!0),a.containsRect(this)&&(b.contained=!0),this.topa.bottom&&(b.bottom=!0),this.lefta.right&&(b.right=!0),b)},c.prototype.isEmpty=function(){return this.width<1||this.height<1?!0:!1},c.prototype.offset=function(a,b){return isNaN(a)||isNaN(b)||(this.x+=a,this.y+=b),this},c.prototype.offsetPoint=function(a){return this.offset(a.x,a.y)},c.prototype.setEmpty=function(){return this.setTo(0,0,0,0)},c.prototype.setTo=function(a,b,c,d){return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)||(this.x=a,this.y=b,c>=0&&(this.width=c),d>=0&&(this.height=d)),this},c.prototype.union=function(a,b){return void 0===b&&(b=new c),b.setTo(Math.min(a.x,this.x),Math.min(a.y,this.y),Math.max(a.right,this.right),Math.max(a.bottom,this.bottom))},c.prototype.scale=function(b,c,d){var e=new a.Geom.Transform;e.scaleX=b,e.scaleY=c,e.x=d.x,e.y=d.y;var f=this.topLeft;return e.transformPoint(f),this.topLeft=f,this.width*=b,this.height*=c,this},c.prototype.toString=function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" isEmpty="+this.isEmpty()+")}]"},c}();b.Rectangle=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,c,d,e,f,g,h){void 0===a&&(a=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),this._x=0,this._y=0,this._scaleX=1,this._scaleY=1,this._rotation=0,this._rotPointX=0,this._rotPointY=0,this._parent=null,this._locked=!1,this._ignoreParent=!1,this._ignoreChild=!1,this._dirty=!0,this.setTransform(a,c,d,e,f,g,h),this._matrix=new b.Matrix,this._cachedConcatenatedMatrix=new b.Matrix,this._matrix.setFromOffsetTransform(this._x,this._y,this._scaleX,this._scaleY,this._rotation,this._rotPointX,this._rotPointY)}return c.prototype.objType=function(){return"Transform"},Object.defineProperty(c.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleX",{get:function(){return this._scaleX},set:function(a){this._scaleX=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleY",{get:function(){return this._scaleY},set:function(a){this._scaleY=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotation",{get:function(){return this._rotation},set:function(a){this._rotation=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointX",{get:function(){return this._rotPointX},set:function(a){this._rotPointX=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointY",{get:function(){return this._rotPointY},set:function(a){this._rotPointY=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointX",{get:function(){return this.rotPointX},set:function(a){this.rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointY",{get:function(){return this.rotPointY},set:function(a){this.rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"matrix",{get:function(){return this._matrix},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldX",{get:function(){return this.getConcatenatedMatrix().tx-this._rotPointX},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldY",{get:function(){return this.getConcatenatedMatrix().ty-this._rotPointY},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"parent",{get:function(){return this._parent},set:function(a){this.checkAncestor(a)||(this._parent=a,this._dirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"locked",{get:function(){return this._locked},set:function(a){this._locked=a,this._locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreParent",{get:function(){return this._ignoreParent},set:function(a){this._ignoreParent=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreChild",{get:function(){return this._ignoreChild},set:function(a){this._ignoreChild=a},enumerable:!0,configurable:!0}),c.prototype.setPosition=function(a,b){return this._x=a,this._y=b,this._dirty=!0,this},c.prototype.setPositionFromPoint=function(a){return this._x=a.x,this._y=a.y,this._dirty=!0,this},c.prototype.translatePositionFromPoint=function(a){return this._x+=a.x,this._y+=a.y,this._dirty=!0,this},c.prototype.getPositionPoint=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this._x,this._y)},Object.defineProperty(c.prototype,"scale",{set:function(a){this._scaleX=a,this._scaleY=a,this._dirty=!0},enumerable:!0,configurable:!0}),c.prototype.setTransform=function(a,b,c,d,e,f,g){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=1),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=0),this._x=a,this._y=b,this._scaleX=c,this._scaleY=d,this._rotation=e,this._rotPointX=f,this._rotPointY=g,this._dirty=!0,this},c.prototype.getParentMatrix=function(){return this._parent?this._parent.getConcatenatedMatrix():null},c.prototype.getConcatenatedMatrix=function(){return this._dirty&&!this.locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY),this._cachedConcatenatedMatrix.copyFrom(this._matrix),!this._parent||this._parent.ignoreChild||this.ignoreParent||(this._cachedConcatenatedMatrix.tx-=this._parent.anchorPointX,this._cachedConcatenatedMatrix.ty-=this._parent.anchorPointY,this._cachedConcatenatedMatrix.prependMatrix(this.getParentMatrix())),this._dirty=!1,this._cachedConcatenatedMatrix},c.prototype.transformPoint=function(a){var b=this.getConcatenatedMatrix();return b.transformPoint(a)},c.prototype.copyFrom=function(a){return this.setTransform(a.x,a.y,a.scaleX,a.scaleY,a.rotation,a.rotPointX,a.rotPointY),this.parent=a.parent,this._matrix=a.matrix.clone(),this},c.prototype.copyTo=function(a){return a.copyFrom(this),this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.copyFrom(this),a},c.prototype.checkAncestor=function(){return!1},Object.defineProperty(c.prototype,"toString",{get:function(){return"[{Transform (x="+this._x+" y="+this._y+" scaleX="+this._scaleX+" scaleY="+this._scaleY+" rotation="+this._rotation+" regX="+this._rotPointX+" regY="+this.rotPointY+" matrix="+this._matrix+")}]"},enumerable:!0,configurable:!0}),c}();b.Transform=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return c.prototype.objType=function(){return"Vector2"},c.fromAngle=function(a){return new c(Math.cos(a),Math.sin(a))},c.randomRadius=function(a){return new c(2*Math.random()-1,2*Math.random()-1).multiplyScalar(a)},c.fromPoint=function(a){return new c(a.x,a.y)},c.prototype.add=function(a){return new c(this.x+a.x,this.y+a.y)},c.prototype.addX=function(a){return new c(this.x+a.x,this.y)},c.prototype.addY=function(a){return new c(this.x,this.y+a.y)},c.prototype.subtract=function(b){return new a.Geom.Vector2(this.x-b.x,this.y-b.y)},c.prototype.multiply=function(b){return new a.Geom.Vector2(this.x*b.x,this.y*b.y)},c.prototype.multiplyScalar=function(b){return new a.Geom.Vector2(this.x*b,this.y*b)},c.prototype.dot=function(a){return this.x*a.x+this.y*a.y},c.prototype.lenSqr=function(){return this.x*this.x+this.y*this.y},c.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},c.prototype.unit=function(){var a=1/this.len();return this.multiplyScalar(a)},c.prototype.floor=function(){return new c(Math.floor(this.x),Math.floor(this.y))},c.prototype.ceil=function(){return new c(Math.ceil(this.x),Math.ceil(this.y))},c.prototype.round=function(){return new c(Math.round(this.x),Math.round(this.y))},c.prototype.clamp=function(a,b){return new c(Math.max(Math.min(this.x,b.x),a.x),Math.max(Math.min(this.y,b.y),a.y))},c.prototype.perp=function(){return new c(-this.y,this.x)},c.prototype.neg=function(){return new c(-this.x,-this.y)},c.prototype.equal=function(a){return this.x===a.x&&this.y===a.y},c.prototype.point=function(){return new b.Point(this.x,this.y)},c.prototype.clear=function(){return this.x=0,this.y=0,this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.setTo(this.x,this.y)},c.prototype.copyFrom=function(a){return this.x=a.x,this.y=a.y,this},c.prototype.copyTo=function(a){return a.x=this.x,a.y=this.y,a},c.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},c.prototype.toString=function(){return"[{Vector2 (x="+this.x+" y="+this.y+")}]"},c}();b.Vector2=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){if(this._game=b,this.name=c,this._manager=this._game.huds,this._device=this._game.deviceTargetOption,this._manager.supported){switch(this._device){case a.TARGET_BROWSER:this.container=document.createElement("div"),this.container.id="HUD-layer-"+b.rnd.uuid(),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="absolute",this._widgets=new Array}this["class"]="kiwi-display"}}return b.prototype.objType=function(){return"HUDDisplay"},b.prototype.addWidget=function(b){return this._manager.supported&&(this._widgets.push(b),this._device==a.TARGET_BROWSER)?(this.container.appendChild(b.container),!0):!1},b.prototype.removeWidget=function(a){if(this._manager.supported&&this.removeFromContainer(a)){var b=this._widgets.indexOf(a);if(-1!==b)return this._widgets.splice(b,1),!0}return!1},b.prototype.removeAllWidgets=function(){for(var a=0;athis._icons.length)for(var a=this.counter.max-this._icons.length,b=0;a>b;b++)this._addIcon();else for(var b=this.counter.max;bthis.counter.current-1?"none":"block"},c.prototype._addIcon=function(){if(this.horizontal)var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x+(this.width+this.iconGap)*(this._icons.length-1),0);else var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x,(this.height+this.iconGap)*(this._icons.length-1));b.horizontalOrigin=this.horizontalOrigin,b.verticalOrigin=this.verticalOrigin,this._icons.push(b),this._device==a.TARGET_BROWSER&&this.container.appendChild(b.container)},c.prototype._removeIcon=function(b){this._device==a.TARGET_BROWSER&&this.container.removeChild(b.container)},Object.defineProperty(c.prototype,"horizontal",{get:function(){return this._horizontal},set:function(a){this._horizontal=a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"vertical",{get:function(){return!this._horizontal},set:function(a){this._horizontal=!a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"horizontalOrigin",{get:function(){return this._horizontalOrigin},set:function(a){this.container.style[this._horizontalOrigin]="auto",this._horizontalOrigin=a,this.container.style[this._horizontalOrigin]=this.x+"px";for(var b=0;bthis._max?this._max:null!==this._min&&athis._min)&&(null!==this._min&&this._current-athis._max?this._current=this._max:this._current+=a,this.updated.dispatch(this._current,this._max,this._min)),this._current},c.prototype.currentPercent=function(){return null!==this.max?this.current/this.max*100:void 0},c}(a.Component);b.Counter=c}(c=b.HUDComponents||(b.HUDComponents={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d){b.call(this,c,"WidgetInput"),this._active=!1,this._container=d,this.onUp=new a.Signal,this.onDown=new a.Signal,this.onOver=new a.Signal,this.onOut=new a.Signal,this._addEvents()}return __extends(c,b),c.prototype.objType=function(){return"WidgetInputComponent"},c.prototype.setElement=function(a){this._removeEvents(),this._container=a,this._addEvents()},c.prototype._addEvents=function(){if(!this._active){this._binds=[],this._binds.push({event:"mouseup","function":this._up.bind(this)}),this._binds.push({event:"mousedown","function":this._down.bind(this)}),this._binds.push({event:"mouseover","function":this._over.bind(this)}),this._binds.push({event:"mouseout","function":this._out.bind(this)});for(var a=0;a=this.duration&&(this._loop?(this.play(this._currentMarker,!0),this.onLoop.dispatch()):(this.onComplete.dispatch(),this.stop()))))},b.prototype.destroy=function(){this._game&&this._game.audio.remove(this,!1),this.onLoop&&this.onLoop.dispose(),this.onStop&&this.onStop.dispose(),this.onPlay&&this.onPlay.dispose(),this.onMute&&this.onMute.dispose(),this.onPause&&this.onPause.dispose(),this.onResume&&this.onResume.dispose(),delete this.onLoop,delete this.onStop,delete this.onPause,delete this.onMute,delete this.onPlay,delete this.onResume,delete this._game,delete this._sound,delete this._currentTime,delete this._startTime,delete this._pending,delete this.masterGainNode,delete this.gainNode,delete this.totalDuration,delete this.duration,delete this._file,delete this._buffer,delete this._decoded},b}();b.Audio=c}(b=a.Sound||(a.Sound={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this.audio={}}return b.prototype.objType=function(){return"AudioLibrary"},b.prototype.clear=function(){for(var a in this.audio)delete this.audio[a]},b.prototype.rebuild=function(b,c){this.clear(),a.Log.log("Kiwi.AudioLibrary: Rebuilding Audio Library.","#audio","#rebuild");for(var d=b.keys,e=0;e0&&(b=Math.min(b,this._maxFrameDuration));for(var c=0;c0?this._delay=b:a.Log.error("Attempted to set timer delay",b,"but value must be greater than 0","#timer")},enumerable:!0,configurable:!0}),c.prototype.processEvents=function(a){if(a===b.TimerEvent.TIMER_START)for(var c=0;c=this.delay;)this._currentCount++,this.processEvents(b.TimerEvent.TIMER_COUNT),this._elapsed-=this.delay,-1!==this.repeatCount&&this._currentCount>=this.repeatCount&&this.stop();for(;this._elapsed<0;)this._currentCount--,this._elapsed+=this.delay,this._currentCount<0&&(this.clear(),this.stop())},c.prototype.start=function(){return this._isStopped===!0&&(this._isRunning=!0,this._isPaused=!1,this._isStopped=!1,this._currentCount=0,this._elapsed=0,this._lastElapsed=this._clock.elapsed()||0,this.processEvents(b.TimerEvent.TIMER_START)),this},c.prototype.stop=function(){return(this._isRunning===!0||this._isPaused===!0)&&(this._isRunning=!1,this._isPaused=!1,this._isStopped=!0,this.processEvents(b.TimerEvent.TIMER_STOP)),this},c.prototype.pause=function(){return this._isRunning===!0&&(this._isRunning=!1,this._isPaused=!0),this},c.prototype.resume=function(){return this._isPaused===!0&&(this._isRunning=!0,this._isPaused=!1),this},c.prototype.addTimerEvent=function(a){return a.type===b.TimerEvent.TIMER_START?this._startEvents.push(a):a.type===b.TimerEvent.TIMER_COUNT?this._countEvents.push(a):a.type===b.TimerEvent.TIMER_STOP&&this._stopEvents.push(a),a},c.prototype.createTimerEvent=function(a,c,d){return a===b.TimerEvent.TIMER_START?(this._startEvents.push(new b.TimerEvent(a,c,d)),this._startEvents[this._startEvents.length-1]):a===b.TimerEvent.TIMER_COUNT?(this._countEvents.push(new b.TimerEvent(a,c,d)),this._countEvents[this._countEvents.length-1]):a===b.TimerEvent.TIMER_STOP?(this._stopEvents.push(new b.TimerEvent(a,c,d)),this._stopEvents[this._stopEvents.length-1]):null},c.prototype.removeTimerEvent=function(a){var c=[];return a.type===b.TimerEvent.TIMER_START?c=this._startEvents.splice(this._startEvents.indexOf(a),1):a.type===b.TimerEvent.TIMER_COUNT?c=this._countEvents.splice(this._countEvents.indexOf(a),1):a.type===b.TimerEvent.TIMER_STOP&&(c=this._stopEvents.splice(this._stopEvents.indexOf(a),1)),1===c.length?!0:!1},c.prototype.clear=function(a){void 0===a&&(a=0),0===a?(this._startEvents.length=0,this._countEvents.length=0,this._stopEvents.length=0):a===b.TimerEvent.TIMER_START?this._startEvents.length=0:a===b.TimerEvent.TIMER_COUNT?this._countEvents.length=0:a===b.TimerEvent.TIMER_STOP&&(this._stopEvents.length=0)},c.prototype.toString=function(){return"[{Timer (name="+this.name+" delay="+this.delay+" repeatCount="+this.repeatCount+" running="+this._isRunning+")}]"},c}();b.Timer=c}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this._callback=null,this.type=0,this.type=a,this._callback=b,this._callbackContext=c}return a.prototype.objType=function(){return"TimerEvent"},a.prototype.run=function(){this._callback&&this._callback.apply(this._callbackContext)},a.TIMER_START=1,a.TIMER_COUNT=2,a.TIMER_STOP=3,a}();a.TimerEvent=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!1),this.domElement=null,this.context=null,this._visible=!0,this._offScreen=!1,this._clearMode=1,this.domElement=document.createElement("canvas"),this.domElement.width=b,this.domElement.height=c,this._width=b,this._height=c,this.context=this.domElement.getContext("2d"),this._offScreen=e,this._visible=d,d===!1&&(this.domElement.style.display="none"),this._bgColor=new a.Utils.Color(0,0,0)}return Object.defineProperty(b.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a,this._updatedSize()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a,this._updatedSize()},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Canvas"},Object.defineProperty(b.prototype,"bgColor",{get:function(){return"#"+this._bgColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._bgColor.set.apply(this._bgColor,b)},enumerable:!0,configurable:!0}),b.prototype._updatedSize=function(){this.domElement.width=this._width,this.domElement.height=this._height},b.prototype.destroy=function(){this._offScreen===!1&&(this.domElement.style.display="none")},Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){null!==a&&a!==this._visible&&(this._visible=a,this.domElement.style.display=a===!0?"block":"none")},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clearMode",{get:function(){return this._clearMode},set:function(b){null!==b&&b!==this._clearMode&&b>=a.Utils.Canvas.CLEARMODE_NONE&&b<=a.Utils.Canvas.CLEARMODE_FILLRECT_ALPHA&&(this._clearMode=b)},enumerable:!0,configurable:!0}),b.prototype.clear=function(){this._clearMode===b.CLEARMODE_NONE||(this._clearMode===b.CLEARMODE_CLEARRECT?this.context.clearRect(0,0,this.domElement.width,this.domElement.height):this._clearMode===b.CLEARMODE_FILLRECT?(this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)):this._clearMode===b.CLEARMODE_FILLRECT_ALPHA&&(this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)))},b.prototype.saveAsPNG=function(){return this.domElement.toDataURL()},b.prototype.toString=function(){return"[{Canvas (width="+this.width+" height="+this.height+" visible="+this.visible+" offScreen="+this._offScreen+" clearMode="+this.clearMode+")}]"},b.CLEARMODE_NONE=0,b.CLEARMODE_CLEARRECT=1,b.CLEARMODE_FILLRECT=2,b.CLEARMODE_FILLRECT_ALPHA=3,b}();b.Canvas=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){for(var a=[],b=0;b1?this.r255=a:this.rNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g",{get:function(){return this._g},set:function(a){a>1?this.g255=a:this.gNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b",{get:function(){return this._b},set:function(a){a>1?this.b255=a:this.bNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a",{get:function(){return this._a},set:function(a){a>1?this.a255=a:this.aNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"r255",{get:function(){return Math.round(255*this._r)},set:function(a){isNaN(a)||(this._r=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g255",{get:function(){return Math.round(255*this._g)},set:function(a){isNaN(a)||(this._g=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b255",{get:function(){return Math.round(255*this._b)},set:function(a){isNaN(a)||(this._b=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a255",{get:function(){return Math.round(255*this._a)},set:function(a){isNaN(a)||(this._a=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"red",{get:function(){return this.r},set:function(a){this.r=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"green",{get:function(){return this.g},set:function(a){this.g=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"blue",{get:function(){return this.b},set:function(a){this.b=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"alpha",{get:function(){return this.a},set:function(a){this.a=a},enumerable:!0,configurable:!0}),a.prototype.parseString=function(a){var b;return a=a.toLowerCase(),"rgba"===a.slice(0,4)?(a=a.replace("rgba",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2],this.a=+b[3]):"rgb"===a.slice(0,3)?(a=a.replace("rgb",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2]):"hsla"===a.slice(0,4)?(a=a.replace("hsla",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2],+b[3])):"hsl"===a.slice(0,3)?(a=a.replace("hsl",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2])):this.parseHex(a),this},a.prototype.parseHex=function(a){var b,c=this.r255,d=this.g255,e=this.b255,f=this.a255;return"#"===a.charAt(0)&&(a=a.slice(1)),"0x"===a.slice(0,2)&&(a=a.slice(2)),b=parseInt(a,16),3===a.length?(c=17*(b>>8&15),d=17*(b>>4&15),e=17*(15&b)):4===a.length?(c=17*(b>>12&15),d=17*(b>>8&15),e=17*(b>>4&15),f=17*(15&b)):6===a.length?(c=b>>16&255,d=b>>8&255,e=255&b,f=255):8===a.length&&(c=b>>24&255,d=b>>16&255,e=b>>8&255,f=255&b),this.r255=c,this.g255=d,this.b255=e,this.a255=f,this},a.prototype.getHex=function(a){void 0===a&&(a=!0);var b,c="";for(b=this.r255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.g255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.b255.toString(16);b.length<2;)b="0"+b;if(c+=b,a){for(b=this.a255.toString(16);b.length<2;)b="0"+b;c+=b}return c},a.prototype.parseHsv=function(a,b,c,d){void 0===d&&(d=1);var e,f,g,h,i,j,k,l;if(isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d))return this;switch(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),h=Math.floor(6*a),i=6*a-h,j=c*(1-b),k=c*(1-i*b),l=c*(1-(1-i)*b),h%6){case 0:e=c,f=l,g=j;break;case 1:e=k,f=c,g=j;break;case 2:e=j,f=c,g=l;break;case 3:e=j,f=k,g=c;break;case 4:e=l,f=j,g=c;break;case 5:e=c,f=j,g=k}return this._r=e,this._g=f,this._b=g,this._a=d,this},a.prototype.getHsva=function(){var a,b,c,d,e=this._r,f=this._g,g=this._b,h=Math.max(e,f,g),i=Math.min(e,f,g);if(a=h,b=h,c=h,d=h-i,b=0===h?0:d/h,h===i)a=0;else{switch(h){case e:a=(f-g)/d+(g>f?6:0);break;case f:a=(g-e)/d+2;break;case g:a=(e-f)/d+4}a/=6}return{h:a,s:b,v:c,a:this._a}},a.prototype.parseHsl=function(a,b,c,d){void 0===d&&(d=1);var e,f,g=this._r,h=this._g,i=this._b;return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)?this:(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),0===b?(g=c,h=c,i=c):(e=.5>c?c*(1+b):c+b-c*b,f=2*c-e,g=this._hue2rgb(f,e,a+1/3),h=this._hue2rgb(f,e,a),i=this._hue2rgb(f,e,a-1/3)),this._r=g,this._g=h,this._b=i,this._a=d,this)},a.prototype.getHsla=function(){var a,b=this._r,c=this._g,d=this._b,e=Math.max(b,c,d),f=Math.min(b,c,d),g=(e+f)/2,h=(e+f)/2,i=(e+f)/2;if(e==f)g=0,h=0;else{switch(a=e-f,h=i>.5?a/(2-e-f):a/(e+f),e){case b:g=(c-d)/a+(d>c?6:0);break;case c:g=(d-b)/a+2;break;case d:g=(b-c)/a+4}g/=6}return{h:g,s:h,l:i,a:this._a}},a.prototype._hue2rgb=function(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a},a}();a.Color=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.defaultCompare=function(a,b){return b>a?-1:a===b?0:1},b.prototype.objType=function(){return"Common"},b.defaultEquals=function(a,b){return a===b},b.defaultToString=function(b){return null===b?"KIWI_NULL":a.Utils.Common.isUndefined(b)?"KIWI_UNDEFINED":a.Utils.Common.isString(b)?b:b.toString()},b.isBetween=function(a,b,c){return a>b&&c>a},b.isFunction=function(a){return"function"==typeof a},b.isNumeric=function(a){return!isNaN(a)},b.isUndefined=function(a){return"undefined"==typeof a},b.isString=function(a){return"[object String]"===Object.prototype.toString.call(a)},b.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b.isObject=function(a){return"[object Object]"===Object.prototype.toString.call(a)},b.reverseCompareFunction=function(b){return a.Utils.Common.isFunction(b)?function(a,c){return-1*b(a,c)}:function(a,b){return b>a?1:a===b?0:-1}},b.compareToEquals=function(a){return function(b,c){return 0===a(b,c)}},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},b.convertToBase2=function(a){var b=a.width,c=a.height;if(-1==this.base2Sizes.indexOf(b)){for(var d=0;b>this.base2Sizes[d];)d++;b=this.base2Sizes[d]}if(-1==this.base2Sizes.indexOf(c)){for(var d=0;c>this.base2Sizes[d];)d++;c=this.base2Sizes[d]}if(a.width!==b||a.height!==c){var e=document.createElement("canvas");return e.width=b,e.height=c,e.getContext("2d").drawImage(a,0,0),e}return a},b.base2Sizes=[2,4,16,32,64,128,256,512,1024,2048,4096],b}();b.Common=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"GameMath"},b.computeMachineEpsilon=function(){var a=4/3,b=a-1,c=b+b+b;return Math.abs(1-c)},b.fuzzyEqual=function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)a},b.fuzzyGreaterThan=function(a,b,c){return void 0===c&&(c=1e-4),a>b-c},b.fuzzyCeil=function(a,b){return void 0===b&&(b=1e-4),Math.ceil(a-b)},b.fuzzyFloor=function(a,b){return void 0===b&&(b=1e-4),Math.floor(a+b)},b.average=function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},b.shear=function(a){return a%1},b.wrap=function(a,b,c){if(void 0===c&&(c=0),a-=c,b-=c,0==b)return c;for(a%=b,a+=c;c>a;)a+=b;return a},b.arithWrap=function(a,b,c){return void 0===c&&(c=0),b-=c,0==b?c:a-b*Math.floor((a-c)/b)},b.clamp=function(a,b,c){return void 0===c&&(c=0),Math.max(c,Math.min(b,a))},b.snapTo=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},b.snapToFloor=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},b.snapToCeil=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},b.snapToInArray=function(a,b,c){if(void 0===c&&(c=!0),c&&b.sort(),a=f-a?f:e},b.roundTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},b.floorTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},b.ceilTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},b.interpolateFloat=function(a,b,c){return(b-a)*c+a},b.radiansToDegrees=function(a){return a*b.RAD_TO_DEG},b.degreesToRadians=function(a){return a*b.DEG_TO_RAD},b.angleBetween=function(a,b,c,d){return Math.atan2(d-b,c-a)},b.normalizeAngle=function(a,c){void 0===c&&(c=!0);var d=c?b.PI:180;return b.wrap(a,d,-d)},b.nearestAngleBetween=function(a,c,d){void 0===d&&(d=!0);var e=d?b.PI:180;return a=b.normalizeAngle(a,d),c=b.normalizeAngle(c,d),-e/2>a&&c>e/2&&(a+=2*e),-e/2>c&&a>e/2&&(c+=2*e),b.normalizeAngle(c-a,d)},b.normalizeAngleToAnother=function(b,c,d){return void 0===d&&(d=!0),c+a.Utils.GameMath.nearestAngleBetween(c,b,d)},b.normalizeAngleAfterAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(b-c,d),c+b},b.normalizeAngleBeforeAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(c-b,d),c-b},b.interpolateAngles=function(b,c,d,e,f){return void 0===e&&(e=!0),void 0===f&&(f=null),b=a.Utils.GameMath.normalizeAngle(b,e),c=a.Utils.GameMath.normalizeAngleToAnother(c,b,e),"function"==typeof f?f(d,b,c-b,1):a.Utils.GameMath.interpolateFloat(b,c,d)},b.logBaseOf=function(a,b){return Math.log(a)/Math.log(b)},b.GCD=function(a,b){var c;for(a=Math.abs(a),b=Math.abs(b),b>a&&(c=a,a=b,b=c);;){if(c=a%b,!c)return b;a=b,b=c}return 1},b.LCM=function(b,c){return b*c/a.Utils.GameMath.GCD(b,c)},b.factorial=function(a){if(0==a)return 1;for(var b=a;--a;)b*=a;return b},b.gammaFunction=function(b){return a.Utils.GameMath.factorial(b-1)},b.fallingFactorial=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(b-c)},b.risingFactorial=function(b,c){return a.Utils.GameMath.factorial(b+c-1)/a.Utils.GameMath.factorial(b-1)},b.binCoef=function(b,c){return a.Utils.GameMath.fallingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.risingBinCoef=function(b,c){return a.Utils.GameMath.risingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.chanceRoll=function(a){return void 0===a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},b.maxAdd=function(a,b,c){return a+=b,a>c&&(a=c),a},b.minSub=function(a,b,c){return a-=b,c>a&&(a=c),a},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},b.randomSign=function(){return Math.random()>.5?1:-1},b.isOdd=function(a){return 1&a?!0:!1},b.isEven=function(a){return 1&a?!1:!0},b.wrapAngle=function(a){var b=a;return a>=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},b.angleLimit=function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},b.linearInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return 0>c?a.Utils.GameMath.linear(b[0],b[1],e):c>1?a.Utils.GameMath.linear(b[d],b[d-1],d-e):a.Utils.GameMath.linear(b[f],b[f+1>d?d:f+1],e-f)},b.bezierInterpolation=function(b,c){for(var d=0,e=b.length-1,f=0;e>=f;f++)d+=Math.pow(1-c,e-f)*Math.pow(c,f)*b[f]*a.Utils.GameMath.bernstein(e,f);return d},b.catmullRomInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return b[0]===b[d]?(0>c&&(f=Math.floor(e=d*(1+c))),a.Utils.GameMath.catmullRom(b[(f-1+d)%d],b[f],b[(f+1)%d],b[(f+2)%d],e-f)):0>c?b[0]-(a.Utils.GameMath.catmullRom(b[0],b[0],b[1],b[1],-e)-b[0]):c>1?b[d]-(a.Utils.GameMath.catmullRom(b[d],b[d],b[d-1],b[d-1],e-d)-b[d]):a.Utils.GameMath.catmullRom(b[f?f-1:0],b[f],b[f+1>d?d:f+1],b[f+2>d?d:f+2],e-f)},b.linear=function(a,b,c){return(b-a)*c+a},b.bernstein=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(c)/a.Utils.GameMath.factorial(b-c)},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},b.difference=function(a,b){return Math.abs(a-b)},b.PI=3.141592653589793,b.PI_2=1.5707963267948966,b.PI_4=.7853981633974483,b.PI_8=.39269908169872414,b.PI_16=.19634954084936207,b.TWO_PI=6.283185307179586,b.THREE_PI_2=4.71238898038469,b.E=2.71828182845905,b.LN10=2.302585092994046,b.LN2=.6931471805599453,b.LOG10E=.4342944819032518,b.LOG2E=1.4426950408889634,b.SQRT1_2=.7071067811865476,b.SQRT2=1.4142135623730951,b.DEG_TO_RAD=.017453292519943295,b.RAD_TO_DEG=57.29577951308232,b.B_16=65536,b.B_31=2147483648,b.B_32=4294967296,b.B_48=281474976710656,b.B_53=9007199254740992,b.B_64=0x10000000000000000,b.ONE_THIRD=.3333333333333333,b.TWO_THIRDS=.6666666666666666,b.ONE_SIXTH=.16666666666666666,b.COS_PI_3=.8660254037844386,b.SIN_2PI_3=.03654595,b.CIRCLE_ALPHA=.5522847498307935,b.ON=!0,b.OFF=!1,b.SHORT_EPSILON=.1,b.PERC_EPSILON=.001,b.EPSILON=1e-4,b.LONG_EPSILON=1e-8,b}();b.GameMath=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){void 0===a&&(a=[]),this.c=1,this._data={lipsum:["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","nunc","sagittis","tortor","ac","mi","pretium","sed","convallis","massa","pulvinar","curabitur","non","turpis","velit","vitae","rutrum","odio","aliquam","sapien","orci","tempor","sed","elementum","sit","amet","tincidunt","sed","risus","etiam","nec","lacus","id","ante","hendrerit","malesuada","donec","porttitor","magna","eget","libero","pharetra","sollicitudin","aliquam","mattis","mattis","massa","et","porta","morbi","vitae","magna","augue","vestibulum","at","lectus","sed","tellus","facilisis","tincidunt","suspendisse","eros","magna","consequat","at","sollicitudin","ac","vestibulum","vel","dolor","in","egestas","lacus","quis","lacus","placerat","et","molestie","ipsum","scelerisque","nullam","sit","amet","tortor","dui","aenean","pulvinar","odio","nec","placerat","fringilla","neque","dolor"]},this.sow(a)}return a.prototype.objType=function(){return"RandomDataGenerator"},a.prototype.uint32=function(){return 4294967296*this.rnd.apply(this)},a.prototype.fract32=function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},a.prototype.rnd=function(){var a=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|a,this.s0=this.s1,this.s1=this.s2,this.s2=a-this.c,this.s2},a.prototype.hash=function(a){var b,c,d;for(d=4022871197,a=a.toString(),c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},a.prototype.sow=function(a){void 0===a&&(a=[]),this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1);for(var b,c=0;b=a[c++];)this.s0-=this.hash(b),this.s0+=~~(this.s0<0),this.s1-=this.hash(b),this.s1+=~~(this.s1<0),this.s2-=this.hash(b),this.s2+=~~(this.s2<0)},a.prototype.integer=function(){return this.uint32()},a.prototype.frac=function(){return this.fract32()},a.prototype.real=function(){return this.uint32()+this.fract32()},a.prototype.integerInRange=function(a,b){return Math.floor(this.realInRange(a,b))},a.prototype.realInRange=function(a,b){return a=a||0,b=b||0,this.frac()*(b-a)+a},a.prototype.normal=function(){return 1-2*this.frac()},a.prototype.uuid=function(){var a,b;for(b=a="";a++<36;b+=~a%5|3*a&4?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},a.prototype.pick=function(a){return a[this.integerInRange(0,a.length)]},a.prototype.weightedPick=function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},a.prototype.word=function(){return this.pick(this._data.lipsum)},a.prototype.words=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.pick(this._data.lipsum));return b.join(" ")},a.prototype.sentence=function(){var a;return a=this.words(this.integerInRange(2,16)).replace(/[a-z]/,function(a){return a.toUpperCase()}),a+"."},a.prototype.sentences=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.sentence());return b.join(" ")},a.prototype.timestamp=function(a,b){return void 0===a&&(a=9466848e5),void 0===b&&(b=1577862e6),this.realInRange(a,b)},a.prototype.angle=function(){return this.integerInRange(-180,180)},a}();a.RandomDataGenerator=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._isSetTimeOut=!1,this.lastTime=0,this.currentTime=0,this.isRunning=!1,this._rafId=null,this._callback=a;for(var b=["ms","moz","webkit","o"],c=0;c0?this.recordings[this.recordings.length-1].time:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"numRecordings",{get:function(){return this.recordings.length},enumerable:!0,configurable:!0}),b.prototype.record=function(a,b,c){if(void 0===b&&(b=[]),void 0===c&&(c=console.log),this.recording){var d={messages:a,time:Date.now(),tags:b,logMethod:c};this.recordings.push(d)>this.maxRecordings&&this.recordings.shift()}},b.prototype.clearRecordings=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.recordings.length),this.recordings.splice(a,b)},b.prototype._execute=function(a,b,c,d){void 0===d&&(d=!1),(this.display||d)&&a.apply(b,c)},b.prototype.getTagsFromArray=function(a){for(var b=0,c=[];bd.time&&this._show(d,c)},b.prototype.addFilter=function(){for(var a=[],b=0;be.majorVersion?"greater":d.majorVersione.minorVersion?"greater":d.minorVersione.patchVersion?"greater":d.patchVersion0&&(this._frameRate=a,this._interval=1e3/this._frameRate,this.time.setMasterInterval(this._interval))},enumerable:!0,configurable:!0}),b.prototype._start=function(){var b=this;this.stage.boot(this._startup),this.stage.renderer||a.Log.error(" Kiwi.Game: Could not create rendering context","#renderer"),this._renderOption===a.RENDERER_WEBGL&&this.stage.ctx&&(this._renderOption=a.RENDERER_CANVAS),this.renderer=this.stage.renderer,this.renderer.boot(),this.cameras.boot(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.boot(),this.time.boot(),this.input.boot(),this.audio.boot(),this.fileStore.boot(),this.loader.boot(),this.states.boot(),this.pluginManager.boot(),this._lastTime=Date.now(),this.raf=new a.Utils.RequestAnimationFrame(function(){return b._loop()}),this.raf.start(),this.bootCallbackOption&&(a.Log.log(" Kiwi.Game: invoked boot callback","#boot"),this.bootCallbackOption(this))},b.prototype._loop=function(){this._delta=this.raf.currentTime-this._lastTime,this._delta>this._interval&&(this.time.update(),this.audio.update(),this.input.update(),this.tweens.update(),this.cameras.update(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.update(),this.states.update(),this.pluginManager.update(),this._frame++,this._lastTime=this.raf.currentTime-this._delta%this._interval),null!==this.states.current&&(this.cameras.render(),this.states.postRender())},b}();a.Game=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(b,c,d,e,f){this._scaleType=a.Stage.SCALE_NONE,this.offset=new a.Geom.Point,this._color=new a.Utils.Color,this.container=null,this._game=b,this.name=c,this.domReady=!1,this._alpha=1,this._x=0,this._y=0,this._width=d,this._height=e,this.color="ffffff",this._game.deviceTargetOption===a.TARGET_COCOON&&(this.color="000000"),this._scale=new a.Geom.Point(1,1),this._scaleType=f,this.onResize=new a.Signal,this.onWindowResize=new a.Signal,this.onFocus=new a.Signal,this.onBlur=new a.Signal,this.onVisibilityChange=new a.Signal,this._renderer=null}return b.prototype.objType=function(){return"Stage"},Object.defineProperty(b.prototype,"scaleType",{get:function(){return this._scaleType},set:function(a){this._scaleType=a,this._scaleContainer()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"alpha",{get:function(){return this._alpha},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.container.style.opacity=String(a.Utils.GameMath.clamp(b,1,0))),this._alpha=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.left=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.left=String(b+"px")),this._x=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.top=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.top=String(b+"px")),this._y=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleX",{get:function(){return this._scale.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleY",{get:function(){return this._scale.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"color",{get:function(){return this._color.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._color.set.apply(this._color,b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b}},set:function(a){this._color.r255=a.r,this._color.g255=a.g,this._color.b255=a.b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbaColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b,a:255*this._color.a}},set:function(a){this._color.r255=a.r,this._color.g255=a.g,this._color.b255=a.b,this._color.a255=a.a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"normalizedColor",{get:function(){return{r:this._color.r,g:this._color.g,b:this._color.b,a:this._color.a}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"renderer",{get:function(){return this._renderer},enumerable:!0,configurable:!0}),b.prototype.boot=function(b){var c=this,d=this;this.domReady=!0,this.container=b.container,this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.offset=this.getOffsetPoint(this.container),this._x=this.offset.x,this._y=this.offset.y,window.addEventListener("resize",function(a){return c._windowResized(a)},!0),this._createFocusEvents()),this._createCompositeCanvas(),this._game.deviceTargetOption===a.TARGET_COCOON?(this._scaleContainer(),window.addEventListener("orientationchange",function(a){return d._orientationChanged(a)},!0)):this._calculateContainerScale()},b.prototype.getOffsetPoint=function(b,c){void 0===c&&(c=new a.Geom.Point);var d=b.getBoundingClientRect(),e=b.clientTop||document.body.clientTop||0,f=b.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||b.scrollTop||document.body.scrollTop,h=window.pageXOffset||b.scrollLeft||document.body.scrollLeft;return c.setTo(d.left+h-f,d.top+g-e)},b.prototype._windowResized=function(a){this._calculateContainerScale(),this.onWindowResize.dispatch()},b.prototype._orientationChanged=function(a){this.onResize.dispatch(window.innerWidth,window.innerHeight)},b.prototype._calculateContainerScale=function(){this._scaleContainer(),this._scaleContainer(),this.offset=this.getOffsetPoint(this.container),this._scale.x=this._width/this.container.clientWidth,this._scale.y=this._height/this.container.clientHeight},b.prototype._createCompositeCanvas=function(){this._game.deviceTargetOption==a.TARGET_COCOON?this.canvas=document.createElement(navigator.isCocoonJS?"screencanvas":"canvas"):(this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%"),this.canvas.id=this._game.id+"compositeCanvas",this.canvas.style.position="absolute",this.canvas.width=this.width,this.canvas.height=this.height,this._game.renderOption===a.RENDERER_CANVAS?(this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null):this._game.renderOption===a.RENDERER_WEBGL&&(this.gl=this.canvas.getContext("webgl"),this.gl||(this.gl=this.canvas.getContext("experimental-webgl"),this.gl?a.Log.warn("Kiwi.Stage: 'webgl' context is not available. Using 'experimental-webgl'","#renderer"):(a.Log.warn("Kiwi.Stage: WebGL rendering is not available despite the device apparently supporting it. Reverting to CANVAS.","#renderer"),this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null)),this.gl&&(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.ctx=null)),this.ctx?this._renderer=new a.Renderers.CanvasRenderer(this._game):this.gl&&(this._renderer=new a.Renderers.GLRenderManager(this._game)),this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.appendChild(this.canvas):document.body.appendChild(this.canvas)},b.prototype.resize=function(b,c){this.canvas.height=c,this.canvas.width=b,this._height=c,this._width=b,this._game.deviceTargetOption===a.TARGET_BROWSER&&this._calculateContainerScale(),this.onResize.dispatch(this._width,this._height)},b.prototype.setRGBColor=function(a,b,c){return this.rgbColor={r:a,g:b,b:c},this.rgbColor},b.prototype.createDebugCanvas=function(){0!=a.Utils.Common.isUndefined(this.debugCanvas)&&(this._game.deviceTargetOption===a.TARGET_COCOON&&a.Log.log("Debug canvas not supported in cocoon, creating canvas and context anyway","#debug-canvas"),this.debugCanvas=document.createElement("canvas"),this.debugCanvas.id=this._game.id+"debugCanvas",this.debugCanvas.style.position="absolute",this.debugCanvas.width=this.width,this.debugCanvas.height=this.height,this.debugCanvas.style.width="100%",this.debugCanvas.style.height="100%",this.dctx=this.debugCanvas.getContext("2d"),this.clearDebugCanvas(),this._game.deviceTargetOption===a.TARGET_BROWSER&&this.container.appendChild(this.debugCanvas))},b.prototype.clearDebugCanvas=function(a){this.dctx.fillStyle=a||"rgba(255,0,0,.2)",this.dctx.clearRect(0,0,this.width,this.height),this.dctx.fillRect(0,0,this.width,this.height)},b.prototype.toggleDebugCanvas=function(){this.debugCanvas.style.display="none"===this.debugCanvas.style.display?"block":"none"},b.prototype._scaleContainer=function(){if(this._game.deviceTargetOption==a.TARGET_BROWSER){var b=this.container.clientWidth;this.container.style.width=String(this._width+"px"),this.container.style.height=String(this._height+"px"),this._scaleType==a.Stage.SCALE_NONE&&(this.container.style.maxWidth="",this.container.style.minWidth=""),(this._scaleType==a.Stage.SCALE_STRETCH||this._scaleType==a.Stage.SCALE_FIT)&&(this.container.style.minWidth="100%",this.container.style.maxWidth="100%"),this._scaleType==a.Stage.SCALE_STRETCH?(this.container.style.minHeight="100%",this.container.style.maxHeight="100%"):(this.container.style.minHeight="",this.container.style.maxHeight=""),this._scaleType==a.Stage.SCALE_FIT&&(this.container.style.height=String(b/this._width*this._height)+"px")}if(this._game.deviceTargetOption==a.TARGET_COCOON)switch(this._scaleType){case a.Stage.SCALE_FIT:this.canvas.style.cssText="idtkscale:ScaleAspectFit";break;case a.Stage.SCALE_STRETCH:this.canvas.style.cssText="idtkscale:ScaleToFill";break;case a.Stage.SCALE_NONE:this.canvas.style.cssText=""}},Object.defineProperty(b.prototype,"visibility",{get:function(){return this._visibility?!document[this._visibility]:!0},enumerable:!0,configurable:!0}),b.prototype._checkVisibility=function(a){return"focus"===a.type||"pageshow"===a.type?void this.onFocus.dispatch(a):"pagehide"===a.type||"blur"===a.type?void this.onBlur.dispatch(a):"visibilitychange"===a.type||"mozvisibilitychange"===a.type||"webkitvisibilitychange"===a.type||"msvisibilitychange"===a.type?void this.onVisibilityChange.dispatch():void 0},b.prototype._createFocusEvents=function(){this._visibility="hidden",this._visibilityChange=this._checkVisibility.bind(this),"hidden"in document?document.addEventListener("visibilitychange",this._visibilityChange):(this._visibility="mozHidden")in document?document.addEventListener("mozvisibilitychange",this._visibilityChange):(this._visibility="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",this._visibilityChange):(this._visibility="msHidden")in document?document.addEventListener("msvisibilitychange",this._visibilityChange):this._visibility=null,window.addEventListener("pageshow",this._visibilityChange),window.addEventListener("pagehide",this._visibilityChange),window.addEventListener("focus",this._visibilityChange),window.addEventListener("blur",this._visibilityChange)},b.DEFAULT_WIDTH=800,b.DEFAULT_HEIGHT=600,b.SCALE_NONE=0,b.SCALE_FIT=1,b.SCALE_STRETCH=2,b}();a.Stage=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function a(a,b){this._components={},this._type=a,this._owner=b}return a.prototype.objType=function(){return"ComponentManager"},a.prototype.hasComponent=function(a){return this._components[a]?!0:!1},a.prototype.hasActiveComponent=function(a){return this._components[a]&&this._components[a].active===!0?!0:!1},a.prototype.getComponent=function(a){return this._components[a]?this._components[a]:null},a.prototype.add=function(a){return this._components[a.name]=a,a},a.prototype.addBatch=function(){for(var a=[],b=0;bf.majorVersion?a.Log.warn(" Kiwi.PluginManager: This major version of Kiwi is greater than that required by '"+d+"'. It is unknown whether this plugin will work with this version of Kiwi","#plugin"):a.Utils.Version.greaterOrEqual(a.VERSION,a.Plugins[d].minimumKiwiVersion)?a.Log.log(" Kiwi.PluginManager: Kiwi version meets minimum version requirements for '"+d+"'.","#plugin"):a.Log.warn(" Kiwi.PluginManager: Kiwi version ("+a.VERSION+") does not meet minimum version requirements for the plugin ("+a.Plugins[d].minimumKiwiVersion+").","#plugin")}else a.Log.warn(" Kiwi.PluginManager: '"+d+"' is missing the minimumKiwiVersion property. It is unknown whether '"+d+"' will work with this version of Kiwi","#plugin");else a.Log.log(" Kiwi.PluginManager: Plugin '"+d+"' appears to be invalid. No property with that name exists on the Kiwi.Plugins object or the Plugin is not registered. Check that the js file containing the plugin has been included. This plugin will be ignored","#plugin");else a.Log.log(" Kiwi.PluginManager: The supplied plugin name at index "+c+"is not a string and will be ignored","#plugin")}this._plugins=b;for(var c=0;c=a&&(a=0),a>1&&(a=1),this._alpha=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){this._visible=a},enumerable:!0,configurable:!0}),b.prototype.scaleToWidth=function(a){this.scale=a/this.width},b.prototype.scaleToHeight=function(a){this.scale=a/this.height},b.prototype.centerAnchorPoint=function(){this.anchorPointX=.5*this.width,this.anchorPointY=.5*this.height},Object.defineProperty(b.prototype,"cellIndex",{get:function(){return this._cellIndex},set:function(b){if(null!==this.atlas){var c=this.atlas.cells[b];void 0!==c?(this._cellIndex=b,this.width=c.w,this.height=c.h):a.Log.error("Could not the set the cellIndex of a Entity, to cell that does not exist on its TextureAtlas.","#entity","#cellIndex")}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"exists",{get:function(){return this._exists},set:function(a){this._exists=a},enumerable:!0,configurable:!0}),b.prototype.addTag=function(){for(var a=[],b=0;b-1&&(this.members.splice(c,1),a.parent=null,b&&a.destroy())}return a},b.prototype.removeChildAt=function(a){if(this.members[a]){var b=this.members[a];return this.removeChild(b)}return null},b.prototype.removeChildren=function(a,b,c){void 0===a&&(a=0),void 0===b&&(b=2147483647),void 0===c&&(c=!1),b-=a;for(var d=this.members.splice(a,b),e=0;e=0;c--){if(this.members[c].hasTag(b))return this.members[c];if(this.members[c].childType()==a.GROUP){var d=this.members[c].getLastChildByTag(b);if(d)return d}}return null},b.prototype.setChildIndex=function(a,b){return a.parent!==this||this.getChildIndex(a)===b?!1:(this.removeChild(a),this.addChildAt(a,b),!0)},b.prototype.swapChildren=function(a,b){if(a.parent!==this||b.parent!==this)return!1;var c=this.getChildIndex(a),d=this.getChildIndex(b);return-1!==c&&-1!==d&&c!==d?(this.members[c]=b,this.members[d]=a,!0):!1},b.prototype.swapChildrenAt=function(a,b){var c=this.getChildAt(a),d=this.getChildAt(b);return null!==c&&null!==d?c==d||c.parent!==this||d.parent!==this?!1:(this.members[a]=d,this.members[b]=c,!0):!1},b.prototype.replaceChild=function(a,b){if(a===b)return!1;var c=this.getChildIndex(a);return c>-1?(b.parent&&b.parent.removeChild(b),this.removeChildAt(c),this.addChildAt(b,c),b.parent=null,!0):!1},b.prototype.forEach=function(a,b){for(var c=[],d=2;d0&&this.members.forEach(function(d){return b.apply(a,[d].concat(c))})},b.prototype.forEachAlive=function(a,b){for(var c=[],d=2;d0&&this.members.forEach(function(d){d.exists&&b.apply(a,[d].concat(c))})},b.prototype.setAll=function(a,b,c){if(null===a)for(var d=0;d0)for(var a=0;a-1&&this._trackingList.splice(b,1)},c.prototype.destroyUnused=function(){for(var a=0,b=0;b0;)this._trackingList[0].destroy(!0,!1);for(this._trackingList=[];this.members.length>0;)this.members[0].destroy(!0,!1);this.members=[]}},c.prototype._destroyChildren=function(b){if(b.childType()==a.GROUP)for(var c=0;c0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.Sprite=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f){return void 0===e&&(e=0),void 0===f&&(f=0),b.call(this,c,e,f),this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),a.Utils.Common.isString(d)&&(d=this.state.textures[d]),"undefined"==typeof d?(a.Log.error("A Texture Atlas was not passed when instantiating a new Static Image.","#static-image","#texture"),this.visible=!1,void(this.active=!1)):(this.atlas=d,this.cellIndex=this.atlas.cellIndex,this.width=d.cells[this.cellIndex].w,this.height=d.cells[this.cellIndex].h,this.transform.rotPointX=this.width/2,this.transform.rotPointY=this.height/2,void(this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))))}return __extends(c,b),c.prototype.objType=function(){return"StaticImage"},c.prototype.render=function(a){if(b.prototype.render.call(this,a),this.alpha>0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.StaticImage=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h,i,j){void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g="#000000"),void 0===h&&(h=32),void 0===i&&(i="normal"),void 0===j&&(j="sans-serif"),b.call(this,c,e,f),this._tempDirty=!0,this._pt1=new a.Geom.Point(0,0),this._pt2=new a.Geom.Point(0,0),this._pt3=new a.Geom.Point(0,0),this._pt4=new a.Geom.Point(0,0),this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),this._text=d,this._fontWeight=i,this._fontSize=h,this._fontColor=new a.Utils.Color(g),this._fontFamily=j,this._textAlign="left",this._baseline="top",this._tempDirty=!0,this._canvas=document.createElement("canvas"),this._canvas.width=2,this._canvas.height=2,this._ctx=this._canvas.getContext("2d"),this.atlas=new a.Textures.SingleImage(this.game.rnd.uuid(),this._canvas),this.state.textureLibrary.add(this.atlas),this.atlas.dirty=!0,this._alignWidth=0,this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))}return __extends(c,b),c.prototype.objType=function(){return"Textfield"},Object.defineProperty(c.prototype,"text",{get:function(){return this._text},set:function(a){this._text=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"color",{get:function(){return"#"+this._fontColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._fontColor.set.apply(this._fontColor,b),this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(a){this._fontWeight=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontSize",{get:function(){return this._fontSize},set:function(a){this._fontSize=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(a){this._fontFamily=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"textAlign",{get:function(){return this._textAlign},set:function(a){this._textAlign=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),c.prototype._renderText=function(){this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily;var b=this._ctx.measureText(this._text),c=b.width,d=1.3*this._fontSize;if(this._alignWidth=c,-1==a.Utils.Common.base2Sizes.indexOf(c)){for(var e=0;c>a.Utils.Common.base2Sizes[e];)e++;c=a.Utils.Common.base2Sizes[e]}if(-1==a.Utils.Common.base2Sizes.indexOf(d)){for(var e=0;d>a.Utils.Common.base2Sizes[e];)e++;d=a.Utils.Common.base2Sizes[e]}this._canvas.width=c,this._canvas.height=d,this._ctx.clearRect(0,0,c,d),this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily,this._ctx.fillStyle=this.color.slice(0,7),this._ctx.textBaseline=this._baseline,this._ctx.fillText(this._text,0,0),this.width=this._alignWidth,this.height=this._canvas.height,this.atlas.cells[0]={x:0,y:0,w:this._canvas.width,h:this._canvas.height,hitboxes:[{x:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_LEFT?0:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_CENTER?.5*-this._alignWidth:-this._alignWidth,y:0,w:this.width,h:this.height}]},this._tempDirty=!1,this.atlas.dirty=!0},c.prototype.render=function(b){if(this.alpha>0&&this.visible){var c=this.game.stage.ctx;c.save();var d=this.transform;this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha),this._tempDirty&&this._renderText();var e=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:e=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:e=.5*this._alignWidth;break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:e=this._alignWidth}var f=d.getConcatenatedMatrix();c.transform(f.a,f.b,f.c,f.d,f.tx,f.ty),c.drawImage(this._canvas,0,0,this._canvas.width,this._canvas.height,-d.rotPointX-e,-d.rotPointY,this._canvas.width,this._canvas.height),c.restore()}},c.prototype.renderGL=function(b,c,d){void 0===d&&(d=null),this._tempDirty&&this._renderText();var e=[],f=this.transform,g=f.getConcatenatedMatrix(),h=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:h=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:h=-(.5*this._alignWidth);break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:h=-this._alignWidth}this._pt1.setTo(h-f.rotPointX,0-f.rotPointY),this._pt2.setTo(this._canvas.width+h-f.rotPointX,0-f.rotPointY),this._pt3.setTo(this._canvas.width+h-f.rotPointX,this._canvas.height-f.rotPointY),this._pt4.setTo(h-f.rotPointX,this._canvas.height-f.rotPointY),g.transformPoint(this._pt1),g.transformPoint(this._pt2),g.transformPoint(this._pt3),g.transformPoint(this._pt4),e.push(this._pt1.x,this._pt1.y,0,0,this.alpha,this._pt2.x,this._pt2.y,this._canvas.width,0,this.alpha,this._pt3.x,this._pt3.y,this._canvas.width,this._canvas.height,this.alpha,this._pt4.x,this._pt4.y,0,this._canvas.height,this.alpha),this.glRenderer.concatBatch(e)},c.TEXT_ALIGN_CENTER="center",c.TEXT_ALIGN_RIGHT="right",c.TEXT_ALIGN_LEFT="left",c}(a.Entity);b.TextField=c,b.Textfield=a.GameObjects.TextField}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=-1),this.allowCollisions=a.Components.ArcadePhysics.NONE,this.properties={},this.tilemap=b, +this.index=c,this.cellIndex=d,this.offset=new a.Geom.Point(0,0)}return b.prototype.objType=function(){return"TileType"},b}();b.TileType=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function c(b,c,d,e){void 0===e&&(e=0),this.tileWidth=0,this.tileHeight=0,this.width=0,this.height=0,this.properties={},this.tileTypes=[],this.createTileType(-1),this.layers=[],this.state=b,this.game=b.game,void 0!==c&&void 0!==d?this.createFromFileStore(c,d,e):(void 0!==c||void 0!==d)&&a.Log.warn("You must pass BOTH the TileMapDataKey and TextureAtlas inorder to create a TileMap from the File Store.","#tilemap")}return Object.defineProperty(c.prototype,"widthInPixels",{get:function(){return this.width*this.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"heightInPixels",{get:function(){return this.height*this.tileHeight},enumerable:!0,configurable:!0}),c.prototype.createFromFileStore=function(c,d,e){void 0===e&&(e=0);var f=null;switch(a.Utils.Common.isString(d)&&(d=this.state.textures[d]),typeof c){case"string":if(0==this.game.fileStore.exists(c))return a.Log.error("The JSON file you have told to use for a TileMap does not exist.","#tilemap","#json"),!1;f=JSON.parse(this.game.fileStore.getFile(c).data);break;case"object":f=c.isData&&c.dataType===a.Files.File.JSON?a.Utils.Common.isString(c.parse)?JSON.parse(c.data):c.data:c;break;default:a.Log.error("The type of TileMapData passed could not be idenified. Please either pass a name of JSON file to use OR an object to be used.","#tilemap")}this.orientation=void 0==f.orientation?b.ORTHOGONAL:f.orientation,this.tileWidth=void 0==f.tilewidth?32:f.tilewidth,this.tileHeight=void 0==f.tileheight?32:f.tileheight,this.width=f.width,this.height=f.height;for(var g in f.properties)this.properties[g]=f.properties[g];"undefined"!==f.tilesets&&-1!==e&&this._generateTypesFromTileset(f.tilesets,d,e);for(var h=0;hl;l+=h)for(var m=f;i>m;m+=g){var n=void 0==b.cells[c]?-1:c,o=this.createTileType(n);o.offset.x=k.x,o.offset.y=k.y,c++}for(var p in e.tileproperties){var o=this.tileTypes[parseInt(e.firstgid)+parseInt(p)];o.properties=e.tileproperties[p]}}},c.prototype.setTo=function(a,b,c,d){this.tileWidth=a,this.tileHeight=b,this.width=c,this.height=d},c.prototype.createTileType=function(a){void 0===a&&(a=-1);var c=new b.TileType(this,this.tileTypes.length,a);return this.tileTypes.push(c),c},c.prototype.createTileTypes=function(a){for(var b=[],c=0;c=d;d++)c.push(this.createTileType(d));return c},c.prototype.setCell=function(a,b){this.tileTypes[a].cellIndex=b},c.prototype.setCellsByRange=function(a,b,c){for(var d=a;a+c>d;d++)this.tileTypes[d].cellIndex=b,b++},c.prototype.createNewLayer=function(c,d,e,f,g,h,i,j,k,l){if(void 0===e&&(e=[]),void 0===f&&(f=this.width),void 0===g&&(g=this.height),void 0===h&&(h=0),void 0===i&&(i=0),void 0===j&&(j=this.tileWidth),void 0===k&&(k=this.tileHeight),void 0===l&&(l=this.orientation),e.lengthc||c>=this._data.length?-1:c},c.prototype.getTileFromXY=function(a,b){var c=this.getIndexFromXY(a,b);return-1!==c?this.tilemap.tileTypes[this._data[c]]:null},c.prototype.getIndexesByType=function(a){for(var b=[],c=0;cg;g++)for(var f=b;b+d>f;f++){var h=this.getIndexFromXY(f,g);-1!==h&&(this._data[h]=this.game.rnd.pick(a))}},c.prototype.fill=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height);for(var f=c;c+e>f;f++)for(var g=b;b+d>g;g++){var h=this.getIndexFromXY(g,f);-1!==h&&(this._data[h]=a)}},c.prototype.replaceTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&this._data[i]==a&&(this._data[i]=b)}},c.prototype.swapTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&(this._data[i]==a?this._data[i]=b:this._data[i]==b&&(this._data[i]=a))}},c.prototype.getOverlappingTiles=function(b,c){return void 0===c&&(c=a.Components.ArcadePhysics.ANY),[]},c.prototype.getCollidableTiles=function(b,c,d,e,f){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height),void 0===f&&(f=a.Components.ArcadePhysics.ANY);var g=[];if(!(b>this.width||c>this.height)){0>b&&(b=0),0>c&&(c=0),b+d>this.width&&(d=this.width-b),c+e>this.height&&(e=this.height-c);for(var h=c;c+e>h;h++)for(var i=b;b+d>i;i++){var j=this.getIndexFromXY(i,h);if(-1!==j){var k=this.tileData[j];(this.tilemap.tileTypes[k].allowCollisions&f)!==a.Components.ArcadePhysics.NONE&&g.push({index:j,type:k,x:i*this.tileWidth,y:h*this.tileHeight})}}return g}},c.prototype.update=function(){b.prototype.update.call(this)},c.prototype._calculateBoundaries=function(a,b){this._startX=0,this._startY=0,this._maxX=this.width,this._maxY=this.height},c.prototype.render=function(a){},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null)},c.prototype.chartToScreen=function(a,b,c){return void 0===b&&(b=this.tileWidth/2),void 0===c&&(c=this.tileHeight),{x:a.x*b-a.y*b,y:a.x*c/2+a.y*c/2}},c.prototype.screenToChart=function(a,b,c){void 0===b&&(b=this.tileWidth/2),void 0===c&&(c=this.tileHeight);var d=Math.floor(a.x/b),e=Math.floor((a.y-d*(c/2))/c);return{x:d+e,y:e}},c}(a.Entity);b.TileMapLayer=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(c){function d(a,d,e,f,g,h,i,j,k,l){void 0===i&&(i=0),void 0===j&&(j=0),void 0===k&&(k=0),void 0===l&&(l=0),c.call(this,a,d,e,f,g,h,i,j,k,l),this.orientation=b.ORTHOGONAL}return __extends(d,c),d.prototype.objType=function(){return"TileMapLayer"},d.prototype.getIndexFromCoords=function(b,c){if(b>this.transform.worldX+this.widthInPixels||c>this.transform.worldY+this.heightInPixels||be+this.widthInPixels||d.rightf+this.heightInPixels)return[];for(var g=d.x-e,h=d.y-f,i=a.Utils.GameMath.snapToFloor(g,this.tileWidth)/this.tileWidth,j=a.Utils.GameMath.snapToFloor(h,this.tileHeight)/this.tileHeight,k=a.Utils.GameMath.snapToCeil(d.width,this.tileWidth)/this.tileWidth,l=a.Utils.GameMath.snapToCeil(d.height,this.tileHeight)/this.tileHeight,m=this.getCollidableTiles(i,j,k+1,l+1,c),n=0;nd.right||o.x+this.tileWidth+ed.bottom||o.y+this.tileHeight+f0&&this.alpha<=1&&(b.globalAlpha=this.alpha);var c=this.transform,d=c.getConcatenatedMatrix();b.transform(d.a,d.b,d.c,d.d,d.tx,d.ty),this._calculateBoundaries(a,d);for(var e=this._startY;ec-c*Math.abs(b-d)/d)return-1;var e=this.screenToChart({x:a,y:b});return this.getIndexFromXY(e.x,e.y)},c.prototype.chartToScreen=function(a,b,c){return void 0===b&&(b=this.tileWidth),void 0===c&&(c=this.tileHeight),{x:(a.x-a.y)*b*.5,y:(a.x+a.y)*c*.5}},c.prototype.screenToChart=function(a,b,c){void 0===b&&(b=this.tileWidth),void 0===c&&(c=this.tileHeight);var d=a.x/(.5*b),e=a.y/(.5*c),f=Math.floor(.5*(d+e)),g=Math.floor(.5*(e-d));return{x:f,y:g}},c.prototype.render=function(a){if(!(this.visible===!1||this.alpha<.1||this.exists===!1)){var b=this.game.stage.ctx;b.save(),this.alpha>0&&this.alpha<=1&&(b.globalAlpha=this.alpha);var c=this.transform,d=c.getConcatenatedMatrix();b.transform(d.a,d.b,d.c,d.d,d.tx,d.ty),this._calculateBoundaries(a,d);for(var e=this._startY;e1)&&(this._nowEntered=b),this.isDown===!1&&b.frameDuration<2&&(this._nowDown=b),this._dragEnabled&&0==this.isDragging&&1==this.isDown&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top,this._nowDragging=b)):this.isDown===!0?this._nowLeft=b:this.withinBounds===!0&&this._withinBounds.id==b.id&&(this._nowLeft=b))},c.prototype._updateMouse=function(){this._evaluateMousePointer(this.game.input.mouse.cursor),null!==this._nowLeft&&this._onLeft.dispatch(this.owner,this._nowLeft),null!==this._nowEntered&&this._onEntered.dispatch(this.owner,this._nowEntered),null!==this._nowDown&&this.isDown===!1&&(this._onDown.dispatch(this.owner,this._nowDown),this._isDown=this._nowDown,this._isUp=!1),1==this._dragEnabled&&this.isDragging===!1&&null!==this._nowDragging&&(this._onDragStarted.dispatch(this.owner,this._nowDragging),this._isDragging=this._nowDragging),this.isDown===!0&&null!==this._nowUp&&this._isDown.id===this._nowUp.id&&(this._onUp.dispatch(this.owner,this._nowUp),this.isDragging===!0&&this._isDragging.id==this._nowUp.id&&(this._isDragging=null,this._onDragStopped.dispatch(this.owner,this._nowUp)),this._isDown=null,this._isUp=!0)},c.prototype._evaluateMousePointer=function(b){this._tempPoint=this.game.cameras.defaultCamera.transformPoint(b.point),a.Geom.Intersect.pointToRectangle(this._tempPoint,this._box.worldHitbox).result?(this._dragEnabled&&this.isDragging===!1&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top),this.withinBounds===!1&&(this._nowEntered=b,this._withinBounds=b,this._outsideBounds=!1,this._justEntered=!0)):this.withinBounds===!0&&this.isDragging===!1&&(this._nowLeft=b,this._withinBounds=null,this._outsideBounds=!0),b.isDown===!0?(this._justEntered&&(this._isDown=b,this._isUp=!1,this._tempDragDisabled=!0),this.withinBounds===!0&&this.isDown===!1&&null===this._nowDown&&(this._nowDown=b),this._dragEnabled===!0&&0==this.isDragging&&this._tempDragDisabled===!1&&1==this.isDown&&(this._nowDragging=b)):(this._tempDragDisabled===!0&&(this._tempDragDisabled=!1),this.isDown===!0&&(this._nowUp=b)),this._justEntered&&(this._justEntered=!1)},c.prototype.destroy=function(){b.prototype.destroy.call(this),this.enabled=!1,delete this._box,delete this._isDown,delete this._isUp,delete this._isDragging,delete this._dragEnabled,this._onDown&&this._onDown.dispose(),delete this._onDown,this._onDragStarted&&this._onDragStarted.dispose(),delete this._onDragStarted,this._onUp&&this._onUp.dispose(),delete this._onUp,this._onLeft&&this._onLeft.dispose(),delete this._onLeft,this._onEntered&&this._onEntered.dispose(),delete this._onEntered,this._onDragStopped&&this._onDragStopped.dispose(),delete this._onDragStopped,delete this._dragDistance},c}(a.Component);b.Input=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b,"Sound"),this._audio=[]}return __extends(b,a),b.prototype.objType=function(){return"Sound"},b.prototype.addSound=function(a,b,c,d){if(void 0===c&&(c=1),void 0===d&&(d=!1),1!=this._validate(a)){var e=this.game.audio.add(b,c,d);return this._audio[a]=e,e}},b.prototype.removeSound=function(a){0!=this._validate(a)&&(this._audio[a].stop(),this._audio[a].destroy(),delete this._audio[a])},b.prototype.getSound=function(a){return 0!=this._validate(a)?this._audio[a]:void 0},b.prototype._validate=function(a){return void 0===this._audio[a]?!1:!0},b.prototype.play=function(a){0!=this._validate(a)&&this._audio[a].play()},b.prototype.stop=function(a){0!=this._validate(a)&&this._audio[a].stop()},b.prototype.pause=function(a){0!=this._validate(a)&&this._audio[a].pause()},b.prototype.resume=function(a){0!=this._validate(a)&&this._audio[a].resume()},b.prototype.destroy=function(){a.prototype.destroy.call(this);for(var b in this._audio)this._audio[b].stop(),this._audio[b].destroy(),delete this._audio[b];delete this._audio},b}(a.Component);b.Sound=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(d,e){b.call(this,d,"ArcadePhysics"),this._callbackFunction=null,this._callbackContext=null,this.parent=d,this.box=e,this.transform=this.parent.transform,this.last=new a.Geom.Point(this.transform.worldX,this.transform.worldY),this.mass=1,this.elasticity=0,this.immovable=!1,this.moves=!0,this.touching=c.NONE,this.wasTouching=c.NONE,this.allowCollisions=c.ANY,this.velocity=new a.Geom.Point,this.acceleration=new a.Geom.Point,this.drag=new a.Geom.Point,this.maxVelocity=new a.Geom.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e4}return __extends(c,b),c.prototype.isTouching=function(a){return(this.touching&a)==a},c.prototype.solid=function(a){return void 0!==a&&(a?this.allowCollisions=c.ANY:this.allowCollisions=c.NONE),(this.allowCollisions&c.ANY)>c.NONE},c.prototype.setCallback=function(a,b){this._callbackFunction=a,this._callbackContext=b},c.prototype.rotateToVelocity=function(){var a=Math.atan2(this.velocity.y,this.velocity.x);return this.transform.rotation=a,a},c.separate=function(a,b){var c=this.separateX(a,b),d=this.separateY(a,b);return c||d},c.separateX=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldX-e.last.x,i=f.transform.worldX-f.last.x;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x-(h>0?h:0),e.last.y+e.box.hitboxOffset.y,l.width+(h>0?h:-h),l.height),o=new a.Geom.Rectangle(m.x-(i>0?i:0),f.last.y+f.box.hitboxOffset.y,m.width+(i>0?i:-i),m.height);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.x+l.width-m.x,!(g>p)&&e.allowCollisions&c.RIGHT&&f.allowCollisions&c.LEFT?(e.touching|=c.RIGHT,f.touching|=c.LEFT):g=0):(g=l.x-m.width-m.x,!(-g>p)&&e.allowCollisions&c.LEFT&&f.allowCollisions&c.RIGHT?(e.touching|=c.LEFT,f.touching|=c.RIGHT):g=0)}if(0!=g){var q=e.velocity.x,r=f.velocity.x;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.x=f.transform.x+g,f.velocity.x=q-r*f.elasticity):(e.transform.x=e.transform.x-g,e.velocity.x=r-q*e.elasticity);else{g*=.5,e.transform.x=e.transform.x-g,f.transform.x=f.transform.x+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.x=u+s*e.elasticity,f.velocity.x=u+t*f.elasticity}return!0}return!1},c.separateY=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldY-e.last.y,i=f.transform.worldY-f.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x,l.y-(h>0?h:0),l.width,l.height+j),o=new a.Geom.Rectangle(m.x,m.y-(i>0?i:0),m.width,m.height+k);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.y+l.height-m.y,!(g>p)&&e.allowCollisions&c.DOWN&&f.allowCollisions&c.UP?(e.touching|=c.DOWN,f.touching|=c.UP):g=0):(g=l.y-m.height-m.y,!(-g>p)&&e.allowCollisions&c.UP&&f.allowCollisions&c.DOWN?(e.touching|=c.UP,f.touching|=c.DOWN):g=0),0!=g){var q=e.velocity.y,r=f.velocity.y;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.y=f.transform.y+g,f.velocity.y=q-r*f.elasticity,b.active&&e.moves&&i>h&&(f.transform.x=f.transform.worldX+b.transform.worldX-e.last.x)):(e.transform.y=e.transform.y-g,e.velocity.y=r-q*e.elasticity,d.active&&f.moves&&h>i&&(e.transform.x=e.transform.worldX+d.transform.worldX-f.last.x));else{g*=.5,e.transform.y=e.transform.y-g,f.transform.y=f.transform.y+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.y=u+s*e.elasticity,f.velocity.y=u+t*f.elasticity}return!0}}return!1},c.separateTiles=function(a,b,c){if(0==a.components.hasComponent("ArcadePhysics"))return!1;if(a.components.getComponent("ArcadePhysics").immovable)return!1;for(var d=!1,e=!1,f=0;f0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=g.transform.worldX+e.x,r=new a.Geom.Rectangle(n.x-(h>0?h:0),f.last.y+f.box.hitboxOffset.y,n.width+(h>0?h:-h),n.height),s=new a.Geom.Rectangle(q-(i>0?i:0),g.last.y+e.y,d.tileWidth+(i>0?i:-i),d.tileHeight);if(r.x+r.width>s.x&&r.xs.y&&r.y-1i?(l=n.x+n.width-q,!(l>m)&&f.allowCollisions&c.RIGHT&&o[p[e.index]].allowCollisions&c.LEFT?f.touching|=c.RIGHT:l=0):(l=n.x-d.tileWidth-q,!(-l>m)&&f.allowCollisions&c.LEFT&&o[p[e.index]].allowCollisions&c.RIGHT?f.touching|=c.LEFT:l=0),0!=l)){var t=f.velocity.x,u=g.velocity.x;return f.transform.x=f.transform.x-l,f.velocity.x=u-t*f.elasticity,!0}return!1},c.separateTilesY=function(b,d,e){var f=b.components.getComponent("ArcadePhysics"),g=d.components.getComponent("ArcadePhysics"),h=f.transform.worldY-f.last.y,i=g.transform.worldY-g.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=d.transform.worldY+e.y,r=new a.Geom.Rectangle(n.x,n.y-(h>0?h:0),n.width,n.height+j),s=new a.Geom.Rectangle(g.transform.worldX+e.x,q-(i>0?i:0),d.tileWidth,d.tileHeight+k);if(r.x+r.width>s.x&&r.xs.y&&r.yi?(l=n.y+n.height-q,!(l>m)&&f.allowCollisions&c.DOWN&&o[p[e.index]].allowCollisions&c.UP?f.touching|=c.DOWN:l=0):(l=n.y-d.tileHeight-q,!(-l>m)&&f.allowCollisions&c.UP&&o[p[e.index]].allowCollisions&c.DOWN?f.touching|=c.UP:l=0),0!=l)){var t=f.velocity.y,u=g.velocity.y;return f.transform.y=f.transform.y-l,f.velocity.y=u-t*f.elasticity,!0}return!1},c.prototype.overlapsTiles=function(b,d,e){if(void 0===d&&(d=!1),void 0===e&&(e=a.Components.ArcadePhysics.ANY),this.parent.childType()!==a.TILE_LAYER)return!1;var f=this.parent.getOverlappingTiles(b,e);return f.length>0?(d&&c.separateTiles(b,this.parent,f),!0):!1},c.prototype.overlaps=function(a,b){if(void 0===b&&(b=!1),0!=a.components.hasComponent("Box")){var d=a.components.getComponent("Box"),e=d.worldHitbox.x+d.worldHitbox.width>this.box.worldHitbox.x&&d.worldHitbox.xthis.box.worldHitbox.y&&d.worldHitbox.y0?a-=d:0>a+d?a+=d:a=0),0!=a&&1e4!=e&&(a>e?a=e:-e>a&&(a=-e)),a},c.prototype.updateMotion=function(){var a,b;b=(c.computeVelocity(this.angularVelocity,this.angularAcceleration,this.angularDrag,this.maxAngular)-this.angularVelocity)/2,this.angularVelocity+=b,this.transform.rotation+=this.angularVelocity*c.updateInterval,this.angularVelocity+=b,b=(c.computeVelocity(this.velocity.x,this.acceleration.x,this.drag.x,this.maxVelocity.x)-this.velocity.x)/2,this.velocity.x+=b,a=this.velocity.x*c.updateInterval,this.velocity.x+=b,this.transform.x=this.transform.x+a,b=(c.computeVelocity(this.velocity.y,this.acceleration.y,this.drag.y,this.maxVelocity.y)-this.velocity.y)/2,this.velocity.y+=b,a=this.velocity.y*c.updateInterval,this.velocity.y+=b,this.transform.y=this.transform.y+a},c.prototype.update=function(){this.last.x=this.transform.worldX,this.last.y=this.transform.worldY,this.moves&&this.updateMotion(),this.wasTouching=this.touching,this.touching=c.NONE},c.prototype.destroy=function(){b.prototype.destroy.call(this),delete this.transform,delete this.owner,delete this._callbackContext,delete this._callbackFunction},c.prototype.objType=function(){return"ArcadePhysics"},c.collide=function(a,b,d){return void 0===d&&(d=!0),c.overlaps(a,b,d)},c.collideGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsObjectGroup(a,b,d)},c.collideGroupGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsGroupGroup(a,b,d)},c.overlaps=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlaps(b,c)},c.overlapsObjectGroup=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlapsGroup(b,c)},c.overlapsGroupGroup=function(b,d,e){void 0===e&&(e=!0);for(var f=!1,g=b.members,h=0;h=this._loadingList.length&&(this._queueLoading=!1,this.clearQueue(),this.onQueueComplete.dispatch()))},b.prototype._startLoadingQueue=function(){return this._loadingQueue.length<=0?(a.Log.log("Kiwi.Files.Loader: No queued files to load.","#loading"),!1):this._loadingQueue[0].loading?!1:(this._loadingQueue[0].onComplete.addOnce(this._queueFileComplete,this,1),this._loadingQueue[0].load(),!0)},b.prototype._queueFileComplete=function(b){var c=this._loadingQueue.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingQueue.","#loading","#error"):(this._loadingQueue.splice(c,1),void this._startLoadingQueue())},b.prototype._startLoadingParallel=function(a){a.loading||(a.onComplete.add(this._parallelFileComplete,this,1),a.load())},b.prototype._startLoadingAllParallel=function(){for(var a=this._loadingParallel.length;a--;)this._startLoadingParallel(this._loadingParallel[a])},b.prototype._parallelFileComplete=function(b){var c=this._loadingParallel.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingParallel.","#loading","#error"):void this._loadingParallel.splice(c,1)},Object.defineProperty(b.prototype,"bytesTotal",{get:function(){return this._bytesTotal},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bytesLoaded",{get:function(){return this._bytesLoaded},enumerable:!0,configurable:!0}),b.prototype.calculateQueuedSize=function(b,c){return void 0===c&&(c=null),this._queueLoading?void a.Log.warn("Kiwi.Files.Loader: Cannot calculate the size of the files in the filequeue whilst they are loading. "):(this.onSizeCallback=b,this.onSizeContext=c,this._currentFileIndex=0,this._bytesTotal=0,this._queueLoading=!0,void this._calculateNextFileSize())},b.prototype._calculateNextFileSize=function(){if(this._currentFileIndex>=this._loadingList.length)return this._queueLoading=!1,void this.onSizeCallback.call(this.onSizeContext,this._bytesTotal);var a=this._loadingList[this._currentFileIndex];if(a.detailsReceived)this._detailsReceived();else{var b=a.loadDetails(this._detailsReceived,this);b||this._detailsReceived()}},b.prototype._detailsReceived=function(){var a=this._loadingList[this._currentFileIndex];a.detailsReceived&&(this._bytesTotal+=a.size),this._currentFileIndex++,this._calculateNextFileSize()},b.prototype.addImage=function(b,c,d,e,f,g,h){void 0===h&&(h=!0);var i={type:a.Files.File.IMAGE,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var j=b;i.key=j.key,i.url=j.url,i.metadata={width:j.width,height:j.height,offsetX:j.offsetX,offsetY:j.offsetY},j.xhrLoading&&(i.xhrLoading=j.xhrLoading),j.state&&(i.state=j.state),j.tags&&(i.tags=j.tags)}else!h&&this.game.states.current&&(i.state=this.game.states.current),i.key=b,i.url=c,i.metadata={width:d,height:e,offsetX:f,offsetY:g};var k=new a.Files.TextureFile(this.game,i);return this.addFileToQueue(k),k},b.prototype.addSpriteSheet=function(b,c,d,e,f,g,h,i,j,k,l,m){void 0===m&&(m=!0);var n={type:a.Files.File.SPRITE_SHEET,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var o=b;n.key=o.key,n.url=o.url,n.metadata={frameWidth:o.frameWidth,frameHeight:o.frameHeight,numCells:o.numCells,rows:o.rows,cols:o.cols,sheetOffsetX:o.sheetOffsetX,sheetOffsetY:o.sheetOffsetY,cellOffsetX:o.cellOffsetX,cellOffsetY:o.cellOffsetY},o.xhrLoading&&(n.xhrLoading=o.xhrLoading),o.state&&(n.state=o.state),o.tags&&(n.tags=o.tags)}else!m&&this.game.states.current&&(n.state=this.game.states.current),n.key=b,n.url=c,n.metadata={frameWidth:d,frameHeight:e,numCells:f,rows:g,cols:h,sheetOffsetX:i,sheetOffsetY:j,cellOffsetX:k,cellOffsetY:l};var p=new a.Files.TextureFile(this.game,n);return this.addFileToQueue(p),p},b.prototype.addTextureAtlas=function(b,c,d,e,f){void 0===f&&(f=!0);var g={type:a.Files.File.TEXTURE_ATLAS,key:b,url:c,fileStore:this.game.fileStore,metadata:{jsonID:d}},h={type:a.Files.File.JSON,key:d,url:e,fileStore:this.game.fileStore,metadata:{imageID:b}};if(!f&&this.game.states.current&&(g.state=this.game.states.current,h.state=this.game.states.current),a.Utils.Common.isObject(b)){var i=b;g.key=i.textureAtlasKey,g.url=i.textureAtlasURL,h.key=i.jsonKey,h.url=i.jsonURL,g.metadata.jsonID=h.key,h.metadata.imageID=g.key,i.state&&(g.state=i.state,h.state=i.state),i.xhrLoading&&(g.xhrLoading=i.xhrLoading),i.tags&&(h.tags=i.tags,g.tags=i.tags)}var j=new a.Files.TextureFile(this.game,g),k=new a.Files.DataFile(this.game,h);return this.addFileToQueue(j),this.addFileToQueue(k),j},b.prototype.addAudio=function(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!0);var f={type:a.Files.File.AUDIO,key:null,url:null,state:null,fileStore:this.game.fileStore};a.Utils.Common.isObject(b)?(f=b,f.type=a.Files.File.AUDIO,f.fileStore=this.game.fileStore):(f.key=b,f.url=c,!d&&this.game.states.current&&(f.state=this.game.states.current));var g,h,i=0;for(g=a.Utils.Common.isString(f.url)?[f.url]:f.url;i-1?(this.name=a.substr(a.lastIndexOf("/")+1),this.path=a.substr(0,a.lastIndexOf("/")+1)):(this.path="",this.name=a),this.extension=a.substr(a.lastIndexOf(".")+1).toLowerCase()},b.prototype.objType=function(){return"File"},Object.defineProperty(b.prototype,"loadInParallel",{get:function(){return this._loadInParallel},enumerable:!0,configurable:!0}),b.prototype.load=function(b,c,d,e,f){return this.loading?void a.Log.error("Kiwi.Files.File: File loading is in progress. Cannot be told to load again.","#loading"):(a.Log.log("Kiwi.Files.File: Starting to load '"+this.name+"'","#file","#loading"),b&&this.onComplete.add(b),c&&this.onProgress.add(c),d&&(this.fileStore=d),"undefined"!=typeof e&&(this.maxLoadAttempts=e),"undefined"!=typeof f&&(this.timeOutDelay=f),this._start(),void this._load())},b.prototype._load=function(){this.attemptCounter++,this.xhrLoader("GET","text")},b.prototype.loadProgress=function(){this.onProgress.dispatch(this)},b.prototype.loadSuccess=function(){this.complete||(this.success=!0,this.hasError=!1,this._stop(),this.fileStore&&this.fileStore.addFile(this.key,this),this.onComplete.dispatch(this))},b.prototype.loadError=function(b){this.attemptCounter>=this.maxLoadAttempts?(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'. Trying Again","#loading"),this.hasError=!0,this.success=!1,this.error=b,this._stop(),this.onComplete.dispatch(this)):(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'","#loading"),this._load())},b.prototype.xhrLoader=function(a,b,c){ +var d=this;void 0===a&&(a="GET"),void 0===b&&(b="text"),void 0===c&&(c=this.timeOutDelay),this._xhr=new XMLHttpRequest,this._xhr.open(a,this.URL,!0),null!==c&&(this._xhr.timeout=c),this._xhr.responseType=b,this._xhr.onload=function(a){return d.xhrOnLoad(a)},this._xhr.onerror=function(a){return d.loadError(a)},this._xhr.onprogress=function(a){return d.xhrOnProgress(a)};var e=this;this._xhr.onreadystatechange=function(){e.readyState=e._xhr.readyState},this._xhr.onloadstart=function(a){e.timeStarted=a.timeStamp,e.lastProgress=a.timeStamp},this._xhr.ontimeout=function(a){e.hasTimedOut=!0},this._xhr.onloadend=function(a){e.xhrOnLoad(a)},this._xhr.send()},b.prototype.xhrOnProgress=function(a){this.bytesLoaded=parseInt(a.loaded),this.bytesTotal=parseInt(a.total),this.percentLoaded=Math.round(this.bytesLoaded/this.bytesTotal*100),this.onProgress.dispatch(this)},b.prototype.xhrOnLoad=function(a){this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.status&&200===this.status||!this.status&&this._xhr.response?(this._getXhrHeaderInfo(),this.buffer=this._xhr.response,this.processXhr(this._xhr.response)):this.loadError(a)},b.prototype.processXhr=function(a){this.data=a,this.loadSuccess()},b.prototype._start=function(){this.attemptCounter=0,this.loading=!0,this.timeStarted=Date.now(),this.percentLoaded=0},b.prototype._stop=function(){this.loading=!1,this.complete=!0,this.percentLoaded=100,this.timeFinished=Date.now(),this.duration=this.timeFinished-this.timeStarted},b.prototype.loadDetails=function(b,c){return void 0===b&&(b=null),void 0===c&&(c=null),this.loading?(a.Log.error("Kiwi.Files.File: Cannot get the file details whilst the file is already loading"),!1):(b&&(this.headCompleteCallback=b),c&&(this.headCompleteContext=c),this.xhrHeadRequest(),!0)},b.prototype._getXhrHeaderInfo=function(){this._xhr&&(this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.type=this._xhr.getResponseHeader("Content-Type"),this.size=parseInt(this._xhr.getResponseHeader("Content-Length")),this.lastModified=this._xhr.getResponseHeader("Last-Modified"),this.ETag=this._xhr.getResponseHeader("ETag"),this.detailsReceived=!0)},b.prototype.xhrHeadRequest=function(){var a=this;this._xhr=new XMLHttpRequest,this._xhr.open("HEAD",this.fileURL,!0),null!==this.timeOutDelay&&(this._xhr.timeout=this.timeOutDelay),this._xhr.onload=function(b){return a.xhrHeadOnLoad(b)},this._xhr.onerror=function(b){return a.xhrHeadOnError(b)},this._xhr.send()},b.prototype.xhrHeadOnError=function(a){this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!1)},b.prototype.xhrHeadOnLoad=function(a){200===this._xhr.status?(this._getXhrHeaderInfo(),this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!0)):this.xhrHeadOnError(null)},b.prototype.addTag=function(a){-1==this._tags.indexOf(a)&&this._tags.push(a)},b.prototype.removeTag=function(a){var b=this._tags.indexOf(a);-1!=b&&this._tags.splice(b,1)},b.prototype.hasTag=function(a){return-1==this._tags.indexOf(a)?!1:!0},Object.defineProperty(b.prototype,"isTexture",{get:function(){return a.Files.TextureFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isAudio",{get:function(){return a.Files.AudioFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isData",{get:function(){return a.Files.DataFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this.fileStore&&this.fileStore.removeFile(this.key),this.onComplete.dispose(),this.onProgress.dispose(),delete this.fileStore,delete this._xhr,delete this.data,delete this.buffer,delete this.game,delete this.error,delete this.headCompleteCallback,delete this.headCompleteContext,delete this.onComplete,delete this.onProgress,delete this.ownerState},Object.defineProperty(b.prototype,"fileName",{get:function(){return this.name},set:function(a){this.name=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"filePath",{get:function(){return this.path},set:function(a){this.path=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileExtension",{get:function(){return this.extension},set:function(a){this.extension=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileURL",{get:function(){return this.URL},set:function(a){this.URL=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileType",{get:function(){return this.type},set:function(a){this.type=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileSize",{get:function(){return this.size},set:function(a){this.size=a},enumerable:!0,configurable:!0}),b.prototype.getFileDetails=function(a,b,c){void 0===a&&(a=null),void 0===c&&(c=null),c&&(this.timeOutDelay=c),this.loadDetails(a,null)},b.TIMEOUT_DELAY=null,b.MAX_LOAD_ATTEMPTS=2,b.IMAGE=0,b.SPRITE_SHEET=1,b.TEXTURE_ATLAS=2,b.AUDIO=3,b.JSON=4,b.XML=5,b.BINARY_DATA=6,b.TEXT_DATA=7,b.UNKNOWN=8,b}();b.File=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._size=0,this._game=a,this._files={}}return a.prototype.objType=function(){return"FileStore"},a.prototype.boot=function(){},a.prototype.getFile=function(a){return this._files[a]},a.prototype.getFilesByTag=function(a){var b={};for(var c in this._files)this._files[c].hasTag(a)&&(b[c]=this._files[c]);return b},a.prototype.removeFilesByTag=function(a){var b=0;for(var c in this._files)this._files[c].hasTag(a)&&(this.removeFile(c),b++);return b},Object.defineProperty(a.prototype,"keys",{get:function(){var a=new Array;for(var b in this._files)a.push(b);return a},enumerable:!0,configurable:!0}),a.prototype.size=function(){return this._size},a.prototype.addFile=function(a,b){return this._files[a]?!1:(this._files[a]=b,this._size++,!0)},a.prototype.exists=function(a){return this._files[a]?!0:!1},a.prototype.removeStateFiles=function(a){for(var b in this._files)this._files[b].ownerState===a&&this.removeFile(b)},a.prototype.removeGlobalFiles=function(){for(var a in this._files)this._files[a].ownerState||this.removeFile(a)},a.prototype.removeFile=function(a,b){void 0===b&&(b=!1);var c=this._files[a];return c?(this._files[a]=null,delete this._files[a],b&&c.destroy(),!0):!1},a.prototype.removeAllFiles=function(){for(var a in this._files)this.removeFile(a)},a}();a.FileStore=b}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){this.isReady=!1,this.container=null,this.input=null}return b.prototype.objType=function(){return"Bootstrap"},b.prototype.boot=function(a,b,c){var d=this;void 0===b&&(b=null),void 0===c&&(c=!0),this._callback=b,this._domParent=a,this._createContainer=c,"complete"===document.readyState||"interactive"===document.readyState?this.ready():(document.addEventListener("DOMContentLoaded",function(){return d.ready()},!1),window.addEventListener("load",function(){return d.ready()},!1))},b.prototype.ready=function(){var b=this;this.isReady!==!0&&(document.body?(this.isReady=!0,this._createContainer===!0&&(""===this._domParent?(a.Log.log(" Kiwi.Game: No DOM parent specified. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer("KiwiGame"+Date.now().toString()),document.body.appendChild(this.container)):document.querySelector(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.querySelector(this._domParent),this._setupContainer()):document.getElementById(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.getElementById(this._domParent),this._setupContainer()):(a.Log.log(" Kiwi.Game: The element '"+this._domParent+"' could not be found. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer(this._domParent),document.body.appendChild(this.container))),null!==this._callback&&this._callback()):window.setTimeout(function(){return b.ready()},13))},b.prototype._setupContainer=function(b){void 0===b&&(b=""),b&&(this.container.id=b),this.container.style.width=a.Stage.DEFAULT_WIDTH+"px",this.container.style.height=a.Stage.DEFAULT_HEIGHT+"px",this.container.style.position="relative",this.container.style.overflow="hidden"},b}();b.Bootstrap=c}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.blob=!1,this.touch=!1,this.pointerEnabled=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.ieMobile=!1,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.mp3=!1,this.wav=!1,this.m4a=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkDevice(),this._checkFeatures(),this._checkOS()}return a.prototype.objType=function(){return"Device"},a.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 Phone/.test(a)?this.windowsPhone=!0:/Windows/.test(a)&&(this.windows=!0)},a.prototype._checkFeatures=function(){"undefined"!=typeof window.Blob&&(this.blob=!0),this.canvas=!!window.CanvasRenderingContext2D,this.webGL=!!window.WebGLRenderingContext;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.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0)&&(this.touch=!0),(window.navigator.pointerEnabled||window.navigator.msPointerEnabled)&&(this.pointerEnabled=!0)},a.prototype._checkBrowser=function(){var a=navigator.userAgent;navigator.appName;/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),/IEMobile/.test(a)&&(this.ieMobile=!0)):/Trident/.test(a)?(this.ie=!0,/rv:(\d+\.\d+)\)/.test(a),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)},a.prototype._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/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))}catch(c){}},a.prototype._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")},a.prototype.getAll=function(){var a="";return a=a.concat("Device\n"),a=a.concat("iPhone : "+this.iPhone+"\n"),a=a.concat("iPhone4 : "+this.iPhone4+"\n"),a=a.concat("iPad : "+this.iPad+"\n"),a=a.concat("\n"),a=a.concat("Operating System\n"),a=a.concat("iOS: "+this.iOS+"\n"),a=a.concat("Android: "+this.android+"\n"),a=a.concat("ChromeOS: "+this.chromeOS+"\n"),a=a.concat("Linux: "+this.linux+"\n"),a=a.concat("MacOS: "+this.macOS+"\n"),a=a.concat("Windows: "+this.windows+"\n"),a=a.concat("\n"),a=a.concat("Browser\n"),a=a.concat("Arora: "+this.arora+"\n"),a=a.concat("Chrome: "+this.chrome+"\n"),a=a.concat("Epiphany: "+this.epiphany+"\n"),a=a.concat("Firefox: "+this.firefox+"\n"),a=a.concat("Internet Explorer: "+this.ie+" ("+this.ieVersion+")\n"),a=a.concat("Mobile Safari: "+this.mobileSafari+"\n"),a=a.concat("Midori: "+this.midori+"\n"),a=a.concat("Opera: "+this.opera+"\n"),a=a.concat("Safari: "+this.safari+"\n"),a=a.concat("\n"),a=a.concat("Features\n"),a=a.concat("Blob: "+this.blob+"\n"),a=a.concat("Canvas: "+this.canvas+"\n"),a=a.concat("File: "+this.file+"\n"),a=a.concat("FileSystem: "+this.fileSystem+"\n"),a=a.concat("LocalStorage: "+this.localStorage+"\n"),a=a.concat("WebGL: "+this.webGL+"\n"),a=a.concat("Worker: "+this.worker+"\n"),a=a.concat("Touch: "+this.touch+"\n"),a=a.concat("\n"),a=a.concat("Audio\n"),a=a.concat("Audio Data: "+this.canvas+"\n"),a=a.concat("Web Audio: "+this.canvas+"\n"),a=a.concat("Can play OGG: "+this.canvas+"\n"),a=a.concat("Can play MP3: "+this.canvas+"\n"),a=a.concat("Can play M4A: "+this.canvas+"\n"),a=a.concat("Can play WAV: "+this.canvas+"\n")},a}();a.Device=b}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e){this.dirty=!1,this.cellIndex=0,this.name=a,this.cells=c||new Array,this.sequences=e||new Array,this.image=d,this._type=b}return b.prototype.objType=function(){return"TextureAtlas"},Object.defineProperty(b.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),b.prototype.createGLTextureWrapper=function(b,c){this.glTextureWrapper=new a.Renderers.GLTextureWrapper(b,this),c.registerTextureWrapper(b,this.glTextureWrapper)},b.prototype.enableGL=function(a,b,c){b.updateTextureSize(a,new Float32Array([this.image.width,this.image.height])),c.useTexture(a,this.glTextureWrapper),this.dirty&&this.refreshTextureGL(a)},b.prototype.refreshTextureGL=function(a){this.glTextureWrapper&&this.glTextureWrapper.refreshTexture(a),this.dirty=!1},b.prototype.readJSON=function(b){var c=JSON.parse(b);void 0!==c.name&&(this.name=c.name);for(var d=0;d=this.numCells||(b.push({x:d,y:e,w:this.cellWidth,h:this.cellHeight,hitboxes:[{x:0,y:0,w:this.cellWidth,h:this.cellHeight}]}),c.push(f++),d+=this.cellOffsetX+this.cellWidth);d=this.sheetOffsetX,e+=this.cellOffsetY+this.cellHeight}return this.sequences=new Array,this.sequences.push(new a.Animations.Sequence("default",c)),b},c}(b.TextureAtlas);b.SpriteSheet=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h){this.width=e||d.width,this.height=f||d.height,this.offsetX=g||0,this.offsetY=h||0,b.call(this,c,a.Textures.TextureAtlas.SINGLE_IMAGE,this.generateAtlasCells(),d)}return __extends(c,b),c.prototype.objType=function(){return"SingleImage"},c.prototype.generateAtlasCells=function(){return[{x:this.offsetX,y:this.offsetY,w:this.width,h:this.height,hitboxes:[{x:0,y:0,w:this.width,h:this.height}]}]},c}(b.TextureAtlas);b.SingleImage=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Back"},a.In=function(a){var b=1.70158;return a*a*((b+1)*a-b)},a.Out=function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},a.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)},a}();a.Back=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"Bounce"},b.In=function(b){return 1-a.Animations.Tweens.Easing.Bounce.Out(1-b)},b.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},b.InOut=function(b){return.5>b?.5*a.Animations.Tweens.Easing.Bounce.In(2*b):.5*a.Animations.Tweens.Easing.Bounce.Out(2*b-1)+.5},b}();b.Bounce=c}(c=b.Easing||(b.Easing={}))}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Circular"},a.In=function(a){return 1-Math.sqrt(1-a*a)},a.Out=function(a){return Math.sqrt(1- --a*a)},a.InOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},a}();a.Circular=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Cubic"},a.In=function(a){return a*a*a},a.Out=function(a){return--a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},a}();a.Cubic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Elastic"},a.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)))},a.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)},a.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)):c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)*.5+1)},a}();a.Elastic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Exponential"},a.In=function(a){return 0===a?0:Math.pow(1024,a-1)},a.Out=function(a){return 1===a?1:1-Math.pow(2,-10*a)},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)},a}();a.Exponential=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Linear"},a.None=function(a){return a},a}();a.Linear=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quadratic"},a.In=function(a){return a*a},a.Out=function(a){return a*(2-a)},a.InOut=function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)},a}();a.Quadratic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quartic"},a.In=function(a){return a*a*a*a},a.Out=function(a){return 1- --a*a*a*a},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)},a}();a.Quartic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quintic"},a.In=function(a){return a*a*a*a*a},a.Out=function(a){return--a*a*a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)},a}();a.Quintic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Sinusoidal"},a.In=function(a){return 1-Math.cos(a*Math.PI/2)},a.Out=function(a){return Math.sin(a*Math.PI/2)},a.InOut=function(a){return.5*(1-Math.cos(Math.PI*a))},a}();a.Sinusoidal=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(a,b){this._game=a,this._tweens=[],this.clock=b||this._game.time.clock}return b.prototype.objType=function(){return"TweenManager"},b.prototype.getAll=function(){return this._tweens},b.prototype.removeAll=function(){this._tweens.length=0},b.prototype.create=function(b){var c=new a.Animations.Tween(b,this._game);return this.validateClock(),c.manager=this,c},b.prototype.add=function(a){return a.setParent(this._game),a.manager=this,this.validateClock(),this._tweens.push(a),a},b.prototype.remove=function(a){var b=this._tweens.indexOf(a);return-1!==b&&this._tweens.splice(b,1),a},b.prototype.update=function(){var a=0,b=this._tweens.length;if(0===this._tweens.length)return!1;for(;b>a;)this._tweens[a].update(1e3*this.clock.elapsed())?a++:(this._tweens.splice(a,1),b--);return!0},b.prototype.validateClock=function(){this.clock||(this.clock=this._game.time.clock,this.clock||a.Log.error("Tween manager could not find valid clock!"))},b}();b.TweenManager=c}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){void 0===c&&(c=null),this._game=null,this._manager=null,this._object=null,this._valuesStart={},this._valuesEnd={},this._duration=1e3,this._delayTime=0,this._startTime=null,this._easingFunction=a.Animations.Tweens.Easing.Linear.None,this._interpolationFunction=a.Utils.GameMath.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartContext=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onUpdateContext=null,this._onCompleteCallback=null,this._onCompleteCalled=!1,this._onCompleteContext=null,this.isRunning=!1,this._object=b,null!==c&&(this._game=c,this._manager=this._game.tweens),this.isRunning=!1}return b.prototype.objType=function(){return"Tween"},Object.defineProperty(b.prototype,"manager",{get:function(){return this._manager},set:function(a){this._manager=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"object",{get:function(){return this._object},set:function(a){var b,c={};this._object=a;for(b in this._valuesEnd)a[b]&&(c[b]=this._valuesEnd[b]);this._valuesEnd=c},enumerable:!0,configurable:!0}),b.prototype.to=function(a,b,c,d){return void 0===b&&(b=1e3),void 0===c&&(c=null),void 0===d&&(d=!1),this._duration=b,this._valuesEnd=a,null!==c&&(this._easingFunction=c),d===!0?this.start():this},b.prototype.start=function(){var a;if(null!==this._game&&null!==this._object){this.isRunning=!0,this._manager.add(this),this._onStartCallbackFired=!1,this._onCompleteCalled=!1,this._startTime=1e3*this._manager.clock.elapsed()+this._delayTime;for(var a in this._valuesEnd)if(null!==this._object[a]&&a in this._object){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}"function"==typeof this._object[a]?this._valuesStart[a]=this._object[a]():this._valuesStart[a]=this._object[a]}return this}},b.prototype.stop=function(){return null!==this._manager&&this._manager.remove(this),this.isRunning=!1,this},b.prototype.setParent=function(a){this._game=a,this._manager=this._game.tweens},b.prototype.delay=function(a){return this._delayTime=a,this},b.prototype.easing=function(a){return this._easingFunction=a,this},b.prototype.interpolation=function(a){return this._interpolationFunction=a,this},b.prototype.chain=function(a){return this._chainedTweens.push(a),this},b.prototype.onStart=function(a,b){return this._onStartCallback=a,this._onStartContext=b,this},b.prototype.onUpdate=function(a,b){return this._onUpdateCallback=a,this._onUpdateContext=b,this},b.prototype.onComplete=function(a,b){return this._onCompleteCallback=a,this._onCompleteContext=b,this},b.prototype.update=function(a){if(a1?1:0>b?0:b;var c=this._easingFunction(b);for(var d in this._valuesStart){var e=this._valuesStart[d],f=this._valuesEnd[d];f instanceof Array?this._object[d]=this._interpolationFunction(f,c):"function"==typeof this._object[d]?this._object[d](e+(f-e)*c):this._object[d]=e+(f-e)*c}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateContext,this._object,c),1===b){this.isRunning=!1,null!==this._onCompleteCallback&&this._onCompleteCalled===!1&&(this._onCompleteCalled=!0,this._onCompleteCallback.call(this._onCompleteContext,this._object));for(var g=0;gg){var i=e*g;f.x=(d-i)/2,d=i}else{var j=d/g;f.y=(e-j)/2,e=j}break;case a.Stage.SCALE_STRETCH:break;case a.Stage.SCALE_NONE:d=this._game.stage.width,e=this._game.stage.height}b.viewport(f.x,f.y,d,e)},c.prototype.initState=function(a){this._textureManager.clearTextures(this._game.stage.gl),this._textureManager.uploadTextureLibrary(this._game.stage.gl,a.textureLibrary)},c.prototype.endState=function(b){this._textureManager.clearTextures(this._game.stage.gl),a.Log.log("Ending WebGL on State","#renderer","#webgl")},c.prototype.render=function(b){var c=this._game.stage.gl,d=this._game.stage.normalizedColor;if(c.clearColor(d.r*d.a,d.g*d.a,d.b*d.a,d.a),c.clear(c.COLOR_BUFFER_BIT),this._currentRenderer=null,0!=this._game.states.current.members.length){this.numDrawCalls=0,this._textureManager.numTextureWrites=0,this._entityCount=0;var e=b.transform.getConcatenatedMatrix(),f=b.transform;this._camMatrixOffset.identity(),this._camMatrixOffset.translate(-f.anchorPointX,-f.anchorPointY),this._camMatrixOffset.prependMatrix(e),this.camMatrix[0]=this._camMatrixOffset.a,this.camMatrix[1]=this._camMatrixOffset.b,this.camMatrix[3]=this._camMatrixOffset.c,this.camMatrix[4]=this._camMatrixOffset.d,this.camMatrix[6]=this._camMatrixOffset.tx,this.camMatrix[7]=this._camMatrixOffset.ty,this._game.deviceTargetOption==a.TARGET_COCOON&&this._switchBlendMode(c,this._currentBlendMode),this.collateRenderSequence(),this.collateBatches(),this.renderBatches(c,b)}},c.prototype.collateRenderSequence=function(){this._sequence=[];var a=this._game.states.current;this.collateChild(a)},c.prototype.collateChild=function(b){if(b.visible)if(b.childType()===a.GROUP)for(var c=0;c=b)return!0;return!1},b.DEFAULT_MAX_TEX_MEM_MB=1024,b}();b.GLTextureManager=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this._created=!1,this._uploaded=!1,this.items=d||a.squareVertices,this.itemSize=c||2,this.numItems=this.items.length/this.itemSize,this.createBuffer(b),e&&this.uploadBuffer(b,this.items)}return Object.defineProperty(a.prototype,"created",{get:function(){return this._created},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"uploaded",{get:function(){return this._uploaded},enumerable:!0,configurable:!0}),a.prototype.clear=function(){this.items=new Array},a.prototype.createBuffer=function(a){return this.buffer=a.createBuffer(),this._created=!0,!0},a.prototype.uploadBuffer=function(a,b){this.items=b,this.numItems=this.items.length/this.itemSize;var c=new Float32Array(this.items);return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,c,a.DYNAMIC_DRAW),this._uploaded=!0,!0},a.prototype.deleteBuffer=function(a){return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.deleteBuffer(this.buffer),this.uploaded=!1,this.created=!1,!0},a.squareVertices=[0,0,100,0,100,100,0,100],a.squareUVs=[0,0,.1,0,.1,.1,0,.1],a.squareCols=[1,1,1,1],a}();a.GLArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){this.gl=a,this.dirty=!0,this._srcRGB=a.SRC_ALPHA,this._dstRGB=a.ONE_MINUS_SRC_ALPHA,this._srcAlpha=a.ONE,this._dstAlpha=a.ONE,this._modeRGB=a.FUNC_ADD,this._modeAlpha=a.FUNC_ADD,"undefined"==typeof b&&(b=null),b&&this.readConfig(b)}return a.prototype.readConfig=function(a){void 0!==a.mode?this.setMode(a.mode):(a.srcRGB=this.makeConstant(a.srcRGB),"undefined"!=typeof a.srcRGB&&(this._srcRGB=a.srcRGB),a.dstRGB=this.makeConstant(a.dstRGB),"undefined"!=typeof a.dstRGB&&(this._dstRGB=a.dstRGB),a.srcAlpha=this.makeConstant(a.srcAlpha),"undefined"!=typeof a.srcAlpha&&(this._srcAlpha=a.srcAlpha),a.dstAlpha=this.makeConstant(a.dstAlpha),"undefined"!=typeof a.dstAlpha&&(this._dstAlpha=a.dstAlpha),a.modeRGB=this.makeConstant(a.modeRGB),"undefined"!=typeof a.modeRGB&&(this._modeRGB=a.modeRGB),a.modeAlpha=this.makeConstant(a.modeAlpha),"undefined"!=typeof a.modeAlpha&&(this._modeAlpha=a.modeAlpha)),this.dirty=!0},a.prototype.makeConstant=function(a){if("number"==typeof a)return a;switch("string"==typeof a&&(a=a.toUpperCase()),a){case"ZERO":a=this.gl.ZERO;break;case"ONE":a=this.gl.ONE;break;case"SRC_COLOR":case"SRC_COLOUR":a=this.gl.SRC_COLOR;break;case"ONE_MINUS_SRC_COLOR":case"ONE_MINUS_SRC_COLOUR":a=this.gl.ONE_MINUS_SRC_COLOR;break;case"DST_COLOR":case"DST_COLOUR":a=this.gl.DST_COLOR;break;case"ONE_MINUS_DST_COLOR":case"ONE_MINUS_DST_COLOUR":a=this.gl.ONE_MINUS_DST_COLOR;break;case"SRC_ALPHA":a=this.gl.SRC_ALPHA;break;case"ONE_MINUS_SRC_ALPHA":a=this.gl.ONE_MINUS_SRC_ALPHA;break;case"DST_ALPHA":a=this.gl.DST_ALPHA;break;case"ONE_MINUS_DST_ALPHA":a=this.gl.ONE_MINUS_DST_ALPHA;break;case"SRC_ALPHA_SATURATE":a=this.gl.SRC_ALPHA_SATURATE;break;case"CONSTANT_COLOR":case"CONSTANT_COLOUR":a=this.gl.CONSTANT_COLOR;break;case"ONE_MINUS_CONSTANT_COLOR":case"ONE_MINUS_CONSTANT_COLOUR":a=this.gl.ONE_MINUS_CONSTANT_COLOR;break;case"CONSTANT_ALPHA":a=this.gl.CONSTANT_ALPHA;break;case"ONE_MINUS_CONSTANT_ALPHA":a=this.gl.ONE_MINUS_CONSTANT_ALPHA;break;case"FUNC_ADD":a=this.gl.FUNC_ADD;break;case"FUNC_SUBTRACT":a=this.gl.FUNC_SUBTRACT;break;case"FUNC_REVERSE_SUBTRACT":a=this.gl.FUNC_REVERSE_SUBTRACT;break;default:a=void 0}return a},a.prototype.setMode=function(a){switch(a=a.toUpperCase()){case"ADDITIVE":case"ADD":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"SUBTRACT":case"SUBTRACTIVE":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_ADD;break;case"ERASE":case"ERASER":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_REVERSE_SUBTRACT;break;case"BLACK":case"BLACKEN":this._srcRGB=this.gl.ZERO,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"NORMAL":default:this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD}this.dirty=!0},a.prototype.isIdentical=function(a){return this==a?!0:this._srcRGB==a._srcRGB&&this._dstRGB==a._dstRGB&&this._srcAlpha==a._srcAlpha&&this._dstAlpha==a._dstAlpha&&this._modeRGB==a._modeRGB&&this._modeAlpha==a._modeAlpha?!0:!1},a.prototype.apply=function(a){a.blendEquationSeparate(this._modeRGB,this._modeAlpha),a.blendFuncSeparate(this._srcRGB,this._dstRGB,this._srcAlpha,this._dstAlpha),this.dirty=!1},a}();a.GLBlendMode=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this.indices=d||a.square,this.itemSize=c||1,this.numItems=this.indices.length/this.itemSize,e&&(this.buffer=this.init(b))}return a.prototype.clear=function(){this.indices=new Array},a.prototype.init=function(a){var b=a.createBuffer();return a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,b),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),b},a.prototype.refresh=function(a,b){return this.numItems=this.indices.length/this.itemSize,a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),this.buffer},a.square=[0,1,2,0,2,3],a}();a.GLElementArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=!1),this.loaded=!1,this._isBatchRenderer=!1,this.shaderManager=c,this._isBatchRenderer=d,this.loaded=!0,this.blendMode=new a.Renderers.GLBlendMode(b,{mode:"NORMAL"})}return b.prototype.enable=function(a,b){void 0===b&&(b=null)},b.prototype.disable=function(a){},b.prototype.clear=function(a,b){},b.prototype.draw=function(a){},b.prototype.updateStageResolution=function(a,b){},b.prototype.updateTextureSize=function(a,b){},Object.defineProperty(b.prototype,"isBatchRenderer",{get:function(){return this._isBatchRenderer},enumerable:!0,configurable:!0}),b.RENDERER_ID="Renderer",b}();b.Renderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(c){function d(d,e,f){void 0===f&&(f=null),c.call(this,d,e,!0),this._shaderPairName="TextureAtlasShader",this._maxItems=1e3,this._pt1=new a.Geom.Point(0,0),this._pt2=new a.Geom.Point(0,0),this._pt3=new a.Geom.Point(0,0),this._pt4=new a.Geom.Point(0,0);var g=5;this._vertexBuffer=new b.GLArrayBuffer(d,g);var h=6;this._indexBuffer=new b.GLElementArrayBuffer(d,1,this._generateIndices(this._maxItems*h)),this.shaderPair=this.shaderManager.requestShader(d,this._shaderPairName)}return __extends(d,c),d.prototype.enable=function(a,b){void 0===b&&(b=null),this.shaderPair=this.shaderManager.requestShader(a,this._shaderPairName,!0),a.uniform1i(this.shaderPair.uniforms.uSampler.location,0),a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b.stageResolution),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.disable=function(a){a.disableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.disableVertexAttribArray(this.shaderPair.attributes.aAlpha)},d.prototype.clear=function(a,b){this._vertexBuffer.clear(),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.draw=function(a){this._vertexBuffer.uploadBuffer(a,this._vertexBuffer.items),a.enableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.vertexAttribPointer(this.shaderPair.attributes.aXYUV,4,a.FLOAT,!1,20,0),a.enableVertexAttribArray(this.shaderPair.attributes.aAlpha),a.vertexAttribPointer(this.shaderPair.attributes.aAlpha,1,a.FLOAT,!1,20,16),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indexBuffer.buffer),a.drawElements(a.TRIANGLES,this._vertexBuffer.items.length/20*6,a.UNSIGNED_SHORT,0)},d.prototype._generateIndices=function(a){for(var b=new Array,c=0;a>c;c++)b.push(4*c+0,4*c+1,4*c+2,4*c+0,4*c+2,4*c+3);return b},d.prototype.updateStageResolution=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b)},d.prototype.updateTextureSize=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uTextureSize.location,b)},d.prototype.setShaderPair=function(a){"string"==typeof a&&(this._shaderPairName=a)},d.prototype.addToBatch=function(a,b,c){if(!(b.alpha<=0)){var d=b.transform,e=d.getConcatenatedMatrix(),f=b.atlas.cells[b.cellIndex];this._pt1.setTo(0-d.rotPointX,0-d.rotPointY),this._pt2.setTo(f.w-d.rotPointX,0-d.rotPointY),this._pt3.setTo(f.w-d.rotPointX,f.h-d.rotPointY),this._pt4.setTo(0-d.rotPointX,f.h-d.rotPointY),e.transformPoint(this._pt1),e.transformPoint(this._pt2),e.transformPoint(this._pt3),e.transformPoint(this._pt4),this._vertexBuffer.items.push(this._pt1.x,this._pt1.y,f.x,f.y,b.alpha,this._pt2.x,this._pt2.y,f.x+f.w,f.y,b.alpha,this._pt3.x,this._pt3.y,f.x+f.w,f.y+f.h,b.alpha,this._pt4.x,this._pt4.y,f.x,f.y+f.h,b.alpha)}},d.prototype.concatBatch=function(a){this._vertexBuffer.items=this._vertexBuffer.items.concat(a)},d.RENDERER_ID="TextureAtlasRenderer",d}(b.Renderer);b.TextureAtlasRenderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.loaded=!1}return a.prototype.init=function(a){this.vertShader=this.compile(a,this.vertSource.join("\n"),a.VERTEX_SHADER),this.fragShader=this.compile(a,this.fragSource.join("\n"),a.FRAGMENT_SHADER),this.shaderProgram=this.attach(a,this.vertShader,this.fragShader),this.loaded=!0},a.prototype.attach=function(a,b,c){var d=a.createProgram();return a.attachShader(d,c),a.attachShader(d,b),a.linkProgram(d),d},a.prototype.compile=function(a,b,c){var d=a.createShader(c);return a.shaderSource(d,b),a.compileShader(d),a.getShaderParameter(d,a.COMPILE_STATUS)?d:null},a.prototype.setParam=function(a,b){this.uniforms[a].value=b,this.uniforms[a].dirty=!0},a.prototype.applyUniforms=function(a){for(var b in this.uniforms)this.applyUniform(a,b)},a.prototype.applyUniform=function(a,b){var c=this.uniforms[b];this.uniforms[b].dirty&&(a["uniform"+c.type](c.location,c.value),this.uniforms[b].dirty=!1)},a.prototype.initUniforms=function(a){for(var b in this.uniforms){var c=this.uniforms[b];c.location=a.getUniformLocation(this.shaderProgram,b),c.dirty=!0,c.value=null}},a.RENDERER_ID="ShaderPair",a}();a.ShaderPair=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.attributes={aXYUV:null,aAlpha:null},this.uniforms={uCamMatrix:{type:"mat3"},uResolution:{type:"2fv"},uTextureSize:{type:"2fv"},uSampler:{type:"1i"}},this.fragSource=["precision mediump float;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor.a *= vAlpha;","}"],this.vertSource=["attribute vec4 aXYUV;","attribute float aAlpha;","uniform mat3 uCamMatrix;","uniform vec2 uResolution;","uniform vec2 uTextureSize;","varying vec2 vTextureCoord;","varying float vAlpha;","void main(void) {"," vec2 pos = (uCamMatrix * vec3(aXYUV.xy,1)).xy; "," gl_Position = vec4((pos / uResolution * 2.0 - 1.0) * vec2(1, -1), 0, 1);"," vTextureCoord = aXYUV.zw / uTextureSize;"," vAlpha = aAlpha;","}"]}return __extends(b,a),b.prototype.init=function(b){a.prototype.init.call(this,b),this.attributes.aXYUV=b.getAttribLocation(this.shaderProgram,"aXYUV"),this.attributes.aAlpha=b.getAttribLocation(this.shaderProgram,"aAlpha"),this.initUniforms(b)},b}(a.ShaderPair);a.TextureAtlasShader=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d){this._frameIndex=0,this._startTime=null,this._reverse=!1,this._isPlaying=!1,this._onStop=null,this._onPlay=null,this._onUpdate=null,this._onLoop=null,this._onComplete=null,this.name=a,this._sequence=b,this._speed=b.speed,this._loop=b.loop,this._parent=d,this._clock=c,this._lastFrameElapsed=this.clock.elapsed()}return b.prototype.objType=function(){return"Animation"},Object.defineProperty(b.prototype,"loop",{get:function(){return this._loop},set:function(a){this._loop=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameIndex",{get:function(){return this._frameIndex},set:function(a){a=Math.floor(a),this._validateFrame(a)&&(this._frameIndex=a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"currentCell",{get:function(){return this._sequence.cells[this.frameIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"speed",{get:function(){return this._speed},set:function(a){this._speed=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clock",{get:function(){return this._clock?this._clock:this._parent.entity.clock},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"reverse",{get:function(){return this._reverse},set:function(a){this._reverse=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isPlaying",{get:function(){return this._isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onStop",{get:function(){return null==this._onStop&&(this._onStop=new a.Signal),this._onStop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onPlay",{get:function(){return null==this._onPlay&&(this._onPlay=new a.Signal),this._onPlay},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUpdate",{get:function(){return null==this._onUpdate&&(this._onUpdate=new a.Signal),this._onUpdate},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onLoop",{get:function(){return null==this._onLoop&&(this._onLoop=new a.Signal),this._onLoop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onComplete",{get:function(){return null==this._onComplete&&(this._onComplete=new a.Signal),this._onComplete},enumerable:!0,configurable:!0}),b.prototype._start=function(a){void 0===a&&(a=null),null!==a&&(this.frameIndex=a),(this.frameIndex>=this.length-1||this.frameIndex<0)&&(this.frameIndex=0),this._isPlaying=!0,this._startTime=this.clock.elapsed(),this._lastFrameElapsed=this.clock.elapsed(),null!==this._onPlay&&this._onPlay.dispatch()},b.prototype.play=function(){this.playAt(this._frameIndex)},b.prototype.playAt=function(a){this._start(a)},b.prototype.pause=function(){this.stop()},b.prototype.resume=function(){null!==this._startTime&&(this._isPlaying=!0)},b.prototype.stop=function(){this._isPlaying&&(this._isPlaying=!1,null!==this._onStop&&this._onStop.dispatch())},b.prototype.nextFrame=function(){this._frameIndex++,this._frameIndex>=this.length&&(this.frameIndex=0)},b.prototype.prevFrame=function(){this._frameIndex--,this._frameIndex<0&&(this.frameIndex=this.length-1)},b.prototype.update=function(){var a,b,c;if(this._isPlaying&&(a=(this.clock.elapsed()-this._lastFrameElapsed)/this._speed%(this.length+1),this._reverse&&(a*=-1),a=a>0?Math.floor(a):Math.ceil(a),0!==a)){if(this._frameIndex+=a,this._lastFrameElapsed=this.clock.elapsed(),this._loop){if(this._frameIndex>=this.length){if(c=Math.floor(this._frameIndex/this.length),this._frameIndex=this._frameIndex%this.length,null!=this._onLoop)for(b=0;c>b;b++)this._onLoop.dispatch()}else if(this._frameIndex<0&&(c=Math.ceil(Math.abs(this._frameIndex)/this.length),this._frameIndex=(this.length+this._frameIndex%this.length)%this.length,null!=this._onLoop))for(b=0;c>b;b++)this._onLoop.dispatch()}else{if(this._frameIndex<0)return this._frameIndex=(this.length+this._frameIndex%this.length)%this.length,void this._parent.stop();if(this._frameIndex>=this.length)return this._frameIndex=this._frameIndex%this.length,this._parent.stop(),void(null!=this._onComplete&&this._onComplete.dispatch())}this._parent.updateCellIndex(),null!==this._onUpdate&&this._onUpdate.dispatch()}},b.prototype._validateFrame=function(a){return a=0},Object.defineProperty(b.prototype,"length",{get:function(){return this._sequence.cells.length},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this._isPlaying=!1,delete this._clock,delete this._sequence,delete this._parent,this._onLoop&&this._onLoop.dispose(),this._onStop&&this._onStop.dispose(),this._onPlay&&this._onPlay.dispose(),this._onUpdate&&this._onUpdate.dispose(),delete this._onLoop,delete this._onStop,delete this._onPlay,delete this._onUpdate,delete this.frameIndex,delete this.loop,delete this._reverse,delete this._tick},b}();b.Animation=c}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c,d){void 0===c&&(c=.1),void 0===d&&(d=!0),this.name=a,this.cells=b,this.speed=c,this.loop=d}return a}();a.Sequence=b}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this.preventDefault=!1,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.timeUp=0,this.repeats=0,this._manager=a,this.game=this._manager.game,this.keyCode=b,c&&this.update(c)}return a.prototype.objType=function(){return"Key"},Object.defineProperty(a.prototype,"duration",{get:function(){return this.isDown&&(this.timeDown=this.game.time.now()),this.timeDownthis.game.time.now()?!0:!1},a.prototype.justReleased=function(a){return void 0===a&&(a=this._manager.justReleasedRate),this.isUp===!0&&this.timeUp+a>this.game.time.now()?!0:!1},a.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeUp=0,this.timeDown=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},a}();a.Key=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._keys=[],this.justPressedRate=200,this.justReleasedRate=200,this.game=a}return b.prototype.objType=function(){return"Keyboard"},Object.defineProperty(b.prototype,"keys",{get:function(){return this._keys},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this.onKeyUp=new a.Signal,this.onKeyDown=new a.Signal,this.onKeyDownOnce=new a.Signal,this.start()},b.prototype.update=function(){},b.prototype.start=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.addEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.addEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype.stop=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.removeEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.removeEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype._keyPressed=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),0==this._keys[b.keyCode].repeats&&this.onKeyDownOnce.dispatch(b.keyCode,this._keys[b.keyCode]),this.onKeyDown.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype._keyReleased=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),this.onKeyUp.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype.addKey=function(b,c){void 0===c&&(c=!1);var d=new a.Input.Key(this,b);return d.preventDefault=c,this._keys[b]=d},b.prototype.justPressed=function(a,b){return void 0===b&&(b=this.justPressedRate),this._keys[a]?this._keys[a].justPressed(b):!1},b.prototype.justReleased=function(a,b){return void 0===b&&(b=this.justReleasedRate),this._keys[a]?this._keys[a].justReleased(b):!1},b.prototype.isDown=function(a){return this._keys[a]?this._keys[a].isDown:!1},b.prototype.isUp=function(a){return this._keys[a]?this._keys[a].isUp:!1},b.prototype.reset=function(){for(var a in this._keys)this._keys[a].reset(); +},b}();b.Keyboard=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Keycodes"},a.A="A".charCodeAt(0),a.B="B".charCodeAt(0),a.C="C".charCodeAt(0),a.D="D".charCodeAt(0),a.E="E".charCodeAt(0),a.F="F".charCodeAt(0),a.G="G".charCodeAt(0),a.H="H".charCodeAt(0),a.I="I".charCodeAt(0),a.J="J".charCodeAt(0),a.K="K".charCodeAt(0),a.L="L".charCodeAt(0),a.M="M".charCodeAt(0),a.N="N".charCodeAt(0),a.O="O".charCodeAt(0),a.P="P".charCodeAt(0),a.Q="Q".charCodeAt(0),a.R="R".charCodeAt(0),a.S="S".charCodeAt(0),a.T="T".charCodeAt(0),a.U="U".charCodeAt(0),a.V="V".charCodeAt(0),a.W="W".charCodeAt(0),a.X="X".charCodeAt(0),a.Y="Y".charCodeAt(0),a.Z="Z".charCodeAt(0),a.ZERO="0".charCodeAt(0),a.ONE="1".charCodeAt(0),a.TWO="2".charCodeAt(0),a.THREE="3".charCodeAt(0),a.FOUR="4".charCodeAt(0),a.FIVE="5".charCodeAt(0),a.SIX="6".charCodeAt(0),a.SEVEN="7".charCodeAt(0),a.EIGHT="8".charCodeAt(0),a.NINE="9".charCodeAt(0),a.NUMPAD_0=96,a.NUMPAD_1=97,a.NUMPAD_2=98,a.NUMPAD_3=99,a.NUMPAD_4=100,a.NUMPAD_5=101,a.NUMPAD_6=102,a.NUMPAD_7=103,a.NUMPAD_8=104,a.NUMPAD_9=105,a.NUMPAD_MULTIPLY=106,a.NUMPAD_ADD=107,a.NUMPAD_ENTER=108,a.NUMPAD_SUBTRACT=109,a.NUMPAD_DECIMAL=110,a.NUMPAD_DIVIDE=111,a.F1=112,a.F2=113,a.F3=114,a.F4=115,a.F5=116,a.F6=117,a.F7=118,a.F8=119,a.F9=120,a.F10=121,a.F11=122,a.F12=123,a.F13=124,a.F14=125,a.F15=126,a.COLON=186,a.EQUALS=187,a.UNDERSCORE=189,a.QUESTION_MARK=191,a.TILDE=192,a.OPEN_BRACKET=219,a.BACKWARD_SLASH=220,a.CLOSED_BRACKET=221,a.QUOTES=222,a.BACKSPACE=8,a.TAB=9,a.CLEAR=12,a.ENTER=13,a.SHIFT=16,a.CONTROL=17,a.ALT=18,a.CAPS_LOCK=20,a.ESC=27,a.SPACEBAR=32,a.PAGE_UP=33,a.PAGE_DOWN=34,a.END=35,a.HOME=36,a.LEFT=37,a.UP=38,a.RIGHT=39,a.DOWN=40,a.INSERT=45,a.DELETE=46,a.HELP=47,a.NUM_LOCK=144,a}();a.Keycodes=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this.game=a}return b.prototype.objType=function(){return"InputManager"},Object.defineProperty(b.prototype,"pointers",{get:function(){return this._pointers},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._pointers=[],this.mouse=new a.Input.Mouse(this.game),this.mouse.boot(),this.keyboard=new a.Input.Keyboard(this.game),this.keyboard.boot(),this.touch=new a.Input.Touch(this.game),this.touch.boot(),this.mouse.onDown.add(this._onDownEvent,this),this.mouse.onUp.add(this._onUpEvent,this),this.touch.touchDown.add(this._onDownEvent,this),this.touch.touchUp.add(this._onUpEvent,this),this._pointers=this.touch.fingers.slice(),this._pointers.push(this.mouse.cursor),this.isDown=!1,this.position=new a.Geom.Point,this.onDown=new a.Signal,this.onUp=new a.Signal},b.prototype._onDownEvent=function(a,b,c,d,e,f){this.onDown.dispatch(a,b,c,d,e,f)},b.prototype._onUpEvent=function(a,b,c,d,e,f){this.onUp.dispatch(a,b,c,d,e,f)},Object.defineProperty(b.prototype,"onPressed",{get:function(){return this.onDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onReleased",{get:function(){return this.onUp},enumerable:!0,configurable:!0}),b.prototype.update=function(){this.mouse.update(),this.keyboard.update(),this.touch.update(),this.touch.touchEnabled?this.position.setTo(this.touch.x,this.touch.y):this.position.setTo(this.mouse.x,this.mouse.y),this.isDown=this.mouse.isDown||this.touch.isDown},b.prototype.reset=function(){this.mouse.reset(),this.keyboard.reset(),this.touch.reset()},Object.defineProperty(b.prototype,"x",{get:function(){return this.position.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.position.y},enumerable:!0,configurable:!0}),b}();b.InputManager=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.preventContextMenu=!1,this._game=a}return b.prototype.objType=function(){return"Mouse"},Object.defineProperty(b.prototype,"cursor",{get:function(){return this._cursor},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this._cursor=new a.Input.MouseCursor(this._game),this._cursor.active=!0,this._cursor.id=1,this.onDown=new a.Signal,this.onUp=new a.Signal,this.onWheel=new a.Signal,this.onContext=new a.Signal,this.start()},Object.defineProperty(b.prototype,"isDown",{get:function(){return this._cursor.isDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isUp",{get:function(){return this._cursor.isUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"duration",{get:function(){return this._cursor.duration},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._cursor.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._cursor.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaX",{get:function(){return this._cursor.wheelDeltaX},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaY",{get:function(){return this._cursor.wheelDeltaY},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"ctrlKey",{get:function(){return this._cursor.ctrlKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"shiftKey",{get:function(){return this._cursor.shiftKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"altKey",{get:function(){return this._cursor.altKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"button",{get:function(){return this._cursor.button},enumerable:!0,configurable:!0}),b.prototype.update=function(){this._cursor.update()},b.prototype.start=function(){this._onMouseDownBind=this.onMouseDown.bind(this),this._onMouseMoveBind=this.onMouseMove.bind(this),this._onMouseUpBind=this.onMouseUp.bind(this),this._onMouseWheelBind=this.onMouseWheel.bind(this),this._onContextMenuBind=this.onContextMenu.bind(this),this._game.deviceTargetOption===a.TARGET_BROWSER?(this._domElement.addEventListener("mousedown",this._onMouseDownBind,!0),this._domElement.addEventListener("mousemove",this._onMouseMoveBind,!0),this._domElement.addEventListener("mouseup",this._onMouseUpBind,!0),this._domElement.addEventListener("mousewheel",this._onMouseWheelBind,!0),this._domElement.addEventListener("DOMMouseScroll",this._onMouseWheelBind,!0),this._domElement.addEventListener("contextmenu",this._onContextMenuBind,!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("mousedown",this._onMouseDownBind,!0),this._game.stage.canvas.addEventListener("mousemove",this._onMouseMoveBind,!0),this._game.stage.canvas.addEventListener("mouseup",this._onMouseUpBind,!0),this._game.stage.canvas.addEventListener("mousewheel",this._onMouseWheelBind,!0),this._game.stage.canvas.addEventListener("DOMMouseScroll",this._onMouseWheelBind,!0))},b.prototype.stop=function(){this._game.deviceTargetOption===a.TARGET_BROWSER?(this._domElement.removeEventListener("mousedown",this._onMouseDownBind,!0),this._domElement.removeEventListener("mousemove",this._onMouseMoveBind,!0),this._domElement.removeEventListener("mouseup",this._onMouseUpBind,!0),this._domElement.removeEventListener("mousewheel",this._onMouseWheelBind,!0),this._domElement.removeEventListener("DOMMouseScroll",this._onMouseWheelBind,!0),this._domElement.removeEventListener("contextmenu",this._onContextMenuBind,!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.removeEventListener("mousedown",this._onMouseDownBind,!0),this._game.stage.canvas.removeEventListener("mousemove",this._onMouseMoveBind,!0),this._game.stage.canvas.removeEventListener("mouseup",this._onMouseUpBind,!0),this._game.stage.canvas.removeEventListener("mousewheel",this._onMouseWheelBind,!0),this._game.stage.canvas.removeEventListener("DOMMouseScroll",this._onMouseWheelBind,!0)),delete this._onMouseDownBind,delete this._onMouseMoveBind,delete this._onMouseUpBind,delete this._onMouseWheelBind,delete this._onContextMenuBind},b.prototype.onMouseDown=function(a){this._cursor.start(a),this.onDown.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseMove=function(a){a.preventDefault(),this._cursor.move(a)},b.prototype.onMouseUp=function(a){this._cursor.stop(a),this.onUp.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseWheel=function(a){this._cursor.wheel(a),this.onWheel.dispatch(this._cursor.wheelDeltaX,this._cursor.wheelDeltaY,this._cursor)},b.prototype.justPressed=function(a){return void 0===a&&(a=this._cursor.justPressedRate),this._cursor.justPressed(a)},b.prototype.justReleased=function(a){return void 0===a&&(a=this._cursor.justReleasedRate),this._cursor.justReleased(a)},b.prototype.reset=function(){this._cursor.reset()},b.prototype.onContextMenu=function(a){this.preventContextMenu&&a.preventDefault(),this.onContext.dispatch(a)},b.LEFT_BUTTON=0,b.MIDDLE_BUTTON=1,b.RIGHT_BUTTON=2,b}();b.Mouse=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.isDown=!1,this.isUp=!0,this._maxPointers=10,this._game=a}return b.prototype.objType=function(){return"TouchManager"},Object.defineProperty(b.prototype,"fingers",{get:function(){return this._fingers},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onDown",{get:function(){return this.touchDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUp",{get:function(){return this.touchUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onCancel",{get:function(){return this.touchCancel},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this.finger1=new a.Input.Finger(this._game),this.finger2=new a.Input.Finger(this._game),this.finger3=new a.Input.Finger(this._game),this.finger4=new a.Input.Finger(this._game),this.finger5=new a.Input.Finger(this._game),this.finger6=new a.Input.Finger(this._game),this.finger7=new a.Input.Finger(this._game),this.finger8=new a.Input.Finger(this._game),this.finger9=new a.Input.Finger(this._game),this.finger10=new a.Input.Finger(this._game),this._fingers=[this.finger1,this.finger2,this.finger3,this.finger4,this.finger5,this.finger6,this.finger7,this.finger8,this.finger9,this.finger10],this.latestFinger=this.finger1,this.touchDown=new a.Signal,this.touchUp=new a.Signal,this.touchCancel=new a.Signal,this.start()},b.prototype.start=function(){var b=this;if(a.DEVICE.touch)if(this.touchEnabled=!0,this._onTouchStartBind=this.onTouchStart.bind(this),this._onTouchMoveBind=this.onTouchMove.bind(this),this._onTouchEndBind=this.onTouchEnd.bind(this),this._onTouchEnterBind=this.onTouchEnter.bind(this),this._onTouchLeaveBind=this.onTouchLeave.bind(this),this._onTouchCancelBind=this.onTouchCancel.bind(this),this._game.deviceTargetOption===a.TARGET_BROWSER)if(a.DEVICE.pointerEnabled){var c="pointerup",d="pointerdown",e="pointerenter",f="pointerleave",g="pointercancel",h="pointermove";if(window.PointerEvent);else if(window.MSPointerEvent)var c="MSPointerUp",d="MSPointerDown",e="MSPointerEnter",f="MSPointerLeave",g="MSPointerCancel",h="MSPointerMove";this._onTouchStartBind=this.onPointerStart.bind(this),this._onTouchMoveBind=this.onPointerMove.bind(this),this._onTouchEndBind=this.onPointerEnd.bind(this),this._onTouchEnterBind=this.onPointerEnter.bind(this),this._onTouchLeaveBind=this.onPointerLeave.bind(this),this._onTouchCancelBind=this.onPointerCancel.bind(this),this._domElement.addEventListener(c,this._onTouchStartBind,!1),this._domElement.addEventListener(h,this._onTouchMoveBind,!1),this._domElement.addEventListener(d,this._onTouchEndBind,!1),this._domElement.addEventListener(e,this._onTouchEnterBind,!1),this._domElement.addEventListener(f,this._onTouchLeaveBind,!1),this._domElement.addEventListener(g,this._onTouchCancelBind,!1)}else this._domElement.addEventListener("touchstart",this._onTouchStartBind,!1),this._domElement.addEventListener("touchmove",this._onTouchMoveBind,!1),this._domElement.addEventListener("touchend",this._onTouchEndBind,!1),this._domElement.addEventListener("touchenter",this._onTouchEnterBind,!1),this._domElement.addEventListener("touchleave",this._onTouchLeaveBind,!1),this._domElement.addEventListener("touchcancel",this._onTouchCancelBind,!1),document.addEventListener("touchmove",function(a){return b.consumeTouchMove(a)},!1);else this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("touchstart",this._onTouchStartBind,!1),this._game.stage.canvas.addEventListener("touchmove",this._onTouchMoveBind,!1),this._game.stage.canvas.addEventListener("touchend",this._onTouchEndBind,!1),this._game.stage.canvas.addEventListener("touchenter",this._onTouchEnterBind,!1),this._game.stage.canvas.addEventListener("touchleave",this._onTouchLeaveBind,!1),this._game.stage.canvas.addEventListener("touchcancel",this._onTouchCancelBind,!1));else this.touchEnabled=!1},b.prototype.consumeTouchMove=function(a){a.preventDefault()},Object.defineProperty(b.prototype,"x",{get:function(){return this.latestFinger.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.latestFinger.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"maximumPointers",{get:function(){return this._maxPointers},set:function(a){0>a&&(a=1),a>this._fingers.length&&(a=this._fingers.length),this._maxPointers=a},enumerable:!0,configurable:!0}),b.prototype._registerFinger=function(a,b){for(var c=0;cthis._game.time.now()?!0:!1},b.prototype.justReleased=function(a){return void 0===a&&(a=this.justReleasedRate),this.isUp===!0&&this.timeUp+a>this._game.time.now()?!0:!1},Object.defineProperty(b.prototype,"pressed",{get:function(){return this.timeDown>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"released",{get:function(){return this.timeUp>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),b.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.duration=0,this.frameDuration=0},b.prototype.update=function(){this.isDown===!0&&(this.frameDuration++,this.duration=this._game.time.now()-this.timeDown)},b}();b.Pointer=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments),this.wheelDeltaX=0,this.wheelDeltaY=0,this.preventDown=!0,this.preventUp=!0,this.preventWheel=!0}return __extends(b,a),b.prototype.objType=function(){return"MouseCursor"},b.prototype.start=function(b){this.preventDown&&b.preventDefault(),this.ctrlKey=b.ctrlKey,this.shiftKey=b.shiftKey,this.altKey=b.altKey,this.button=b.button,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.preventUp&&b.preventDefault(),this.move(b),a.prototype.stop.call(this,b)},b.prototype.wheel=function(a){this.preventWheel&&a.preventDefault(),a.wheelDeltaX?this.wheelDeltaX=a.wheelDeltaX:this.wheelDeltaX=a.deltaX,a.wheelDeltaY?this.wheelDeltaY=a.wheelDeltaY:this.wheelDeltaY=a.deltaY},b}(a.Pointer);a.MouseCursor=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b){a.call(this,b),this.circle.diameter=44}return __extends(b,a),b.prototype.objType=function(){return"Finger"},b.prototype.start=function(b){this.active=!0,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.active=!1,a.prototype.stop.call(this,b)},b.prototype.leave=function(a){this.withinGame=!1,this.move(a)},b.prototype.reset=function(){this.active=!1,a.prototype.reset.call(this)},b}(a.Pointer);a.Finger=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c,d){this.cx=0,this.cy=0,this.halfWidth=0,this.halfHeight=0,this.cx=a||0,this.cy=b||0,this.halfWidth=c/2||0,this.halfHeight=d/2||0}return b.prototype.objType=function(){return"AABB"},Object.defineProperty(b.prototype,"height",{get:function(){return 2*this.halfHeight},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return 2*this.halfWidth},enumerable:!0,configurable:!0}),b.prototype.draw=function(a){return a.beginPath(),a.moveTo(this.cx-this.halfWidth,this.cy),a.lineTo(this.cx+this.halfWidth,this.cy),a.moveTo(this.cx,this.cy-this.halfHeight),a.lineTo(this.cx,this.cy+this.halfHeight),a.stroke(),this},b.prototype.setPosition=function(a,b){return this.cx=a,this.cy=b,this},b.prototype.setPositionPoint=function(a){return this.cx=a.x,this.cy=a.y,this},b.prototype.toRect=function(){return new a.Rectangle(this.cx-this.halfWidth,this.cy-this.halfHeight,2*this.halfWidth,2*this.halfHeight)},b.prototype.fromRect=function(a){return this.halfWidth=a.width/2,this.halfHeight=a.height/2,this.cx=a.x+this.halfWidth,this.cy=a.y+this.halfHeight,this},b}();a.AABB=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),this._diameter=0,this._radius=0,this.x=0,this.y=0,this.setTo(a,b,c)}return b.prototype.objType=function(){return"Circle"},Object.defineProperty(b.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"circumference",{get:function(){return 2*(Math.PI*this._radius)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){isNaN(a)||(athis.x?this.radius=a-this.x:(this._radius=0,this._diameter=0))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"top",{get:function(){return this.y-this._radius},set:function(a){a&&!isNaN(a)&&(a>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isEmpty",{get:function(){return this._diameter<=0?!0:!1},enumerable:!0,configurable:!0}),b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x,this.y,this._diameter)},b.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.diameter)},b.prototype.copyTo=function(a){return a.copyFrom(this)},b.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},b.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.diameter===a.diameter?!0:!1},b.prototype.intersects=function(a){return this.distanceTo(a,!1)=c&&d>=a&&b>=e&&f>=b?!0:!1},b.prototype.intersectLineLine=function(b){return a.Geom.Intersect.lineToLine(this,b)},b.prototype.perp=function(a,c,d){void 0===d&&(d=new b);var e;if(this.y1===this.y2)return d.setTo(a,c,a,this.y1),d;if(this.x1===this.x2)return d.setTo(a,c,this.x1,c),d;var f=c-this.perpSlope*a;return e=0!==a?this.intersectLineLine({x1:a,y1:c,x2:0,y2:f}):this.intersectLineLine({x1:a,y1:c,x2:1,y2:f+this.perpSlope}),d.setTo(a,c,e.x,e.y),d},b.prototype.toString=function(){return"[{Line (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}();b.Line=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=0),a.call(this,b,c,d,e)}return __extends(b,a),b.prototype.objType=function(){return"Ray"},b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x1,this.y1,this.x2,this.y2)},b.prototype.isPointOnRay=function(a,b){return(a-this.x1)*(this.y2-this.y1)===(this.x2-this.x1)*(b-this.y1)&&Math.atan2(b-this.y1,a-this.x1)==Math.atan2(this.y2-this.y1,this.x2-this.x1)?!0:!1},b.prototype.toString=function(){return"[{Ray (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}(a.Line);a.Ray=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(){}return c.prototype.objType=function(){return"Intersect"},c.distance=function(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))},c.distanceSquared=function(a,b,c,d){return(c-a)*(c-a)+(d-b)*(d-b)},c.lineToLine=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);return 0!==e&&(d.result=!0,d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e),d},c.lineToLineSegment=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);if(0!==e){d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e;var f=Math.max(c.x1,c.x2),g=Math.min(c.x1,c.x2),h=Math.max(c.y1,c.y2),i=Math.min(c.y1,c.y2);(d.x<=f&&d.x>=g)==!0&&(d.y<=h&&d.y>=i)==!0&&(d.result=!0)}return d},c.lineToRawSegment=function(a,c,d,e,f,g){void 0===g&&(g=new b.IntersectResult),g.result=!1;var h=(a.x1-a.x2)*(d-f)-(a.y1-a.y2)*(c-e);if(0!==h){g.x=((a.x1*a.y2-a.y1*a.x2)*(c-e)-(a.x1-a.x2)*(c*f-d*e))/h,g.y=((a.x1*a.y2-a.y1*a.x2)*(d-f)-(a.y1-a.y2)*(c*f-d*e))/h;var i=Math.max(c,e),j=Math.min(c,e),k=Math.max(d,f),l=Math.min(d,f); +g.x<=i&&g.x>=j&&g.y<=k&&g.y>=l&&(g.result=!0)}return g},c.lineSegmentToRawSegment=function(a,d,e,f,g,h){void 0===h&&(h=new b.IntersectResult),h=c.lineToRawSegment(a,d,e,f,g,h);var i=Math.max(a.x1,a.x2),j=Math.min(a.x1,a.x2),k=Math.max(a.y1,a.y2),l=Math.min(a.y1,a.y2);return h.x<=i&&h.x>=j&&h.y<=k&&h.y>=l?h:(h.result=!1,h)},c.lineToRay=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=(a.x1-a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1-c.x2);return 0!==e&&(d.x=((a.x1*a.y2-a.y1*a.x2)*(c.x1-c.x2)-(a.x1-a.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((a.x1*a.y2-a.y1*a.x2)*(c.y1-c.y2)-(a.y1-a.y2)*(c.x1*c.y2-c.y1*c.x2))/e,d.result=!0,!(c.x1>=c.x2)&&d.x=c.y2)&&d.y=Math.min(a.x1,a.x2)&&e.x<=Math.max(a.x1,a.x2)&&e.y>=Math.min(a.y1,a.y2)&&e.y<=Math.max(a.y1,a.y2)||(e.result=!1)),e},c.lineSegmentToRay=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToRay(a,d,e),e.result===!0&&(e.x>=Math.min(a.x1,a.x2)&&e.x<=Math.max(a.x1,a.x2)&&e.y>=Math.min(a.y1,a.y2)&&e.y<=Math.max(a.y1,a.y2)||(e.result=!1)),e},c.lineSegmentToCircle=function(a,d,e){void 0===e&&(e=new b.IntersectResult),e.result=!1;var f=a.perp(d.x,d.y);if(f.length<=d.radius){var g=Math.max(a.x1,a.x2),h=Math.min(a.x1,a.x2),i=Math.max(a.y1,a.y2),j=Math.min(a.y1,a.y2);f.x2<=g&&f.x2>=h&&f.y2<=i&&f.y2>=j?e.result=!0:(c.circleContainsPoint(d,{x:a.x1,y:a.y1}).result||c.circleContainsPoint(d,{x:a.x2,y:a.y2}).result)&&(e.result=!0)}return e},c.lineSegmentToRectangle=function(a,d,e){if(void 0===e&&(e=new b.IntersectResult),e.result=!1,d.contains(a.x1,a.y1)&&d.contains(a.x2,a.y2))e.x=(a.x1+a.x2)/2,e.y=(a.y1+a.y2)/2,e.result=!0;else{if(c.lineSegmentToRawSegment(a,d.x,d.y,d.right,d.y,e),e.result===!0)return e;if(c.lineSegmentToRawSegment(a,d.x,d.y,d.x,d.bottom,e),e.result===!0)return e;if(c.lineSegmentToRawSegment(a,d.x,d.bottom,d.right,d.bottom,e),e.result===!0)return e;c.lineSegmentToRawSegment(a,d.right,d.y,d.right,d.bottom,e)}return e},c.rayToCircle=function(d,e,f){void 0===f&&(f=new b.IntersectResult);var g=e.x-d.x1,h=e.y-d.y1;return f.result=!1,Math.sqrt(g*g+h*h)<=e.radius?(f.result=!0,f):Math.abs(a.Utils.GameMath.nearestAngleBetween(d.angle,Math.atan2(h,g)))>=Math.PI/2?f:(c.lineToCircle(d,e,f),f)},c.rayToRectangle=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,c.lineToRectangle(a,d,e),e},c.rayToLineSegment=function(a,c,d,e,f,g,h,i,j){void 0===j&&(j=new b.IntersectResult),j.result=!1;var k,l,m;return(e-c)/(d-a)!=(i-g)/(h-f)&&(m=(d-a)*(i-g)-(e-c)*(h-f),0!=m&&(k=((c-g)*(h-f)-(a-f)*(i-g))/m,l=((c-g)*(d-a)-(a-f)*(e-c))/m,k>=0&&l>=0&&1>=l&&(j.result=!0,j.x=a+k*(d-a),c+k*(e-c)))),j},c.circleToCircle=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,e.result=(a.radius+d.radius)*(a.radius+d.radius)>=c.distanceSquared(a.x,a.y,d.x,d.y),e},c.circleToRectangle=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e,f,g,h,i,j,k,l;return i=c.width/2,g=Math.abs(a.x-c.x-i),k=a.radius+i,g>k?(d.result=!1,d):(j=c.height/2,h=Math.abs(a.y-c.y-j),l=a.radius+j,h>l?(d.result=!1,d):i>=g||h<=c.height/2?(d.result=!0,d):(e=g-i,f=h-j,d.result=e*e+f*f<=a.radius*a.radius,d))},c.circleContainsPoint=function(a,d,e){return void 0===e&&(e=new b.IntersectResult),e.result=!1,e.result=a.radius*a.radius>=c.distanceSquared(a.x,a.y,d.x,d.y),e},c.pointToRectangle=function(a,c,d){return void 0===d&&(d=new b.IntersectResult),d.result=!1,d.setTo(a.x,a.y),d.result=c.containsPoint(a),d},c.rectangleToRectangle=function(a,c,d){void 0===d&&(d=new b.IntersectResult),d.result=!1;var e=Math.max(a.x,c.x),f=Math.min(a.right,c.right),g=Math.max(a.y,c.y),h=Math.min(a.bottom,c.bottom);d.setTo(e,g,f-e,h-g,f-e,h-g);var i=d.x+.5*d.width,j=d.y+.5*d.height;return i>a.x&&ia.y&&j=b?!0:!1},a.prototype.equals=function(a){return this.x===a.x&&this.y===a.y?!0:!1},a.interpolate=function(b,c,d){var e=c.x-b.x,f=c.y-b.y;return new a(c.x-e*d,c.y-f*d)},a.prototype.offset=function(a,b){return this.x+=a,this.y+=b,this},a.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},a.prototype.subtract=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x-b.x,this.y-b.y)},a.prototype.getCSS=function(){return this.x+"px "+this.y+"px"},a.prototype.toString=function(){return"[{Point (x="+this.x+" y="+this.y+")}]"},a}();a.Point=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.x=0,this.y=0,this.width=0,this.height=0,this.setTo(a,b,c,d)}return c.prototype.objType=function(){return"Rectangle"},Object.defineProperty(c.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a&&(a=this.x&&a<=this.right&&b>=this.y&&b<=this.bottom?!0:!1},c.prototype.containsPoint=function(a){return this.contains(a.x,a.y)},c.prototype.containsRect=function(a){return a.volume>this.volume?!1:a.x>=this.x&&a.y>=this.y&&a.right<=this.right&&a.bottom<=this.bottom?!0:!1},c.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.width,a.height)},c.prototype.copyTo=function(a){return void 0===a&&(a=new c),a.copyFrom(this)},c.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.width===a.width&&this.height===a.height?!0:!1},c.prototype.inflate=function(a,b){return isNaN(a)||isNaN(b)||(this.x-=a,this.width+=2*a,this.y-=b,this.height+=2*b),this},c.prototype.inflatePoint=function(a){return this.inflate(a.x,a.y)},c.prototype.intersection=function(a,b){return void 0===b&&(b=new c),this.intersects(a)===!0&&(b.x=Math.max(a.x,this.x),b.y=Math.max(a.y,this.y),b.width=Math.min(a.right,this.right)-b.x,b.height=Math.min(a.bottom,this.bottom)-b.y),b},c.prototype.intersects=function(a){return a.x>this.right-1?!1:a.right-1this.bottom-1?!1:!0},c.prototype.overlap=function(a){var b={top:!1,bottom:!1,left:!1,right:!1,contains:!1,contained:!1},c=this.intersection(a);return c.isEmpty?b:(this.containsRect(a)&&(b.contains=!0),a.containsRect(this)&&(b.contained=!0),this.topa.bottom&&(b.bottom=!0),this.lefta.right&&(b.right=!0),b)},c.prototype.isEmpty=function(){return this.width<1||this.height<1?!0:!1},c.prototype.offset=function(a,b){return isNaN(a)||isNaN(b)||(this.x+=a,this.y+=b),this},c.prototype.offsetPoint=function(a){return this.offset(a.x,a.y)},c.prototype.setEmpty=function(){return this.setTo(0,0,0,0)},c.prototype.setTo=function(a,b,c,d){return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)||(this.x=a,this.y=b,c>=0&&(this.width=c),d>=0&&(this.height=d)),this},c.prototype.union=function(a,b){return void 0===b&&(b=new c),b.setTo(Math.min(a.x,this.x),Math.min(a.y,this.y),Math.max(a.right,this.right),Math.max(a.bottom,this.bottom))},c.prototype.scale=function(b,c,d){var e=new a.Geom.Transform;e.scaleX=b,e.scaleY=c,e.x=d.x,e.y=d.y;var f=this.topLeft;return e.transformPoint(f),this.topLeft=f,this.width*=b,this.height*=c,this},c.prototype.toString=function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" isEmpty="+this.isEmpty()+")}]"},c}();b.Rectangle=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,c,d,e,f,g,h){void 0===a&&(a=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),this._x=0,this._y=0,this._scaleX=1,this._scaleY=1,this._rotation=0,this._rotPointX=0,this._rotPointY=0,this._parent=null,this._locked=!1,this._ignoreParent=!1,this._ignoreChild=!1,this._dirty=!0,this.setTransform(a,c,d,e,f,g,h),this._matrix=new b.Matrix,this._cachedConcatenatedMatrix=new b.Matrix,this._matrix.setFromOffsetTransform(this._x,this._y,this._scaleX,this._scaleY,this._rotation,this._rotPointX,this._rotPointY)}return c.prototype.objType=function(){return"Transform"},Object.defineProperty(c.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleX",{get:function(){return this._scaleX},set:function(a){this._scaleX=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleY",{get:function(){return this._scaleY},set:function(a){this._scaleY=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotation",{get:function(){return this._rotation},set:function(a){this._rotation=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointX",{get:function(){return this._rotPointX},set:function(a){this._rotPointX=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointY",{get:function(){return this._rotPointY},set:function(a){this._rotPointY=a,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointX",{get:function(){return this.rotPointX},set:function(a){this.rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointY",{get:function(){return this.rotPointY},set:function(a){this.rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"matrix",{get:function(){return this._matrix},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldX",{get:function(){return this.getConcatenatedMatrix().tx-this._rotPointX},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldY",{get:function(){return this.getConcatenatedMatrix().ty-this._rotPointY},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"parent",{get:function(){return this._parent},set:function(a){this.checkAncestor(a)||(this._parent=a,this._dirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"locked",{get:function(){return this._locked},set:function(a){this._locked=a,this._locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreParent",{get:function(){return this._ignoreParent},set:function(a){this._ignoreParent=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreChild",{get:function(){return this._ignoreChild},set:function(a){this._ignoreChild=a},enumerable:!0,configurable:!0}),c.prototype.setPosition=function(a,b){return this._x=a,this._y=b,this._dirty=!0,this},c.prototype.setPositionFromPoint=function(a){return this._x=a.x,this._y=a.y,this._dirty=!0,this},c.prototype.translatePositionFromPoint=function(a){return this._x+=a.x,this._y+=a.y,this._dirty=!0,this},c.prototype.getPositionPoint=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this._x,this._y)},Object.defineProperty(c.prototype,"scale",{set:function(a){this._scaleX=a,this._scaleY=a,this._dirty=!0},enumerable:!0,configurable:!0}),c.prototype.setTransform=function(a,b,c,d,e,f,g){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=1),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=0),this._x=a,this._y=b,this._scaleX=c,this._scaleY=d,this._rotation=e,this._rotPointX=f,this._rotPointY=g,this._dirty=!0,this},c.prototype.getParentMatrix=function(){return this._parent?this._parent.getConcatenatedMatrix():null},c.prototype.getConcatenatedMatrix=function(){return this._dirty&&!this.locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY),this._cachedConcatenatedMatrix.copyFrom(this._matrix),!this._parent||this._parent.ignoreChild||this.ignoreParent||(this._cachedConcatenatedMatrix.tx-=this._parent.anchorPointX,this._cachedConcatenatedMatrix.ty-=this._parent.anchorPointY,this._cachedConcatenatedMatrix.prependMatrix(this.getParentMatrix())),this._dirty=!1,this._cachedConcatenatedMatrix},c.prototype.transformPoint=function(a){var b=this.getConcatenatedMatrix();return b.transformPoint(a)},c.prototype.copyFrom=function(a){return this.setTransform(a.x,a.y,a.scaleX,a.scaleY,a.rotation,a.rotPointX,a.rotPointY),this.parent=a.parent,this._matrix=a.matrix.clone(),this},c.prototype.copyTo=function(a){return a.copyFrom(this),this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.copyFrom(this),a},c.prototype.checkAncestor=function(a){return!1},Object.defineProperty(c.prototype,"toString",{get:function(){return"[{Transform (x="+this._x+" y="+this._y+" scaleX="+this._scaleX+" scaleY="+this._scaleY+" rotation="+this._rotation+" regX="+this._rotPointX+" regY="+this.rotPointY+" matrix="+this._matrix+")}]"},enumerable:!0,configurable:!0}),c}();b.Transform=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return c.prototype.objType=function(){return"Vector2"},c.fromAngle=function(a){return new c(Math.cos(a),Math.sin(a))},c.randomRadius=function(a){return new c(2*Math.random()-1,2*Math.random()-1).multiplyScalar(a)},c.fromPoint=function(a){return new c(a.x,a.y)},c.prototype.add=function(a){return new c(this.x+a.x,this.y+a.y)},c.prototype.addX=function(a){return new c(this.x+a.x,this.y)},c.prototype.addY=function(a){return new c(this.x,this.y+a.y)},c.prototype.subtract=function(b){return new a.Geom.Vector2(this.x-b.x,this.y-b.y)},c.prototype.multiply=function(b){return new a.Geom.Vector2(this.x*b.x,this.y*b.y)},c.prototype.multiplyScalar=function(b){return new a.Geom.Vector2(this.x*b,this.y*b)},c.prototype.dot=function(a){return this.x*a.x+this.y*a.y},c.prototype.lenSqr=function(){return this.x*this.x+this.y*this.y},c.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},c.prototype.unit=function(){var a=1/this.len();return this.multiplyScalar(a)},c.prototype.floor=function(){return new c(Math.floor(this.x),Math.floor(this.y))},c.prototype.ceil=function(){return new c(Math.ceil(this.x),Math.ceil(this.y))},c.prototype.round=function(){return new c(Math.round(this.x),Math.round(this.y))},c.prototype.clamp=function(a,b){return new c(Math.max(Math.min(this.x,b.x),a.x),Math.max(Math.min(this.y,b.y),a.y))},c.prototype.perp=function(){return new c(-this.y,this.x)},c.prototype.neg=function(){return new c(-this.x,-this.y)},c.prototype.equal=function(a){return this.x===a.x&&this.y===a.y},c.prototype.point=function(){return new b.Point(this.x,this.y)},c.prototype.clear=function(){return this.x=0,this.y=0,this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.setTo(this.x,this.y)},c.prototype.copyFrom=function(a){return this.x=a.x,this.y=a.y,this},c.prototype.copyTo=function(a){return a.x=this.x,a.y=this.y,a},c.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},c.prototype.toString=function(){return"[{Vector2 (x="+this.x+" y="+this.y+")}]"},c}();b.Vector2=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){if(this._game=b,this.name=c,this._manager=this._game.huds,this._device=this._game.deviceTargetOption,this._manager.supported){switch(this._device){case a.TARGET_BROWSER:this.container=document.createElement("div"),this.container.id="HUD-layer-"+b.rnd.uuid(),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="absolute",this._widgets=new Array}this["class"]="kiwi-display"}}return b.prototype.objType=function(){return"HUDDisplay"},b.prototype.addWidget=function(b){return this._manager.supported&&(this._widgets.push(b),this._device==a.TARGET_BROWSER)?(this.container.appendChild(b.container),!0):!1},b.prototype.removeWidget=function(a){if(this._manager.supported&&this.removeFromContainer(a)){var b=this._widgets.indexOf(a);if(-1!==b)return this._widgets.splice(b,1),!0}return!1},b.prototype.removeAllWidgets=function(){for(var a=0;athis._icons.length)for(var a=this.counter.max-this._icons.length,b=0;a>b;b++)this._addIcon();else for(var b=this.counter.max;bthis.counter.current-1?this._icons[b].style.display="none":this._icons[b].style.display="block"},c.prototype._addIcon=function(){if(this.horizontal)var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x+(this.width+this.iconGap)*(this._icons.length-1),0);else var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x,(this.height+this.iconGap)*(this._icons.length-1));b.horizontalOrigin=this.horizontalOrigin,b.verticalOrigin=this.verticalOrigin,this._icons.push(b),this._device==a.TARGET_BROWSER&&this.container.appendChild(b.container)},c.prototype._removeIcon=function(b){this._device==a.TARGET_BROWSER&&this.container.removeChild(b.container)},Object.defineProperty(c.prototype,"horizontal",{get:function(){return this._horizontal},set:function(a){this._horizontal=a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"vertical",{get:function(){return!this._horizontal},set:function(a){this._horizontal=!a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"horizontalOrigin",{get:function(){return this._horizontalOrigin},set:function(a){this.container.style[this._horizontalOrigin]="auto",this._horizontalOrigin=a,this.container.style[this._horizontalOrigin]=this.x+"px";for(var b=0;bthis._max?this._current=this._max:null!==this._min&&athis._min)&&(null!==this._min&&this._current-athis._max?this._current=this._max:this._current+=a,this.updated.dispatch(this._current,this._max,this._min)),this._current},c.prototype.currentPercent=function(){return null!==this.max?this.current/this.max*100:void 0},c}(a.Component);b.Counter=c}(c=b.HUDComponents||(b.HUDComponents={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d){b.call(this,c,"WidgetInput"),this._active=!1,this._container=d,this.onUp=new a.Signal,this.onDown=new a.Signal,this.onOver=new a.Signal,this.onOut=new a.Signal,this._addEvents()}return __extends(c,b),c.prototype.objType=function(){return"WidgetInputComponent"},c.prototype.setElement=function(a){this._removeEvents(),this._container=a,this._addEvents()},c.prototype._addEvents=function(){if(!this._active){this._binds=[],this._binds.push({event:"mouseup","function":this._up.bind(this)}),this._binds.push({event:"mousedown","function":this._down.bind(this)}),this._binds.push({event:"mouseover","function":this._over.bind(this)}),this._binds.push({event:"mouseout","function":this._out.bind(this)});for(var a=0;a=this.duration&&(this._loop?(this.play(this._currentMarker,!0),this.onLoop.dispatch()):(this.onComplete.dispatch(),this.stop()))))},b.prototype.destroy=function(){this._game&&this._game.audio.remove(this,!1),this.onLoop&&this.onLoop.dispose(),this.onStop&&this.onStop.dispose(),this.onPlay&&this.onPlay.dispose(),this.onMute&&this.onMute.dispose(),this.onPause&&this.onPause.dispose(),this.onResume&&this.onResume.dispose(),delete this.onLoop,delete this.onStop,delete this.onPause,delete this.onMute,delete this.onPlay,delete this.onResume,delete this._game,delete this._sound,delete this._currentTime,delete this._startTime,delete this._pending,delete this.masterGainNode,delete this.gainNode,delete this.totalDuration,delete this.duration,delete this._file,delete this._buffer,delete this._decoded},b}();b.Audio=c}(b=a.Sound||(a.Sound={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this.audio={}}return b.prototype.objType=function(){return"AudioLibrary"},b.prototype.clear=function(){for(var a in this.audio)delete this.audio[a]},b.prototype.rebuild=function(b,c){this.clear(),a.Log.log("Kiwi.AudioLibrary: Rebuilding Audio Library.","#audio","#rebuild");for(var d=b.keys,e=0;e0&&(b=Math.min(b,this._maxFrameDuration));for(var c=0;c0?this._delay=b:a.Log.error("Attempted to set timer delay",b,"but value must be greater than 0","#timer")},enumerable:!0,configurable:!0}),c.prototype.processEvents=function(a){if(a===b.TimerEvent.TIMER_START)for(var c=0;c=this.delay;)this._currentCount++,this.processEvents(b.TimerEvent.TIMER_COUNT),this._elapsed-=this.delay,-1!==this.repeatCount&&this._currentCount>=this.repeatCount&&this.stop();for(;this._elapsed<0;)this._currentCount--,this._elapsed+=this.delay,this._currentCount<0&&(this.clear(),this.stop())},c.prototype.start=function(){return this._isStopped===!0&&(this._isRunning=!0,this._isPaused=!1,this._isStopped=!1,this._currentCount=0,this._elapsed=0,this._lastElapsed=this._clock.elapsed()||0,this.processEvents(b.TimerEvent.TIMER_START)),this},c.prototype.stop=function(){return(this._isRunning===!0||this._isPaused===!0)&&(this._isRunning=!1,this._isPaused=!1,this._isStopped=!0,this.processEvents(b.TimerEvent.TIMER_STOP)),this},c.prototype.pause=function(){return this._isRunning===!0&&(this._isRunning=!1,this._isPaused=!0),this},c.prototype.resume=function(){return this._isPaused===!0&&(this._isRunning=!0,this._isPaused=!1),this},c.prototype.addTimerEvent=function(a){return a.type===b.TimerEvent.TIMER_START?this._startEvents.push(a):a.type===b.TimerEvent.TIMER_COUNT?this._countEvents.push(a):a.type===b.TimerEvent.TIMER_STOP&&this._stopEvents.push(a),a},c.prototype.createTimerEvent=function(a,c,d){return a===b.TimerEvent.TIMER_START?(this._startEvents.push(new b.TimerEvent(a,c,d)),this._startEvents[this._startEvents.length-1]):a===b.TimerEvent.TIMER_COUNT?(this._countEvents.push(new b.TimerEvent(a,c,d)),this._countEvents[this._countEvents.length-1]):a===b.TimerEvent.TIMER_STOP?(this._stopEvents.push(new b.TimerEvent(a,c,d)),this._stopEvents[this._stopEvents.length-1]):null},c.prototype.removeTimerEvent=function(a){var c=[];return a.type===b.TimerEvent.TIMER_START?c=this._startEvents.splice(this._startEvents.indexOf(a),1):a.type===b.TimerEvent.TIMER_COUNT?c=this._countEvents.splice(this._countEvents.indexOf(a),1):a.type===b.TimerEvent.TIMER_STOP&&(c=this._stopEvents.splice(this._stopEvents.indexOf(a),1)),1===c.length?!0:!1},c.prototype.clear=function(a){void 0===a&&(a=0),0===a?(this._startEvents.length=0,this._countEvents.length=0,this._stopEvents.length=0):a===b.TimerEvent.TIMER_START?this._startEvents.length=0:a===b.TimerEvent.TIMER_COUNT?this._countEvents.length=0:a===b.TimerEvent.TIMER_STOP&&(this._stopEvents.length=0)},c.prototype.toString=function(){return"[{Timer (name="+this.name+" delay="+this.delay+" repeatCount="+this.repeatCount+" running="+this._isRunning+")}]"},c}();b.Timer=c}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this._callback=null,this.type=0,this.type=a,this._callback=b,this._callbackContext=c}return a.prototype.objType=function(){return"TimerEvent"},a.prototype.run=function(){this._callback&&this._callback.apply(this._callbackContext)},a.TIMER_START=1,a.TIMER_COUNT=2,a.TIMER_STOP=3,a}();a.TimerEvent=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!1),this.domElement=null,this.context=null,this._visible=!0,this._offScreen=!1,this._clearMode=1,this.domElement=document.createElement("canvas"),this.domElement.width=b,this.domElement.height=c,this._width=b,this._height=c,this.context=this.domElement.getContext("2d"),this._offScreen=e,this._visible=d,d===!1&&(this.domElement.style.display="none"),this._bgColor=new a.Utils.Color(0,0,0)}return Object.defineProperty(b.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a,this._updatedSize()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a,this._updatedSize()},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Canvas"},Object.defineProperty(b.prototype,"bgColor",{get:function(){return"#"+this._bgColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._bgColor.set.apply(this._bgColor,b)},enumerable:!0,configurable:!0}),b.prototype._updatedSize=function(){this.domElement.width=this._width,this.domElement.height=this._height},b.prototype.destroy=function(){this._offScreen===!1&&(this.domElement.style.display="none")},Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){null!==a&&a!==this._visible&&(this._visible=a,a===!0?this.domElement.style.display="block":this.domElement.style.display="none")},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clearMode",{get:function(){return this._clearMode},set:function(b){null!==b&&b!==this._clearMode&&b>=a.Utils.Canvas.CLEARMODE_NONE&&b<=a.Utils.Canvas.CLEARMODE_FILLRECT_ALPHA&&(this._clearMode=b)},enumerable:!0,configurable:!0}),b.prototype.clear=function(){this._clearMode===b.CLEARMODE_NONE||(this._clearMode===b.CLEARMODE_CLEARRECT?this.context.clearRect(0,0,this.domElement.width,this.domElement.height):this._clearMode===b.CLEARMODE_FILLRECT?(this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)):this._clearMode===b.CLEARMODE_FILLRECT_ALPHA&&(this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)))},b.prototype.saveAsPNG=function(){return this.domElement.toDataURL()},b.prototype.toString=function(){return"[{Canvas (width="+this.width+" height="+this.height+" visible="+this.visible+" offScreen="+this._offScreen+" clearMode="+this.clearMode+")}]"},b.CLEARMODE_NONE=0,b.CLEARMODE_CLEARRECT=1,b.CLEARMODE_FILLRECT=2,b.CLEARMODE_FILLRECT_ALPHA=3,b}();b.Canvas=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){for(var a=[],b=0;b1?this.r255=a:this.rNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g",{get:function(){return this._g},set:function(a){a>1?this.g255=a:this.gNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b",{get:function(){return this._b},set:function(a){a>1?this.b255=a:this.bNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a",{get:function(){return this._a},set:function(a){a>1?this.a255=a:this.aNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"r255",{get:function(){return Math.round(255*this._r)},set:function(a){isNaN(a)||(this._r=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g255",{get:function(){return Math.round(255*this._g)},set:function(a){isNaN(a)||(this._g=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b255",{get:function(){return Math.round(255*this._b)},set:function(a){isNaN(a)||(this._b=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a255",{get:function(){return Math.round(255*this._a)},set:function(a){isNaN(a)||(this._a=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"red",{get:function(){return this.r},set:function(a){this.r=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"green",{get:function(){return this.g},set:function(a){this.g=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"blue",{get:function(){return this.b},set:function(a){this.b=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"alpha",{get:function(){return this.a},set:function(a){this.a=a},enumerable:!0,configurable:!0}),a.prototype.parseString=function(a){var b;return a=a.toLowerCase(),"rgba"===a.slice(0,4)?(a=a.replace("rgba",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2],this.a=+b[3]):"rgb"===a.slice(0,3)?(a=a.replace("rgb",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2]):"hsla"===a.slice(0,4)?(a=a.replace("hsla",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2],+b[3])):"hsl"===a.slice(0,3)?(a=a.replace("hsl",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2])):this.parseHex(a),this},a.prototype.parseHex=function(a){var b,c=this.r255,d=this.g255,e=this.b255,f=this.a255;return"#"===a.charAt(0)&&(a=a.slice(1)),"0x"===a.slice(0,2)&&(a=a.slice(2)),b=parseInt(a,16),3===a.length?(c=17*(b>>8&15),d=17*(b>>4&15),e=17*(15&b)):4===a.length?(c=17*(b>>12&15),d=17*(b>>8&15),e=17*(b>>4&15),f=17*(15&b)):6===a.length?(c=b>>16&255,d=b>>8&255,e=255&b,f=255):8===a.length&&(c=b>>24&255,d=b>>16&255,e=b>>8&255,f=255&b),this.r255=c,this.g255=d,this.b255=e,this.a255=f,this},a.prototype.getHex=function(a){void 0===a&&(a=!0);var b,c="";for(b=this.r255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.g255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.b255.toString(16);b.length<2;)b="0"+b;if(c+=b,a){for(b=this.a255.toString(16);b.length<2;)b="0"+b;c+=b}return c},a.prototype.parseHsv=function(a,b,c,d){void 0===d&&(d=1);var e,f,g,h,i,j,k,l;if(isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d))return this;switch(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),h=Math.floor(6*a),i=6*a-h,j=c*(1-b),k=c*(1-i*b),l=c*(1-(1-i)*b),h%6){case 0:e=c,f=l,g=j;break;case 1:e=k,f=c,g=j;break;case 2:e=j,f=c,g=l;break;case 3:e=j,f=k,g=c;break;case 4:e=l,f=j,g=c;break;case 5:e=c,f=j,g=k}return this._r=e,this._g=f,this._b=g,this._a=d,this},a.prototype.getHsva=function(){var a,b,c,d,e=this._r,f=this._g,g=this._b,h=Math.max(e,f,g),i=Math.min(e,f,g);if(a=h,b=h,c=h,d=h-i,b=0===h?0:d/h,h===i)a=0;else{switch(h){case e:a=(f-g)/d+(g>f?6:0);break;case f:a=(g-e)/d+2;break;case g:a=(e-f)/d+4}a/=6}return{h:a,s:b,v:c,a:this._a}},a.prototype.parseHsl=function(a,b,c,d){void 0===d&&(d=1);var e,f,g=this._r,h=this._g,i=this._b;return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)?this:(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),0===b?(g=c,h=c,i=c):(e=.5>c?c*(1+b):c+b-c*b,f=2*c-e,g=this._hue2rgb(f,e,a+1/3),h=this._hue2rgb(f,e,a),i=this._hue2rgb(f,e,a-1/3)),this._r=g,this._g=h,this._b=i,this._a=d,this)},a.prototype.getHsla=function(){var a,b=this._r,c=this._g,d=this._b,e=Math.max(b,c,d),f=Math.min(b,c,d),g=(e+f)/2,h=(e+f)/2,i=(e+f)/2;if(e==f)g=0,h=0;else{switch(a=e-f,h=i>.5?a/(2-e-f):a/(e+f),e){case b:g=(c-d)/a+(d>c?6:0);break;case c:g=(d-b)/a+2;break;case d:g=(b-c)/a+4}g/=6}return{h:g,s:h,l:i,a:this._a}},a.prototype._hue2rgb=function(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a},a}();a.Color=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.defaultCompare=function(a,b){return b>a?-1:a===b?0:1},b.prototype.objType=function(){return"Common"},b.defaultEquals=function(a,b){return a===b},b.defaultToString=function(b){return null===b?"KIWI_NULL":a.Utils.Common.isUndefined(b)?"KIWI_UNDEFINED":a.Utils.Common.isString(b)?b:b.toString()},b.isBetween=function(a,b,c){return a>b&&c>a},b.isFunction=function(a){return"function"==typeof a},b.isNumeric=function(a){return!isNaN(a)},b.isUndefined=function(a){return"undefined"==typeof a},b.isString=function(a){return"[object String]"===Object.prototype.toString.call(a)},b.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b.isObject=function(a){return"[object Object]"===Object.prototype.toString.call(a)},b.reverseCompareFunction=function(b){return a.Utils.Common.isFunction(b)?function(a,c){return-1*b(a,c)}:function(a,b){return b>a?1:a===b?0:-1}},b.compareToEquals=function(a){return function(b,c){return 0===a(b,c)}},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},b.convertToBase2=function(a){var b=a.width,c=a.height;if(-1==this.base2Sizes.indexOf(b)){for(var d=0;b>this.base2Sizes[d];)d++;b=this.base2Sizes[d]}if(-1==this.base2Sizes.indexOf(c)){for(var d=0;c>this.base2Sizes[d];)d++;c=this.base2Sizes[d]}if(a.width!==b||a.height!==c){var e=document.createElement("canvas");return e.width=b,e.height=c,e.getContext("2d").drawImage(a,0,0),e}return a},b.base2Sizes=[2,4,16,32,64,128,256,512,1024,2048,4096],b}();b.Common=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"GameMath"},b.computeMachineEpsilon=function(){var a=4/3,b=a-1,c=b+b+b;return Math.abs(1-c)},b.fuzzyEqual=function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)a},b.fuzzyGreaterThan=function(a,b,c){return void 0===c&&(c=1e-4),a>b-c},b.fuzzyCeil=function(a,b){return void 0===b&&(b=1e-4),Math.ceil(a-b)},b.fuzzyFloor=function(a,b){return void 0===b&&(b=1e-4),Math.floor(a+b)},b.average=function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},b.shear=function(a){return a%1},b.wrap=function(a,b,c){if(void 0===c&&(c=0),a-=c,b-=c,0==b)return c;for(a%=b,a+=c;c>a;)a+=b;return a},b.arithWrap=function(a,b,c){return void 0===c&&(c=0),b-=c,0==b?c:a-b*Math.floor((a-c)/b)},b.clamp=function(a,b,c){return void 0===c&&(c=0),Math.max(c,Math.min(b,a))},b.snapTo=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},b.snapToFloor=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},b.snapToCeil=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},b.snapToInArray=function(a,b,c){if(void 0===c&&(c=!0),c&&b.sort(),a=f-a?f:e},b.roundTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},b.floorTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},b.ceilTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},b.interpolateFloat=function(a,b,c){return(b-a)*c+a},b.radiansToDegrees=function(a){return a*b.RAD_TO_DEG},b.degreesToRadians=function(a){return a*b.DEG_TO_RAD},b.angleBetween=function(a,b,c,d){return Math.atan2(d-b,c-a)},b.normalizeAngle=function(a,c){void 0===c&&(c=!0);var d=c?b.PI:180;return b.wrap(a,d,-d)},b.nearestAngleBetween=function(a,c,d){void 0===d&&(d=!0);var e=d?b.PI:180;return a=b.normalizeAngle(a,d),c=b.normalizeAngle(c,d),-e/2>a&&c>e/2&&(a+=2*e),-e/2>c&&a>e/2&&(c+=2*e),b.normalizeAngle(c-a,d)},b.normalizeAngleToAnother=function(b,c,d){return void 0===d&&(d=!0),c+a.Utils.GameMath.nearestAngleBetween(c,b,d)},b.normalizeAngleAfterAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(b-c,d),c+b},b.normalizeAngleBeforeAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(c-b,d),c-b},b.interpolateAngles=function(b,c,d,e,f){return void 0===e&&(e=!0),void 0===f&&(f=null),b=a.Utils.GameMath.normalizeAngle(b,e),c=a.Utils.GameMath.normalizeAngleToAnother(c,b,e),"function"==typeof f?f(d,b,c-b,1):a.Utils.GameMath.interpolateFloat(b,c,d)},b.logBaseOf=function(a,b){return Math.log(a)/Math.log(b)},b.GCD=function(a,b){var c;for(a=Math.abs(a),b=Math.abs(b),b>a&&(c=a,a=b,b=c);;){if(c=a%b,!c)return b;a=b,b=c}return 1},b.LCM=function(b,c){return b*c/a.Utils.GameMath.GCD(b,c)},b.factorial=function(a){if(0==a)return 1;for(var b=a;--a;)b*=a;return b},b.gammaFunction=function(b){return a.Utils.GameMath.factorial(b-1)},b.fallingFactorial=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(b-c)},b.risingFactorial=function(b,c){return a.Utils.GameMath.factorial(b+c-1)/a.Utils.GameMath.factorial(b-1)},b.binCoef=function(b,c){return a.Utils.GameMath.fallingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.risingBinCoef=function(b,c){return a.Utils.GameMath.risingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.chanceRoll=function(a){return void 0===a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},b.maxAdd=function(a,b,c){return a+=b,a>c&&(a=c),a},b.minSub=function(a,b,c){return a-=b,c>a&&(a=c),a},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},b.randomSign=function(){return Math.random()>.5?1:-1},b.isOdd=function(a){return 1&a?!0:!1},b.isEven=function(a){return 1&a?!1:!0},b.wrapAngle=function(a){var b=a;return a>=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},b.angleLimit=function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},b.linearInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return 0>c?a.Utils.GameMath.linear(b[0],b[1],e):c>1?a.Utils.GameMath.linear(b[d],b[d-1],d-e):a.Utils.GameMath.linear(b[f],b[f+1>d?d:f+1],e-f)},b.bezierInterpolation=function(b,c){for(var d=0,e=b.length-1,f=0;e>=f;f++)d+=Math.pow(1-c,e-f)*Math.pow(c,f)*b[f]*a.Utils.GameMath.bernstein(e,f);return d},b.catmullRomInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return b[0]===b[d]?(0>c&&(f=Math.floor(e=d*(1+c))),a.Utils.GameMath.catmullRom(b[(f-1+d)%d],b[f],b[(f+1)%d],b[(f+2)%d],e-f)):0>c?b[0]-(a.Utils.GameMath.catmullRom(b[0],b[0],b[1],b[1],-e)-b[0]):c>1?b[d]-(a.Utils.GameMath.catmullRom(b[d],b[d],b[d-1],b[d-1],e-d)-b[d]):a.Utils.GameMath.catmullRom(b[f?f-1:0],b[f],b[f+1>d?d:f+1],b[f+2>d?d:f+2],e-f)},b.linear=function(a,b,c){return(b-a)*c+a},b.bernstein=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(c)/a.Utils.GameMath.factorial(b-c)},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},b.difference=function(a,b){return Math.abs(a-b)},b.PI=3.141592653589793,b.PI_2=1.5707963267948966,b.PI_4=.7853981633974483,b.PI_8=.39269908169872414,b.PI_16=.19634954084936207,b.TWO_PI=6.283185307179586,b.THREE_PI_2=4.71238898038469,b.E=2.71828182845905,b.LN10=2.302585092994046,b.LN2=.6931471805599453,b.LOG10E=.4342944819032518,b.LOG2E=1.4426950408889634,b.SQRT1_2=.7071067811865476,b.SQRT2=1.4142135623730951,b.DEG_TO_RAD=.017453292519943295,b.RAD_TO_DEG=57.29577951308232,b.B_16=65536,b.B_31=2147483648,b.B_32=4294967296,b.B_48=281474976710656,b.B_53=9007199254740992,b.B_64=0x10000000000000000,b.ONE_THIRD=.3333333333333333,b.TWO_THIRDS=.6666666666666666,b.ONE_SIXTH=.16666666666666666,b.COS_PI_3=.8660254037844386,b.SIN_2PI_3=.03654595,b.CIRCLE_ALPHA=.5522847498307935,b.ON=!0,b.OFF=!1,b.SHORT_EPSILON=.1,b.PERC_EPSILON=.001,b.EPSILON=1e-4,b.LONG_EPSILON=1e-8,b}();b.GameMath=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){void 0===a&&(a=[]),this.c=1,this._data={lipsum:["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","nunc","sagittis","tortor","ac","mi","pretium","sed","convallis","massa","pulvinar","curabitur","non","turpis","velit","vitae","rutrum","odio","aliquam","sapien","orci","tempor","sed","elementum","sit","amet","tincidunt","sed","risus","etiam","nec","lacus","id","ante","hendrerit","malesuada","donec","porttitor","magna","eget","libero","pharetra","sollicitudin","aliquam","mattis","mattis","massa","et","porta","morbi","vitae","magna","augue","vestibulum","at","lectus","sed","tellus","facilisis","tincidunt","suspendisse","eros","magna","consequat","at","sollicitudin","ac","vestibulum","vel","dolor","in","egestas","lacus","quis","lacus","placerat","et","molestie","ipsum","scelerisque","nullam","sit","amet","tortor","dui","aenean","pulvinar","odio","nec","placerat","fringilla","neque","dolor"]},this.sow(a)}return a.prototype.objType=function(){return"RandomDataGenerator"},a.prototype.uint32=function(){return 4294967296*this.rnd.apply(this)},a.prototype.fract32=function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},a.prototype.rnd=function(){var a=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|a,this.s0=this.s1,this.s1=this.s2,this.s2=a-this.c,this.s2},a.prototype.hash=function(a){var b,c,d;for(d=4022871197,a=a.toString(),c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},a.prototype.sow=function(a){void 0===a&&(a=[]),this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1);for(var b,c=0;b=a[c++];)this.s0-=this.hash(b),this.s0+=~~(this.s0<0),this.s1-=this.hash(b),this.s1+=~~(this.s1<0),this.s2-=this.hash(b),this.s2+=~~(this.s2<0)},a.prototype.integer=function(){return this.uint32()},a.prototype.frac=function(){return this.fract32()},a.prototype.real=function(){return this.uint32()+this.fract32()},a.prototype.integerInRange=function(a,b){return Math.floor(this.realInRange(a,b))},a.prototype.realInRange=function(a,b){return a=a||0,b=b||0,this.frac()*(b-a)+a},a.prototype.normal=function(){return 1-2*this.frac()},a.prototype.uuid=function(){var a,b;for(b=a="";a++<36;b+=~a%5|3*a&4?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},a.prototype.pick=function(a){return a[this.integerInRange(0,a.length)]},a.prototype.weightedPick=function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},a.prototype.word=function(){return this.pick(this._data.lipsum)},a.prototype.words=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.pick(this._data.lipsum));return b.join(" ")},a.prototype.sentence=function(){var a;return a=this.words(this.integerInRange(2,16)).replace(/[a-z]/,function(a){return a.toUpperCase()}),a+"."},a.prototype.sentences=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.sentence());return b.join(" ")},a.prototype.timestamp=function(a,b){return void 0===a&&(a=9466848e5),void 0===b&&(b=1577862e6),this.realInRange(a,b)},a.prototype.angle=function(){return this.integerInRange(-180,180)},a}();a.RandomDataGenerator=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._isSetTimeOut=!1,this.lastTime=0,this.currentTime=0,this.isRunning=!1,this._rafId=null,this._callback=a;for(var b=["ms","moz","webkit","o"],c=0;c0?this.recordings[this.recordings.length-1].time:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"numRecordings",{get:function(){return this.recordings.length},enumerable:!0,configurable:!0}),b.prototype.record=function(a,b,c){if(void 0===b&&(b=[]),void 0===c&&(c=console.log),this.recording){var d={messages:a,time:Date.now(),tags:b,logMethod:c};this.recordings.push(d)>this.maxRecordings&&this.recordings.shift()}},b.prototype.clearRecordings=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.recordings.length),this.recordings.splice(a,b)},b.prototype._execute=function(a,b,c,d){void 0===d&&(d=!1),(this.display||d)&&a.apply(b,c)},b.prototype.getTagsFromArray=function(a){for(var b=0,c=[];bd.time&&this._show(d,c)},b.prototype.addFilter=function(){for(var a=[],b=0;be.majorVersion?"greater":d.majorVersione.minorVersion?"greater":d.minorVersione.patchVersion?"greater":d.patchVersion this.x + halfWidth || x < this.x - halfWidth) return -1; - if (y > this.y + this.heightInPixels || y < this.y) return -1; - - - + var halfHeight = this.heightInPixels * 0.5; + if (Math.abs(x) > halfWidth - halfWidth * Math.abs(y - halfHeight) / halfHeight) return -1; + var point = this.screenToChart({ x: x, y: y }); return this.getIndexFromXY(point.x, point.y); - } - /** - * ChartToScreen maps a point in the game tile coordinates into screen pixel - * coordinates that indicate where the tile should be drawn. - * - * @method chartToScreen - * @param chartPt {any} A Object containing x/y properties of the tile. - * @param [tileW] {Number} The width of the tile - * @param [tileH] {Number} The height of the tile - * @return {Object} With x/y properties of the location of the map onscreen. - * @public - */ + /** + * ChartToScreen maps a point in the game tile coordinates into screen pixel + * coordinates that indicate where the tile should be drawn. + * + * @method chartToScreen + * @param chartPt {any} A Object containing x/y properties of the tile. + * @param [tileW] {Number} The width of the tile + * @param [tileH] {Number} The height of the tile + * @return {Object} With x/y properties of the location of the map onscreen. + * @public + */ public chartToScreen(chartPt: any, tileW: number = this.tileWidth, tileH: number = this.tileHeight): any { return { @@ -109,33 +105,36 @@ module Kiwi.GameObjects.Tilemap { } - /** - * ScreenToChart maps a point in screen coordinates into the game tile chart - * coordinates for the tile on which the screen point falls on. - * - * @method screenToChart - * @param scrPt {any} An object containing x/y coordinates of the point on the screen you want to convert to tile coordinates. - * @param [tileW] {Number} The width of a single tile. - * @param [tileH] {Number} The height of a single tile. - * @return {Object} With x/y properties of the location of tile on the screen. - * @public - */ + /** + * ScreenToChart maps a point in screen coordinates into the game tile chart + * coordinates for the tile on which the screen point falls on. + * + * @method screenToChart + * @param scrPt {any} An object containing x/y coordinates of the point on the screen you want to convert to tile coordinates. + * @param [tileW] {Number} The width of a single tile. + * @param [tileH] {Number} The height of a single tile. + * @return {Object} With x/y properties of the location of tile on the screen. + * @public + */ public screenToChart(scrPt: any, tileW: number=this.tileWidth, tileH: number=this.tileHeight): any { - var column = Math.floor( scrPt.x / (tileW * 0.5) ); - var row = Math.floor( ( scrPt.y - column * ( tileH / 2 ) ) / tileH); + var xht = scrPt.x / (tileW * 0.5); + var yht = scrPt.y / (tileH * 0.5); + var col = Math.floor((xht + yht) * 0.5); + var row = Math.floor((yht - xht) * 0.5); + return { - x: column + row, + x: col, y: row }; } - /** - * The render loop which is used when using the Canvas renderer. - * @method render - * @param camera {Camera} - * @public - */ + /** + * The render loop which is used when using the Canvas renderer. + * @method render + * @param camera {Camera} + * @public + */ public render(camera: Kiwi.Camera) { //When not to render the map. @@ -223,7 +222,7 @@ module Kiwi.GameObjects.Tilemap { //Loop through the tiles. for (var y = this._startY; y < this._maxY; y++) { for (var x = this._startX; x < this._maxX; x++) { - + //Get the tile type this._temptype = this.getTileFromXY(x, y); @@ -232,7 +231,7 @@ module Kiwi.GameObjects.Tilemap { //Skip tiletypes that don't use a cellIndex. if (this._temptype.cellIndex == -1) continue; - + //Get the cell index var cell = this.atlas.cells[this._temptype.cellIndex]; @@ -241,7 +240,7 @@ module Kiwi.GameObjects.Tilemap { var offsetY = this._temptype.offset.y; var w = this.tileWidth * (this.width * 2 - 1); var h = this.tileHeight * this.height; - + // We want <0,0>'s horizontal center point to be in the screen center, hence the -tileWidth/2. var shiftX = this.tileWidth / 2; diff --git a/templateGame/lib/kiwi.js b/templateGame/lib/kiwi.js index afa7e54c..2ccebfdc 100644 --- a/templateGame/lib/kiwi.js +++ b/templateGame/lib/kiwi.js @@ -496,7 +496,8 @@ var Kiwi; this.states.update(); this.pluginManager.update(); this._frame++; - this._lastTime = this.raf.currentTime - (this._delta % this._interval); + this._lastTime = + this.raf.currentTime - (this._delta % this._interval); } // Graphics MUST be drawn every frame to avert frame buffer issues // under some clients @@ -853,8 +854,7 @@ var Kiwi; r: this._color.r, g: this._color.g, b: this._color.b, - a: this._color.a - }; + a: this._color.a }; }, enumerable: true, configurable: true @@ -1153,6 +1153,7 @@ var Kiwi; } } if (this._game.deviceTargetOption == Kiwi.TARGET_COCOON) { + // This has no effect in WebGL, and is thus handled separately. switch (this._scaleType) { case Kiwi.Stage.SCALE_FIT: this.canvas.style.cssText = "idtkscale:ScaleAspectFit"; @@ -1576,9 +1577,7 @@ var Kiwi; var plugins = []; for (var i = 0; i < PluginManager._availablePlugins.length; i++) { plugins.push({ - name: PluginManager._availablePlugins[i].name, - version: PluginManager._availablePlugins[i].version - }); + name: PluginManager._availablePlugins[i].name, version: PluginManager._availablePlugins[i].version }); } return plugins; }, @@ -1882,6 +1881,7 @@ var Kiwi; if (this._cameras.length === 0) { return false; } + //render each camera for (var i = 0; i < this._cameras.length; i++) { this._cameras[i].render(); } @@ -2867,6 +2867,7 @@ var Kiwi; for (var _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } + //Loop through the arguments for (var i = 0; i < args.length; i++) { if (this._tags.indexOf(args[i]) == -1) { this._tags.push(args[i]); @@ -3133,22 +3134,19 @@ var Kiwi; * @method preUpdate * @public */ - Component.prototype.preUpdate = function () { - }; + Component.prototype.preUpdate = function () { }; /** * If the component is being added to a State rather than a Game Object then over-ride its update method to perform required tasks. * @method update * @public */ - Component.prototype.update = function () { - }; + Component.prototype.update = function () { }; /** * Components can postUpdate, that is run an update after the parent has updated. This is to be overriden by subclasses. * @method postUpdate * @public */ - Component.prototype.postUpdate = function () { - }; + Component.prototype.postUpdate = function () { }; /** * Destroys this component and all of the properties that exist on it. * @method destroy @@ -4275,6 +4273,7 @@ var Kiwi; for (var _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } + //Loop through the arguments for (var i = 0; i < args.length; i++) { if (this._tags.indexOf(args[i]) == -1) { this._tags.push(args[i]); @@ -4333,6 +4332,7 @@ var Kiwi; if (this._tempRemoveChildren !== null) destroyChildren = this._tempRemoveChildren; if (destroyChildren == true) { + //Remove all of the children. for (var i = 0; i < this.members.length; i++) { this.members[i].destroy(true); } @@ -4364,11 +4364,10 @@ var Kiwi; * @module Kiwi * */ -var __extends = this.__extends || function (d, b) { +var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Kiwi; (function (Kiwi) { @@ -4466,8 +4465,7 @@ var Kiwi; * @method preload * @public */ - State.prototype.preload = function () { - }; + State.prototype.preload = function () { }; /** * This method is progressively called whilst loading files and is executed each time a file has been loaded. * This can be used to create a 'progress' bar during the loading stage of a game. @@ -4477,15 +4475,13 @@ var Kiwi; * @param file {Kiwi.Files.File} The last file to have been loaded. * @public */ - State.prototype.loadProgress = function (percent, bytesLoaded, file) { - }; + State.prototype.loadProgress = function (percent, bytesLoaded, file) { }; /** * Gets executed when the game is finished loading and it is about to 'create' the state. * @method loadComplete * @public */ - State.prototype.loadComplete = function () { - }; + State.prototype.loadComplete = function () { }; /** * The game loop that gets executed while the game is loading. * @method loadUpdate @@ -4550,15 +4546,13 @@ var Kiwi; * @method postRender * @public */ - State.prototype.postRender = function () { - }; + State.prototype.postRender = function () { }; /** * Called just before this State is going to be Shut Down and another one is going to be switched too. * @method shutDown * @public */ - State.prototype.shutDown = function () { - }; + State.prototype.shutDown = function () { }; /* *-------------- * Loading Methods @@ -4700,11 +4694,13 @@ var Kiwi; State.prototype.destroy = function (deleteAll) { if (deleteAll === void 0) { deleteAll = true; } if (deleteAll == true) { + //destroy all of the tracking list while (this._trackingList.length > 0) { //If the item is a group then we don't want it to destroy it's children, as this method will do that eventually anyway. this._trackingList[0].destroy(true, false); } this._trackingList = []; + //destroy all of the groups members. Usually they would be apart of the trackingList while (this.members.length > 0) { //If the item is a group then we don't want it to destroy it's children, as this method will do that eventually anyway. this.members[0].destroy(true, false); @@ -5168,6 +5164,8 @@ var Kiwi; } bindings = this._bindings.slice(0); //clone array in case add/remove items during dispatch this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch. + //execute all callbacks until end of the list or until a callback returns `false` or stops propagation + //reverse loop since listeners with higher priority will be added at the end of the list do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false); @@ -5863,12 +5861,13 @@ var Kiwi; w: this._canvas.width, h: this._canvas.height, hitboxes: [{ - x: this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_LEFT ? 0 : this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_CENTER ? -this._alignWidth * 0.5 : -this._alignWidth, - y: 0, - w: this.width, - h: this.height - }] - }; + x: this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_LEFT ? 0 : + this._textAlign === Kiwi.GameObjects.TextField.TEXT_ALIGN_CENTER ? + -this._alignWidth * 0.5 : -this._alignWidth, + y: 0, + w: this.width, + h: this.height + }] }; this._tempDirty = false; this.atlas.dirty = true; }; @@ -5952,7 +5951,12 @@ var Kiwi; m.transformPoint(this._pt3); m.transformPoint(this._pt4); //Append to the xyuv and alpha arrays - vertexItems.push(this._pt1.x, this._pt1.y, 0, 0, this.alpha, this._pt2.x, this._pt2.y, this._canvas.width, 0, this.alpha, this._pt3.x, this._pt3.y, this._canvas.width, this._canvas.height, this.alpha, this._pt4.x, this._pt4.y, 0, this._canvas.height, this.alpha); + vertexItems.push(this._pt1.x, this._pt1.y, 0, 0, this.alpha, + //Top Left Point + this._pt2.x, this._pt2.y, this._canvas.width, 0, this.alpha, + //Top Right Point + this._pt3.x, this._pt3.y, this._canvas.width, this._canvas.height, this.alpha, //Bottom Right Point + this._pt4.x, this._pt4.y, 0, this._canvas.height, this.alpha); //Add to the batch! this.glRenderer.concatBatch(vertexItems); }; @@ -6180,6 +6184,7 @@ var Kiwi; if (Kiwi.Utils.Common.isString(atlas)) { atlas = this.state.textures[atlas]; } + //Does the JSON exist? switch (typeof tileMapData) { case 'string': if (this.game.fileStore.exists(tileMapData) == false) { @@ -6211,14 +6216,17 @@ var Kiwi; this.tileHeight = (json.tileheight == undefined) ? 32 : json.tileheight; this.width = json.width; this.height = json.height; + //Add the properties for (var prop in json.properties) { this.properties[prop] = json.properties[prop]; } //Generate the Tiles needed. if (json.tilesets !== "undefined" && startingCell !== -1) this._generateTypesFromTileset(json.tilesets, atlas, startingCell); + //Generate the layers we need for (var i = 0; i < json.layers.length; i++) { var layerData = json.layers[i]; + //Check what type it is. switch (json.layers[i].type) { case "tilelayer": var w = (layerData.width !== undefined) ? layerData.width : this.width; @@ -6249,6 +6257,7 @@ var Kiwi; * @private */ TileMap.prototype._generateTypesFromTileset = function (tilesetData, atlas, startingCell) { + //Loop through the tilesets for (var i = 0; i < tilesetData.length; i++) { var tileset = tilesetData[i]; //Tileset Information @@ -6260,6 +6269,7 @@ var Kiwi; var ih = tileset.imageheight - m; //Drawing offsets var offset = (tileset.tileoffset == undefined) ? { x: 0, y: 0 } : tileset.tileoffset; + //Calculate how many tiles there are in this tileset and thus how many different tile type there can be. for (var y = m; y < ih; y += th) { for (var x = m; x < iw; x += tw) { //Does the cell exist? Then use that. @@ -6270,6 +6280,7 @@ var Kiwi; startingCell++; //Increase the cell to use by one. } } + //Add tile properties for (var tp in tileset.tileproperties) { var tileType = this.tileTypes[(parseInt(tileset.firstgid) + parseInt(tp))]; tileType.properties = tileset.tileproperties[tp]; @@ -6620,8 +6631,7 @@ var Kiwi; get: function () { return null; }, - set: function (val) { - }, + set: function (val) { }, enumerable: true, configurable: true }); @@ -6986,6 +6996,7 @@ var Kiwi; width = this.width - x; if (y + height > this.height) height = this.height - y; + //Loop through and of the tiles. for (var j = y; j < y + height; j++) { for (var i = x; i < x + width; i++) { //Get the tile index. @@ -7197,6 +7208,7 @@ var Kiwi; var h = Kiwi.Utils.GameMath.snapToCeil(b.height, this.tileHeight) / this.tileHeight; //Add one, because we want to include the very end tile. var tiles = this.getCollidableTiles(x, y, w + 1, h + 1, collisionType); + //Loop through the tiles and make sure they are actually overlapping with the Entity. for (var i = 0; i < tiles.length; i++) { var t = tiles[i]; if (t.x + worldX > b.right || t.x + this.tileWidth + worldX < b.left || t.y + worldY > b.bottom || t.y + this.tileHeight + worldY < b.top) { @@ -7301,6 +7313,7 @@ var Kiwi; var m = t.getConcatenatedMatrix(); //Find which ones we need to render. this._calculateBoundaries(camera, m); + //Loop through the tiles. for (var y = this._startY; y < this._maxY; y++) { for (var x = this._startX; x < this._maxX; x++) { //Get the tile type @@ -7323,7 +7336,11 @@ var Kiwi; m.transformPoint(this._corner3); m.transformPoint(this._corner4); //Append to the xyuv array - vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha); + vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, //Top Left Point + this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, //Top Right Point + this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, //Bottom Right Point + this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha //Bottom Left Point + ); } } //Concat points to the Renderer. @@ -7412,9 +7429,8 @@ var Kiwi; TileMapLayerIsometric.prototype.getIndexFromCoords = function (x, y) { //Not within the bounds? var halfWidth = this.widthInPixels * 0.5; - if (x > this.x + halfWidth || x < this.x - halfWidth) - return -1; - if (y > this.y + this.heightInPixels || y < this.y) + var halfHeight = this.heightInPixels * 0.5; + if (Math.abs(x) > halfWidth - halfWidth * Math.abs(y - halfHeight) / halfHeight) return -1; var point = this.screenToChart({ x: x, y: y }); return this.getIndexFromXY(point.x, point.y); @@ -7452,10 +7468,12 @@ var Kiwi; TileMapLayerIsometric.prototype.screenToChart = function (scrPt, tileW, tileH) { if (tileW === void 0) { tileW = this.tileWidth; } if (tileH === void 0) { tileH = this.tileHeight; } - var column = Math.floor(scrPt.x / (tileW * 0.5)); - var row = Math.floor((scrPt.y - column * (tileH / 2)) / tileH); + var xht = scrPt.x / (tileW * 0.5); + var yht = scrPt.y / (tileH * 0.5); + var col = Math.floor((xht + yht) * 0.5); + var row = Math.floor((yht - xht) * 0.5); return { - x: column + row, + x: col, y: row }; }; @@ -7511,6 +7529,7 @@ var Kiwi; var m = t.getConcatenatedMatrix(); //Find which ones we need to render. this._calculateBoundaries(camera, m); + //Loop through the tiles. for (var y = this._startY; y < this._maxY; y++) { for (var x = this._startX; x < this._maxX; x++) { //Get the tile type @@ -7541,7 +7560,11 @@ var Kiwi; m.transformPoint(this._corner3); m.transformPoint(this._corner4); //Append to the xyuv array - vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha); + vertexItems.push(this._corner1.x + t.rotPointX, this._corner1.y + t.rotPointY, cell.x, cell.y, this.alpha, //Top Left Point + this._corner2.x + t.rotPointX, this._corner2.y + t.rotPointY, cell.x + cell.w, cell.y, this.alpha, //Top Right Point + this._corner3.x + t.rotPointX, this._corner3.y + t.rotPointY, cell.x + cell.w, cell.y + cell.h, this.alpha, //Bottom Right Point + this._corner4.x + t.rotPointX, this._corner4.y + t.rotPointY, cell.x, cell.y + cell.h, this.alpha //Bottom Left Point + ); } } //Concat points to the Renderer. @@ -7840,6 +7863,8 @@ var Kiwi; this.onChange.dispatch(name, this.currentAnimation); } else if (inheritFromTexture) { + //Check to see if that animation exists on the atlas. + //If so create a new version of it. for (var i = 0; i < this._atlas.sequences.length; i++) { if (this._atlas.sequences[i].name === name) { this.currentAnimation = this.createFromSequence(this._atlas.sequences[i], false); @@ -8028,8 +8053,10 @@ var Kiwi; */ get: function () { if (this.autoUpdate == true && this.entity.atlas !== null && this.entity.atlas.cells && this.entity.atlas.cells[0].hitboxes) { - this._hitboxOffset.x = this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].x || 0; - this._hitboxOffset.y = this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].y || 0; + this._hitboxOffset.x = + this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].x || 0; + this._hitboxOffset.y = + this.entity.atlas.cells[this.entity.cellIndex].hitboxes[0].y || 0; } return this._hitboxOffset; }, @@ -8490,9 +8517,7 @@ var Kiwi; * @type Kiwi.Signal * @public */ - get: function () { - return this._onDragStarted; - }, + get: function () { return this._onDragStarted; }, enumerable: true, configurable: true }); @@ -8504,9 +8529,7 @@ var Kiwi; * @type Kiwi.Signal * @public */ - get: function () { - return this._onDragStopped; - }, + get: function () { return this._onDragStopped; }, enumerable: true, configurable: true }); @@ -8618,9 +8641,7 @@ var Kiwi; * @type boolean * @public */ - get: function () { - return (this._isDragging !== null); - }, + get: function () { return (this._isDragging !== null); }, enumerable: true, configurable: true }); @@ -9625,7 +9646,8 @@ var Kiwi; if (gameObject.components.hasComponent('Box') == false) return; var box = gameObject.components.getComponent('Box'); - var result = (box.worldHitbox.x + box.worldHitbox.width > this.box.worldHitbox.x) && (box.worldHitbox.x < this.box.worldHitbox.x + this.box.worldHitbox.width) && (box.worldHitbox.y + box.worldHitbox.height > this.box.worldHitbox.y) && (box.worldHitbox.y < this.box.worldHitbox.y + this.box.worldHitbox.height); + var result = (box.worldHitbox.x + box.worldHitbox.width > this.box.worldHitbox.x) && (box.worldHitbox.x < this.box.worldHitbox.x + this.box.worldHitbox.width) && + (box.worldHitbox.y + box.worldHitbox.height > this.box.worldHitbox.y) && (box.worldHitbox.y < this.box.worldHitbox.y + this.box.worldHitbox.height); if (result) { if (separateObjects) ArcadePhysics.separate(this.owner, gameObject); @@ -9929,6 +9951,7 @@ var Kiwi; ArcadePhysics.overlapsArrayGroup = function (array, group, separateObjects) { if (separateObjects === void 0) { separateObjects = true; } var result = false; + //loop through the array for (var i = 0; i < array.length; i++) { if (typeof array[i].childType !== "undefined") { if (array[i].childType() === Kiwi.GROUP) { @@ -11238,6 +11261,7 @@ var Kiwi; this.data[dataFile.key] = dataFile; break; default: + //Image file is of unknown type and was not added to data library break; } }; @@ -13062,7 +13086,9 @@ var Kiwi; this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; this.fileSystem = !!window['requestFileSystem']; this.worker = !!window['Worker']; - if ('ontouchstart' in document.documentElement || (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 0) || (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 0)) { + if ('ontouchstart' in document.documentElement || + (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 0) || + (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 0)) { this.touch = true; } if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) { @@ -13147,8 +13173,7 @@ var Kiwi; } } } - catch (e) { - } + catch (e) { } }; /** * @@ -13482,6 +13507,7 @@ var Kiwi; this.textures[imageFile.key] = this._buildTextureAtlas(imageFile); break; default: + //Image file is of unknown type and was not added to texture library break; } }; @@ -15194,14 +15220,17 @@ var Kiwi; this._onStartCallbackFired = true; } var elapsed = (time - this._startTime) / this._duration; - elapsed = elapsed > 1 ? 1 : elapsed < 0 ? 0 : elapsed; + elapsed = elapsed > 1 ? 1 : + elapsed < 0 ? 0 : + elapsed; var value = this._easingFunction(elapsed); for (var property in this._valuesStart) { var start = this._valuesStart[property]; var end = this._valuesEnd[property]; // Add checks for object, array, numeric up front if (end instanceof Array) { - this._object[property] = this._interpolationFunction(end, value); + this._object[property] = + this._interpolationFunction(end, value); } else { if (typeof this._object[property] === "function") { @@ -15217,7 +15246,8 @@ var Kiwi; } if (elapsed === 1) { this.isRunning = false; - if (this._onCompleteCallback !== null && this._onCompleteCalled === false) { + if (this._onCompleteCallback !== null && + this._onCompleteCalled === false) { this._onCompleteCalled = true; this._onCompleteCallback.call(this._onCompleteContext, this._object); } @@ -15827,7 +15857,10 @@ var Kiwi; this._batches = []; var batchIndex; for (var i = 0; i < this._sequence.length; i++) { - if (!this._sequence[i].isBatchRenderer || this._sequence[i].renderer !== currentRenderer || this._sequence[i].shader !== currentShader || this._sequence[i].texture !== currentTexture) { + if (!this._sequence[i].isBatchRenderer || + this._sequence[i].renderer !== currentRenderer || + this._sequence[i].shader !== currentShader || + this._sequence[i].texture !== currentTexture) { //create a new batch var batchIndex = this._batches.push(new Array()) - 1; currentRenderer = this._sequence[i].renderer; @@ -15865,6 +15898,7 @@ var Kiwi; } // Clear renderer for fresh data this._currentRenderer.clear(gl, { camMatrix: this.camMatrix }); + // Call render functions for (var i = 0; i < batch.length; i++) batch[i].entity.renderGL(gl, camera); // Upload textures @@ -16594,14 +16628,10 @@ var Kiwi; * @public */ GLArrayBuffer.squareVertices = [ - 0, - 0, - 100, - 0, - 100, - 100, - 0, - 100 + 0, 0, + 100, 0, + 100, 100, + 0, 100 ]; /** * @@ -16612,14 +16642,10 @@ var Kiwi; * @public */ GLArrayBuffer.squareUVs = [ - 0, - 0, - .1, - 0, - .1, - .1, - 0, - .1 + 0, 0, + .1, 0, + .1, .1, + 0, .1 ]; /** * @@ -16630,10 +16656,7 @@ var Kiwi; * @public */ GLArrayBuffer.squareCols = [ - 1, - 1, - 1, - 1 + 1, 1, 1, 1 ]; return GLArrayBuffer; })(); @@ -16884,7 +16907,12 @@ var Kiwi; GLBlendMode.prototype.isIdentical = function (blendMode) { if (this == blendMode) return (true); - if (this._srcRGB == blendMode._srcRGB && this._dstRGB == blendMode._dstRGB && this._srcAlpha == blendMode._srcAlpha && this._dstAlpha == blendMode._dstAlpha && this._modeRGB == blendMode._modeRGB && this._modeAlpha == blendMode._modeAlpha) + if (this._srcRGB == blendMode._srcRGB + && this._dstRGB == blendMode._dstRGB + && this._srcAlpha == blendMode._srcAlpha + && this._dstAlpha == blendMode._dstAlpha + && this._modeRGB == blendMode._modeRGB + && this._modeAlpha == blendMode._modeAlpha) return (true); return (false); }; @@ -16980,12 +17008,8 @@ var Kiwi; * @public */ GLElementArrayBuffer.square = [ - 0, - 1, - 2, - 0, - 2, - 3 + 0, 1, 2, + 0, 2, 3 ]; return GLElementArrayBuffer; })(); @@ -17981,7 +18005,8 @@ var Kiwi; var frameDelta, i, repeats; if (this._isPlaying) { // How many frames do we move, ahead or behind? - frameDelta = ((this.clock.elapsed() - this._lastFrameElapsed) / this._speed) % (this.length + 1); + frameDelta = ((this.clock.elapsed() - + this._lastFrameElapsed) / this._speed) % (this.length + 1); if (this._reverse) { frameDelta *= -1; } @@ -18008,7 +18033,8 @@ var Kiwi; } else if (this._frameIndex < 0) { repeats = Math.ceil(Math.abs(this._frameIndex) / this.length); - this._frameIndex = (this.length + this._frameIndex % this.length) % this.length; + this._frameIndex = (this.length + + this._frameIndex % this.length) % this.length; if (this._onLoop != null) { for (i = 0; i < repeats; i++) { this._onLoop.dispatch(); @@ -18017,7 +18043,8 @@ var Kiwi; } } else if (this._frameIndex < 0) { - this._frameIndex = (this.length + this._frameIndex % this.length) % this.length; + this._frameIndex = (this.length + + this._frameIndex % this.length) % this.length; // Execute the stop on the parent // to allow the isPlaying boolean to remain consistent this._parent.stop(); @@ -20340,6 +20367,7 @@ var Kiwi; break; } } + //Loop through the fingers and check to see that none of them are down. for (var i = 0; i < this._fingers.length; i++) { if (this._fingers[i].active === true) { this.isDown = true; @@ -20366,6 +20394,7 @@ var Kiwi; break; } } + //loop through the fingers and check to see that none of them are down. for (var i = 0; i < this._fingers.length; i++) { if (this._fingers[i].active) { this.isDown = true; @@ -20467,6 +20496,7 @@ var Kiwi; Touch.prototype.onTouchEnter = function (event) { //Stop corresponding mouse events from firing. event.preventDefault(); + // For touch enter and leave its a list of the touch points that have entered or left the target for (var i = 0; i < event.changedTouches.length; i++) { this._enterFinger(event.changedTouches[i], event.changedTouches[i].identifier); } @@ -20481,6 +20511,7 @@ var Kiwi; Touch.prototype.onTouchLeave = function (event) { //Stops corresponding mouse events from firing event.preventDefault(); + // For touch enter and leave its a list of the touch points that have entered or left the target for (var i = 0; i < event.changedTouches.length; i++) { this._leaveFinger(event.changedTouches[i], event.changedTouches[i].identifier); } @@ -22283,11 +22314,16 @@ var Kiwi; Intersect.lineToLine = function (line1, line2, output) { if (output === void 0) { output = new Geom.IntersectResult; } output.result = false; - var denom = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2); + var denom = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - + (line1.y1 - line1.y2) * (line2.x1 - line2.x2); if (denom !== 0) { output.result = true; - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * + (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * + (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; } return output; }; @@ -22313,15 +22349,21 @@ var Kiwi; Intersect.lineToLineSegment = function (line1, seg, output) { if (output === void 0) { output = new Geom.IntersectResult; } output.result = false; - var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 - seg.x2); + var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - + (line1.y1 - line1.y2) * (seg.x1 - seg.x2); if (denom !== 0) { - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * + (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * + (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * + (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; var maxX = Math.max(seg.x1, seg.x2); var minX = Math.min(seg.x1, seg.x2); var maxY = Math.max(seg.y1, seg.y2); var minY = Math.min(seg.y1, seg.y2); - if ((output.x <= maxX && output.x >= minX) === true && (output.y <= maxY && output.y >= minY) === true) { + if ((output.x <= maxX && output.x >= minX) === true && + (output.y <= maxY && output.y >= minY) === true) { output.result = true; } } @@ -22354,7 +22396,8 @@ var Kiwi; var minX = Math.min(x1, x2); var maxY = Math.max(y1, y2); var minY = Math.min(y1, y2); - if (output.x <= maxX && output.x >= minX && output.y <= maxY && output.y >= minY) { + if (output.x <= maxX && output.x >= minX && + output.y <= maxY && output.y >= minY) { output.result = true; } } @@ -22501,7 +22544,10 @@ var Kiwi; output.result = false; Intersect.lineToLineSegment(line1, line2, output); if (output.result === true) { - if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { + if (!(output.x >= Math.min(line1.x1, line1.x2) && + output.x <= Math.max(line1.x1, line1.x2) && + output.y >= Math.min(line1.y1, line1.y2) && + output.y <= Math.max(line1.y1, line1.y2))) { output.result = false; } } @@ -22524,7 +22570,8 @@ var Kiwi; output.result = false; Intersect.lineToRay(line1, ray, output); if (output.result === true) { - if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { + if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) + && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { output.result = false; } } @@ -22557,7 +22604,8 @@ var Kiwi; } else { // Worst case - segment doesn't traverse center, so no perpendicular connection. - if (Intersect.circleContainsPoint(circle, { x: seg.x1, y: seg.y1 }).result || Intersect.circleContainsPoint(circle, { x: seg.x2, y: seg.y2 }).result) { + if (Intersect.circleContainsPoint(circle, { x: seg.x1, y: seg.y1 }).result || + Intersect.circleContainsPoint(circle, { x: seg.x2, y: seg.y2 }).result) { output.result = true; } } @@ -22751,7 +22799,8 @@ var Kiwi; return output; } // If circle centroid is within the rect, it overlaps. - if (circleRelativeX <= halfRectWidth || circleRelativeY <= rect.height / 2) { + if (circleRelativeX <= halfRectWidth || + circleRelativeY <= rect.height / 2) { output.result = true; return output; } @@ -22760,7 +22809,8 @@ var Kiwi; // own radius of this ideal corner, it overlaps. cornerDistX = circleRelativeX - halfRectWidth; cornerDistY = circleRelativeY - halfRectHeight; - output.result = cornerDistX * cornerDistX + cornerDistY * cornerDistY <= circle.radius * circle.radius; + output.result = cornerDistX * cornerDistX + cornerDistY * cornerDistY <= + circle.radius * circle.radius; return output; }; /** @@ -23378,7 +23428,12 @@ var Kiwi; * @public */ Matrix.prototype.equals = function (matrix) { - return (this.a === matrix.a && this.b === matrix.b && this.c === matrix.c && this.d === matrix.d && this.tx === matrix.tx && this.ty === matrix.ty); + return (this.a === matrix.a && + this.b === matrix.b && + this.c === matrix.c && + this.d === matrix.d && + this.tx === matrix.tx && + this.ty === matrix.ty); }; return Matrix; })(); @@ -24969,7 +25024,9 @@ var Kiwi; // Get local matrix this._cachedConcatenatedMatrix.copyFrom(this._matrix); // Apply parent transform - if (this._parent && !this._parent.ignoreChild && !this.ignoreParent) { + if (this._parent && + !this._parent.ignoreChild && + !this.ignoreParent) { this._cachedConcatenatedMatrix.tx -= this._parent.anchorPointX; this._cachedConcatenatedMatrix.ty -= this._parent.anchorPointY; this._cachedConcatenatedMatrix.prependMatrix(this.getParentMatrix()); @@ -26704,6 +26761,7 @@ var Kiwi; } } else { + //remove some for (var i = this.counter.max; i < this._icons.length; i++) { this._removeIcon(this._icons[i]); this._icons[i].destroy(); @@ -26712,6 +26770,7 @@ var Kiwi; } } } + //display them all! for (var i = 0; i < this._icons.length; i++) { if (i > (this.counter.current - 1)) { this._icons[i].style.display = 'none'; @@ -28924,6 +28983,7 @@ var Kiwi; this.audio[audioFile.key] = audioFile; break; default: + //Audio file is of unknown type and was not added to audio library break; } }; @@ -32447,6 +32507,7 @@ var Kiwi; m = n; n = r; } + //now start loop while (true) { r = m % n; if (!r) @@ -33229,106 +33290,21 @@ var Kiwi; */ this._data = { lipsum: [ - "lorem", - "ipsum", - "dolor", - "sit", - "amet", - "consectetur", - "adipiscing", - "elit", - "nunc", - "sagittis", - "tortor", - "ac", - "mi", - "pretium", - "sed", - "convallis", - "massa", - "pulvinar", - "curabitur", - "non", - "turpis", - "velit", - "vitae", - "rutrum", - "odio", - "aliquam", - "sapien", - "orci", - "tempor", - "sed", - "elementum", - "sit", - "amet", - "tincidunt", - "sed", - "risus", - "etiam", - "nec", - "lacus", - "id", - "ante", - "hendrerit", - "malesuada", - "donec", - "porttitor", - "magna", - "eget", - "libero", - "pharetra", - "sollicitudin", - "aliquam", - "mattis", - "mattis", - "massa", - "et", - "porta", - "morbi", - "vitae", - "magna", - "augue", - "vestibulum", - "at", - "lectus", - "sed", - "tellus", - "facilisis", - "tincidunt", - "suspendisse", - "eros", - "magna", - "consequat", - "at", - "sollicitudin", - "ac", - "vestibulum", - "vel", - "dolor", - "in", - "egestas", - "lacus", - "quis", - "lacus", - "placerat", - "et", - "molestie", - "ipsum", - "scelerisque", - "nullam", - "sit", - "amet", - "tortor", - "dui", - "aenean", - "pulvinar", - "odio", - "nec", - "placerat", - "fringilla", - "neque", - "dolor" + "lorem", "ipsum", "dolor", "sit", "amet", "consectetur", + "adipiscing", "elit", "nunc", "sagittis", "tortor", "ac", "mi", + "pretium", "sed", "convallis", "massa", "pulvinar", "curabitur", + "non", "turpis", "velit", "vitae", "rutrum", "odio", "aliquam", + "sapien", "orci", "tempor", "sed", "elementum", "sit", "amet", + "tincidunt", "sed", "risus", "etiam", "nec", "lacus", "id", "ante", + "hendrerit", "malesuada", "donec", "porttitor", "magna", "eget", + "libero", "pharetra", "sollicitudin", "aliquam", "mattis", "mattis", + "massa", "et", "porta", "morbi", "vitae", "magna", "augue", + "vestibulum", "at", "lectus", "sed", "tellus", "facilisis", + "tincidunt", "suspendisse", "eros", "magna", "consequat", "at", + "sollicitudin", "ac", "vestibulum", "vel", "dolor", "in", "egestas", + "lacus", "quis", "lacus", "placerat", "et", "molestie", "ipsum", + "scelerisque", "nullam", "sit", "amet", "tortor", "dui", "aenean", + "pulvinar", "odio", "nec", "placerat", "fringilla", "neque", "dolor" ] }; this.sow(seeds); @@ -33714,7 +33690,8 @@ var Kiwi; } else { this._isSetTimeOut = false; - this._rafId = window.requestAnimationFrame(function () { return _this.RAFUpdate(); }); + this._rafId = + window.requestAnimationFrame(function () { return _this.RAFUpdate(); }); } this.isRunning = true; }; @@ -34699,9 +34676,7 @@ var Kiwi; for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { - this.constructor = d; - } + function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); };